JDK-8053905 : Eager code generation fails for earley boyer with split threshold set to 1000
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 9
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-07-29
  • Updated: 2015-09-29
  • Resolved: 2015-04-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u60Fixed 9 b63Fixed
Description
Discovered when trying to write a code generation time benchmark.

Repro:

java -jar dist/nashorn.jar -Dnashorn.compiler.splitter.threshold=1000 -scripting --lazy-compilation=false ../test/script/external/octane/earley-boyer.js 

Comments
Fixed in http://hg.openjdk.java.net/jdk9/dev/nashorn/rev/b275aac76cdd
27-04-2015

The problem is that the compilation of the script expects RecompilableScriptFunctionData.code to be empty because it's a non-demand eager compilation. However, since we also run with optimistic types, the code collection is populated through TypeEvaluator.getOptimisticType() as shown in the following stack trace: at jdk.nashorn.internal.runtime.RecompilableScriptFunctionData.addCode(RecompilableScriptFunctionData.java:662) at jdk.nashorn.internal.runtime.RecompilableScriptFunctionData.addCode(RecompilableScriptFunctionData.java:707) at jdk.nashorn.internal.runtime.RecompilableScriptFunctionData.getBest(RecompilableScriptFunctionData.java:731) at jdk.nashorn.internal.runtime.RecompilableScriptFunctionData.getReturnType(RecompilableScriptFunctionData.java:724) at jdk.nashorn.internal.codegen.TypeEvaluator.getEvaluatedType(TypeEvaluator.java:235) at jdk.nashorn.internal.codegen.TypeEvaluator.getOptimisticType(TypeEvaluator.java:95) at jdk.nashorn.internal.codegen.Compiler.getOptimisticType(Compiler.java:541)
26-03-2015

With current tip the assertion above does not fail anymore. However, this method in RecompilableScriptFunctionData throws IllegalStateException: public void initializeCode(final FunctionInitializer initializer) { // Since the method is public, we double-check that we aren't invoked with an inappropriate compile unit. if(!code.isEmpty()) { throw new IllegalStateException(name); } addCode(lookup(initializer), null, null, initializer.getFlags()); } I haven't looked yet at why this method is called with non-empty code collection.
31-10-2014

This assertion fails in CodeGenerator#leaveBlock: @Override public Node leaveBlock(final Block block) { popBlockScope(block); method.beforeJoinPoint(block); closeBlockVariables(block); lc.releaseSlots(); assert !method.isReachable() || (lc.isFunctionBody() ? 0 : lc.getUsedSlotCount()) == method.getFirstTemp() : "reachable="+method.isReachable() + " isFunctionBody=" + lc.isFunctionBody() + " usedSlotCount=" + lc.getUsedSlotCount() + " firstTemp=" + method.getFirstTemp(); return block; } lc.isFunctionBody() is true, but method.getFirstTemp() == lc.getUsedSlotCount() == 4 (method.isReachable() is true)
29-07-2014