Frame escapes and inline failed, reason recursion

Stefan Fehrenbach stefan.fehrenbach at gmail.com
Mon Jul 21 11:19:28 UTC 2014


Hello again,

thanks to Christian Humer, I got my previous parser experiment to work. :-)
I tried to apply my newly gained knowledge to "truffleize" a different parser.

I have one problem, however, and one question:

The problem is an escaping frame, see the error message below.
If I read this correctly, it starts at gll.grammar.SymbolSlot.parse
[1], which calls the push method of the gll.parser.State interface
[2]. The only implementation is in gll.parser.ParsingState [3].
There, the VirtualFrame is passed on to gll.gss.Link.schedule [4],
which does not use it currently, but probably should in the future.
What is going wrong there, and what can I do to fix it? The FAQ says
something about private/final methods, @Child fields and parent
classes, but I don't really get that.

[1] https://github.com/fehrenbach/gll/blob/20dbecaa111a481f59a54ed09e1e0c64e7aa435e/src/main/java/gll/grammar/SymbolSlot.java#L102
[2] https://github.com/fehrenbach/gll/blob/20dbecaa111a481f59a54ed09e1e0c64e7aa435e/src/main/java/gll/parser/State.java#L144
[3] https://github.com/fehrenbach/gll/blob/20dbecaa111a481f59a54ed09e1e0c64e7aa435e/src/main/java/gll/parser/ParsingState.java#L298
[4] https://github.com/fehrenbach/gll/blob/20dbecaa111a481f59a54ed09e1e0c64e7aa435e/src/main/java/gll/gss/Link.java#L94


My question is about this message "inline failed", where it says
"reason recursion". Is that a problem?
My best guess is that I have created a recursive function and truffle
won't inline it into itself.
In this code base, nonterminals are functions / CallTargets. In the
grammar below, the left hand side S is a function, and the right hand
side S is a call of that function.

S ::= ε
    | 'a' S


I think I avoided my mistakes from last time. I broke cycles in the
grammar by using function calls to form a proper AST. I tried to not
refer to AST nodes directly, but make the trampoline (Parser and
ParsingState) use CallTargets. I have non-final @Child annotated
fields.


It just occurs to me, that my last frame escapes problem went away
with an @ExplodeLoop annotation. Is the problem the loop in
ParsingState.push [3]?
How do I fix it? You use @ExplodeLoop to loop over children, right?
The "results" are not part of the AST and they might not even be
compilation final...


I hope someone can enlighten me :)

Best regards,
Stefan


/home/stefan/opt/graalvm-jdk1.8.0-0.3/bin/java -server -Xss64m
-G:+TruffleCompilationExceptionsAreFatal -G:+TraceTruffleInlining
-Dtruffle.TraceRewrites=true -Dtruffle.DetailedRewriteReasons=true
-G:+TraceTruffleCompilationDetails -G:+TraceTruffleCompilation
-G:TruffleCompilationThreshold=1 -XX:+UnlockDiagnosticVMOptions
-XX:CompileCommand=print,*::executeHelper -Didea.launcher.port=7532
-Didea.launcher.bin.path=/usr/share/intellijidea-ce/bin
-Dfile.encoding=UTF-8 -classpath
/home/stefan/opt/graalvm-jdk1.8.0-0.3/lib/dt.jar:/home/stefan/opt/graalvm-jdk1.8.0-0.3/lib/tools.jar:/home/stefan/opt/graalvm-jdk1.8.0-0.3/lib/sa-jdi.jar:/home/stefan/opt/graalvm-jdk1.8.0-0.3/lib/jconsole.jar:/home/stefan/src/gll/target/scala-2.11/test-classes:/home/stefan/src/gll/target/scala-2.11/classes:/home/stefan/.ivy2/cache/asm/asm/jars/asm-3.3.1.jar:/home/stefan/.ivy2/cache/asm/asm-analysis/jars/asm-analysis-3.3.1.jar:/home/stefan/.ivy2/cache/asm/asm-commons/jars/asm-commons-3.3.1.jar:/home/stefan/.ivy2/cache/asm/asm-tree/jars/asm-tree-3.3.1.jar:/home/stefan/.ivy2/cache/asm/asm-util/jars/asm-util-3.3.1.jar:/home/stefan/.ivy2/cache/asm/asm-xml/jars/asm-xml-3.3.1.jar:/home/stefan/.ivy2/cache/com.google.caliper/caliper/jars/caliper-0.5-rc1.jar:/home/stefan/.ivy2/cache/com.google.code.findbugs/jsr305/jars/jsr305-1.3.9.jar:/home/stefan/.ivy2/cache/com.google.code.gson/gson/jars/gson-1.7.1.jar:/home/stefan/.ivy2/cache/com.google.code.java-allocation-instrumenter/java-allocation-instrumenter/jars/java-allocation-instrumenter-2.0.jar:/home/stefan/.ivy2/cache/com.google.guava/guava/jars/guava-11.0.1.jar:/home/stefan/.ivy2/cache/com.novocode/junit-interface/jars/junit-interface-0.10-M2.jar:/home/stefan/.ivy2/cache/com.oracle/truffle/jars/truffle-0.3.jar:/home/stefan/.ivy2/cache/junit/junit/jars/junit-4.8.2.jar:/home/stefan/.ivy2/cache/junit/junit-dep/jars/junit-dep-4.10.jar:/home/stefan/.ivy2/cache/org.hamcrest/hamcrest-core/jars/hamcrest-core-1.1.jar:/home/stefan/.ivy2/cache/com.github.wookietreiber/scala-chart_2.11/jars/scala-chart_2.11-0.4.2.jar:/home/stefan/.ivy2/cache/com.storm-enroute/scalameter-core_2.11/jars/scalameter-core_2.11-0.6.jar:/home/stefan/.ivy2/cache/com.storm-enroute/scalameter_2.11/jars/scalameter_2.11-0.6.jar:/home/stefan/.ivy2/cache/org.apache.commons/commons-math3/jars/commons-math3-3.2.jar:/home/stefan/.ivy2/cache/org.jfree/jcommon/jars/jcommon-1.0.21.jar:/home/stefan/.ivy2/cache/org.jfree/jfreechart/jars/jfreechart-1.0.17.jar:/home/stefan/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.11.1.jar:/home/stefan/.ivy2/cache/org.scala-lang/scala-reflect/jars/scala-reflect-2.11.0.jar:/home/stefan/.ivy2/cache/org.scala-lang.modules/scala-parser-combinators_2.11/jars/scala-parser-combinators_2.11-1.0.1.jar:/home/stefan/.ivy2/cache/org.scala-lang.modules/scala-swing_2.11/jars/scala-swing_2.11-1.0.1.jar:/home/stefan/.ivy2/cache/org.scala-lang.modules/scala-xml_2.11/jars/scala-xml_2.11-1.0.1.jar:/home/stefan/.ivy2/cache/org.scala-tools.testing/test-interface/jars/test-interface-0.5.jar:/home/stefan/.ivy2/cache/xml-apis/xml-apis/jars/xml-apis-1.3.04.jar:/usr/share/intellijidea-ce/lib/idea_rt.jar
com.intellij.rt.execution.application.AppMain
gll.parser.TestParserWithAs
CompilerOracle: print *.executeHelper
OpenJDK 64-Bit Server VM warning: printing of assembly code is
enabled; turning on DebugNonSafepoints to gain additional output
before first
[truffle]   rewrite S
|From M SortCall                               |To M SortCallCached
                     |Reason Called S for the first time at this call
site
[truffle]   rewrite S
|From M SortCall                               |To M SortCallCached
                     |Reason Called S for the first time at this call
site
[truffle] inline start     SortCallRootNode at 1e965684
                |ASTSize      13 (0/0) |C/T          11/    3 |L/T
     11/   11 |Inval#/Replace#     0/    1
[truffle] inline failed    SortCallRootNode at 1e965684
                |ASTSize      13 (0/0) |nodeCount 2147483647/   13
|frequency        0.91 |score          0.0000 |index=  0, force=N,
callSites= 2   |reason      recursion
[truffle] inline done      SortCallRootNode at 1e965684
                |ASTSize      13 (0/0) |C/T          11/    3 |L/T
     11/   11 |Inval#/Replace#     0/    1
[truffle] opt queued       SortCallRootNode at 1e965684
                |ASTSize      13 (0/0) |C/T          11/    3 |L/T
     11/   11 |Inval#/Replace#     0/    1
[truffle] opt start        SortCallRootNode at 1e965684
                |ASTSize      13 (0/0) |C/T          20/    3 |L/T
     20/   11 |Inval#/Replace#     0/    1
after first
[truffle] opt fail         SortCallRootNode at 1e965684
                |Reason Frame escapes at:
490|MethodCallTarget#HotSpotMethod<State.push(VirtualFrame, Slot,
Stack, int, Intermediate, int)>
properties:{invokeKind=Interface,
targetMethod=HotSpotMethod<State.push(VirtualFrame, Slot, Stack, int,
Intermediate, int)>, stamp=void, returnType=HotSpotType<gll/gss/Stack,
resolved>}
arguments: [337|CheckCast, 257|NewFrame,
513|Const(SymbolSlot at 327177752), 298|CheckCast,
487|Invoke#State.getPosition, 416|Invoke#State.createEmpty, 313|Unbox]
com.oracle.graal.nodes.util.GraphUtil$2: Frame escapes at:
490|MethodCallTarget#HotSpotMethod<State.push(VirtualFrame, Slot,
Stack, int, Intermediate, int)>
properties:{invokeKind=Interface,
targetMethod=HotSpotMethod<State.push(VirtualFrame, Slot, Stack, int,
Intermediate, int)>, stamp=void, returnType=HotSpotType<gll/gss/Stack,
resolved>}
arguments: [337|CheckCast, 257|NewFrame,
513|Const(SymbolSlot at 327177752), 298|CheckCast,
487|Invoke#State.getPosition, 416|Invoke#State.createEmpty, 313|Unbox]
at gll.parser.State.push(State.java)
at gll.grammar.SymbolSlot.parse(SymbolSlot.java:103)
at gll.grammar.Production.schedule(Production.java:79)
at gll.grammar.SortCallRootNode.execute(SortCallRootNode.java:45)
at com.oracle.graal.truffle.OptimizedCallTarget.callProxy(OptimizedCallTarget.java:186)
at com.oracle.graal.truffle.OptimizedCallTarget.callRoot(OptimizedCallTarget.java:272)
Caused by: com.oracle.graal.graph.VerificationError: Frame escapes at:
490|MethodCallTarget#HotSpotMethod<State.push(VirtualFrame, Slot,
Stack, int, Intermediate, int)>
properties:{invokeKind=Interface,
targetMethod=HotSpotMethod<State.push(VirtualFrame, Slot, Stack, int,
Intermediate, int)>, stamp=void, returnType=HotSpotType<gll/gss/Stack,
resolved>}
arguments: [337|CheckCast, 257|NewFrame,
513|Const(SymbolSlot at 327177752), 298|CheckCast,
487|Invoke#State.getPosition, 416|Invoke#State.createEmpty, 313|Unbox]
at com.oracle.graal.truffle.phases.VerifyFrameDoesNotEscapePhase.run(VerifyFrameDoesNotEscapePhase.java:45)
at com.oracle.graal.phases.Phase.run(Phase.java:51)
at com.oracle.graal.phases.BasePhase.apply(BasePhase.java:73)
at com.oracle.graal.phases.Phase.apply(Phase.java:44)
at com.oracle.graal.truffle.PartialEvaluator.createGraph(PartialEvaluator.java:122)
at com.oracle.graal.truffle.TruffleCompilerImpl.compileMethodImpl(TruffleCompilerImpl.java:115)
at com.oracle.graal.truffle.hotspot.HotSpotTruffleRuntime$3.run(HotSpotTruffleRuntime.java:300)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:744)
at com.oracle.graal.compiler.CompilerThread.run(CompilerThread.java:48)


More information about the graal-dev mailing list