Skip to content

Instantly share code, notes, and snippets.

@retronym
Created February 16, 2021 04:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save retronym/ce64349ec61b0e0b33f2f907cd98b4ae to your computer and use it in GitHub Desktop.
Save retronym/ce64349ec61b0e0b33f2f907cd98b4ae to your computer and use it in GitHub Desktop.
package p1
class Test {
def crash: Unit = {
var box: AnyRef = null
def writeBox(a: AnyRef): Unit = {
box = a
}
writeBox(null)
}
}
after beforeMethodOpt
// access flags 0x1000001
public crash()V
L0
LINENUMBER 5 L0
L1
LINENUMBER 6 L1
ACONST_NULL
ASTORE 3
L2
NEW scala/runtime/ObjectRef
DUP
ALOAD 3
INVOKESPECIAL scala/runtime/ObjectRef.<init> (Ljava/lang/Object;)V
ASTORE 4
GOTO L3
L4
L3
ALOAD 4
ACONST_NULL
ASTORE 3
ACONST_NULL
ASTORE 4
ASTORE 1
L5
LINENUMBER 12 L5
ACONST_NULL
ALOAD 1
POP
ASTORE 2
L6
LINENUMBER 9 L6
L7
ALOAD 1
ALOAD 2
PUTFIELD scala/runtime/ObjectRef.elem : Ljava/lang/Object;
GOTO L8
L9
L8
LINENUMBER 12 L8
ACONST_NULL
ASTORE 2
L10
RETURN
L11
LOCALVARIABLE box Lscala/runtime/ObjectRef; L5 L10 1
LOCALVARIABLE this Lp1/Test; L1 L11 0
LOCALVARIABLE writeBox$1_a Ljava/lang/Object; L7 L9 2
LOCALVARIABLE create_e Ljava/lang/Object; L2 L4 3
// signature TU;
// declaration: create_e extends U
MAXSTACK = 4
MAXLOCALS = 5
after nullness
// access flags 0x1000001
public crash()V
L0
LINENUMBER 5 L0
L1
LINENUMBER 6 L1
ACONST_NULL
ASTORE 3
L2
NEW scala/runtime/ObjectRef
DUP
ACONST_NULL
INVOKESPECIAL scala/runtime/ObjectRef.<init> (Ljava/lang/Object;)V
ASTORE 4
GOTO L3
L4
L3
ALOAD 4
ACONST_NULL
POP
ACONST_NULL
ASTORE 4
ASTORE 1
L5
LINENUMBER 12 L5
ACONST_NULL
ALOAD 1
POP
ASTORE 2
L6
LINENUMBER 9 L6
L7
ALOAD 1
ACONST_NULL
PUTFIELD scala/runtime/ObjectRef.elem : Ljava/lang/Object;
GOTO L8
L9
L8
LINENUMBER 12 L8
ACONST_NULL
POP
L10
RETURN
L11
LOCALVARIABLE box Lscala/runtime/ObjectRef; L5 L10 1
LOCALVARIABLE this Lp1/Test; L1 L11 0
LOCALVARIABLE writeBox$1_a Ljava/lang/Object; L7 L9 2
LOCALVARIABLE create_e Ljava/lang/Object; L2 L4 3
// signature TU;
// declaration: create_e extends U
MAXSTACK = 4
MAXLOCALS = 5
after boxUnbox
// access flags 0x1000001
public crash()V
L0
LINENUMBER 5 L0
L1
LINENUMBER 6 L1
ACONST_NULL
ASTORE 3
L2
ACONST_NULL
ASTORE 5
GOTO L3
L4
L3
ACONST_NULL
POP
ACONST_NULL
ASTORE 4
L5
LINENUMBER 12 L5
ACONST_NULL
POP
ASTORE 2
L6
LINENUMBER 9 L6
L7
ACONST_NULL
ASTORE 5
GOTO L8
L9
L8
LINENUMBER 12 L8
ACONST_NULL
POP
L10
RETURN
L11
LOCALVARIABLE box Lscala/runtime/ObjectRef; L5 L10 1
LOCALVARIABLE this Lp1/Test; L1 L11 0
LOCALVARIABLE writeBox$1_a Ljava/lang/Object; L7 L9 2
LOCALVARIABLE create_e Ljava/lang/Object; L2 L4 3
// signature TU;
// declaration: create_e extends U
MAXSTACK = 4
MAXLOCALS = 6
/tmp/HashMap.scala:3: error: Error while emitting p1/Test
scala.tools.asm.tree.analysis.AnalyzerException: While processing p1/Test.crash
at scala.tools.nsc.backend.jvm.analysis.AsmAnalyzer.<init>(AsmAnalyzer.scala:31)
at scala.tools.nsc.backend.jvm.analysis.ProdConsAnalyzer.<init>(ProdConsAnalyzer.scala:69)
at scala.tools.nsc.backend.jvm.opt.CopyProp.prodCons$lzycompute$1(CopyProp.scala:115)
at scala.tools.nsc.backend.jvm.opt.CopyProp.prodCons$1(CopyProp.scala:115)
at scala.tools.nsc.backend.jvm.opt.CopyProp.hasNoCons$1(CopyProp.scala:116)
at scala.tools.nsc.backend.jvm.opt.CopyProp.eliminateStaleStoresAndRewriteSomeIntrinsics(CopyProp.scala:139)
at scala.tools.nsc.backend.jvm.opt.LocalOpt.removalRound$2(LocalOpt.scala:316)
at scala.tools.nsc.backend.jvm.opt.LocalOpt.methodOptimizations(LocalOpt.scala:380)
at scala.tools.nsc.backend.jvm.opt.LocalOpt.$anonfun$methodOptimizations$1(LocalOpt.scala:215)
at scala.tools.nsc.backend.jvm.opt.LocalOpt.$anonfun$methodOptimizations$1$adapted(LocalOpt.scala:214)
at scala.collection.IterableOnceOps.foldLeft(IterableOnce.scala:646)
at scala.collection.IterableOnceOps.foldLeft$(IterableOnce.scala:642)
at scala.collection.AbstractIterable.foldLeft(Iterable.scala:919)
at scala.tools.nsc.backend.jvm.opt.LocalOpt.methodOptimizations(LocalOpt.scala:214)
at scala.tools.nsc.backend.jvm.PostProcessor.$anonfun$localOptimizations$1(PostProcessor.scala:129)
at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.scala:17)
at scala.reflect.internal.util.Statistics.timed(Statistics.scala:338)
at scala.tools.nsc.backend.jvm.PostProcessor.localOptimizations(PostProcessor.scala:129)
at scala.tools.nsc.backend.jvm.PostProcessor.sendToDisk(PostProcessor.scala:65)
at scala.tools.nsc.backend.jvm.GeneratedClassHandler$WritingClassHandler.$anonfun$postProcessUnit$3(GeneratedClassHandler.scala:126)
at scala.tools.nsc.backend.jvm.GeneratedClassHandler$WritingClassHandler.$anonfun$postProcessUnit$3$adapted(GeneratedClassHandler.scala:124)
at scala.collection.immutable.List.foreach(List.scala:333)
at scala.tools.nsc.backend.jvm.GeneratedClassHandler$WritingClassHandler.$anonfun$postProcessUnit$2(GeneratedClassHandler.scala:124)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
at scala.tools.nsc.backend.jvm.PostProcessorFrontendAccess$PostProcessorFrontendAccessImpl.withThreadLocalReporter(PostProcessorFrontendAccess.scala:241)
at scala.tools.nsc.backend.jvm.GeneratedClassHandler$WritingClassHandler.$anonfun$postProcessUnit$1(GeneratedClassHandler.scala:124)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
at scala.concurrent.Future$.$anonfun$apply$1(Future.scala:672)
at scala.concurrent.impl.Promise$Transformation.run(Promise.scala:431)
at scala.tools.nsc.backend.jvm.GeneratedClassHandler$SyncWritingClassHandler$$anonfun$$lessinit$greater$1.execute(GeneratedClassHandler.scala:181)
at scala.concurrent.impl.ExecutionContextImpl.execute(ExecutionContextImpl.scala:21)
at scala.concurrent.impl.Promise$Transformation.submitWithValue(Promise.scala:393)
at scala.concurrent.impl.Promise$DefaultPromise.submitWithValue(Promise.scala:302)
at scala.concurrent.impl.Promise$DefaultPromise.dispatchOrAddCallbacks(Promise.scala:276)
at scala.concurrent.impl.Promise$DefaultPromise.map(Promise.scala:146)
at scala.concurrent.Future$.apply(Future.scala:672)
at scala.tools.nsc.backend.jvm.GeneratedClassHandler$WritingClassHandler.postProcessUnit(GeneratedClassHandler.scala:120)
at scala.tools.nsc.backend.jvm.GeneratedClassHandler$WritingClassHandler.process(GeneratedClassHandler.scala:113)
at scala.tools.nsc.backend.jvm.GeneratedClassHandler$GlobalOptimisingGeneratedClassHandler.$anonfun$complete$1(GeneratedClassHandler.scala:93)
at scala.tools.nsc.backend.jvm.GeneratedClassHandler$GlobalOptimisingGeneratedClassHandler.$anonfun$complete$1$adapted(GeneratedClassHandler.scala:93)
at scala.collection.immutable.List.foreach(List.scala:333)
at scala.tools.nsc.backend.jvm.GeneratedClassHandler$GlobalOptimisingGeneratedClassHandler.complete(GeneratedClassHandler.scala:93)
at scala.tools.nsc.backend.jvm.GenBCode$BCodePhase.$anonfun$run$1(GenBCode.scala:81)
at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
at scala.reflect.internal.util.Statistics.timed(Statistics.scala:338)
at scala.tools.nsc.backend.jvm.GenBCode$BCodePhase.run(GenBCode.scala:78)
at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1515)
at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1499)
at scala.tools.nsc.Global$Run.compileSources(Global.scala:1491)
at scala.tools.nsc.Global$Run.compile(Global.scala:1626)
at scala.tools.nsc.Driver.doCompile(Driver.scala:48)
at scala.tools.nsc.MainClass.doCompile(Main.scala:30)
at scala.tools.nsc.Driver.process(Driver.scala:68)
at scala.tools.nsc.Driver.main(Driver.scala:82)
at scala.tools.nsc.Main.main(Main.scala)
Caused by: scala.tools.asm.tree.analysis.AnalyzerException: Error at instruction 20: Cannot pop operand off an empty stack.
at scala.tools.asm.tree.analysis.Analyzer.analyze(Analyzer.java:296)
at scala.tools.nsc.backend.jvm.analysis.AsmAnalyzer.<init>(AsmAnalyzer.scala:28)
... 54 more
Caused by: java.lang.IndexOutOfBoundsException: Cannot pop operand off an empty stack.
at scala.tools.asm.tree.analysis.Frame.pop(Frame.java:258)
at scala.tools.asm.tree.analysis.Frame.execute(Frame.java:333)
at scala.tools.asm.tree.analysis.Analyzer.analyze(Analyzer.java:188)
... 55 more
class Test {
^
1 error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment