JDK-8079424 : Code generator emits an extra POP for discarded boolean logical operation
  • Type: Bug
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 8u60,9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: x86_64
  • Submitted: 2015-05-01
  • Updated: 2015-09-29
  • Resolved: 2015-05-15
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 b66Fixed
Related Reports
Duplicate :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.8.0_60-ea"
Java(TM) SE Runtime Environment (build 1.8.0_60-ea-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b12, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Red Hat Enterprise Linux Workstation release 6.4 (Santiago)
Linux jfleming-ld1 2.6.32-358.6.2.el6.x86_64 #1 SMP Tue May 14 15:48:21 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux

A DESCRIPTION OF THE PROBLEM :
The Nashorn script engine in the 8u60 ea release fails on code of the following form:

true && true, true

There must be a binary logical operator, and it must be part of a compound expression. In these circumstances, it fails every time with the stack trace below. Previous releases of Nashorn handle this form correctly.

REGRESSION.  Last worked in version 8u45

ADDITIONAL REGRESSION INFORMATION: 
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Open a nashorn shell, and enter the following:

true && true, true

ACTUAL -
Exception in thread "main" java.lang.AssertionError: Failed generating bytecode for <STDIN>:1
	at jdk.nashorn.internal.codegen.CompilationPhase$13.transform(CompilationPhase.java:486)
	at jdk.nashorn.internal.codegen.CompilationPhase.apply(CompilationPhase.java:728)
	at jdk.nashorn.internal.codegen.Compiler.compile(Compiler.java:620)
	at jdk.nashorn.internal.runtime.Context.compile(Context.java:1276)
	at jdk.nashorn.internal.runtime.Context.compileScript(Context.java:1213)
	at jdk.nashorn.internal.runtime.Context.compileScript(Context.java:628)
	at jdk.nashorn.api.scripting.NashornScriptEngine.compileImpl(NashornScriptEngine.java:523)
	at jdk.nashorn.api.scripting.NashornScriptEngine.compileImpl(NashornScriptEngine.java:512)
	at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:400)
	at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:155)
	at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:264)
	at com.sun.tools.script.shell.Main.evaluateString(Main.java:298)
	at com.sun.tools.script.shell.Main.processSource(Main.java:267)
	at com.sun.tools.script.shell.Main.access$100(Main.java:37)
	at com.sun.tools.script.shell.Main$1.run(Main.java:183)
	at com.sun.tools.script.shell.Main.main(Main.java:48)
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
	at jdk.nashorn.internal.codegen.Label$Stack.pop(Label.java:300)
	at jdk.nashorn.internal.codegen.MethodEmitter.popType(MethodEmitter.java:279)
	at jdk.nashorn.internal.codegen.MethodEmitter.pop(MethodEmitter.java:502)
	at jdk.nashorn.internal.codegen.CodeGenerator.loadAND_OR(CodeGenerator.java:3808)
	at jdk.nashorn.internal.codegen.CodeGenerator.access$3300(CodeGenerator.java:181)
	at jdk.nashorn.internal.codegen.CodeGenerator$1.enterAND(CodeGenerator.java:1089)
	at jdk.nashorn.internal.ir.visitor.NodeOperatorVisitor.enterBinaryNode(NodeOperatorVisitor.java:111)
	at jdk.nashorn.internal.ir.BinaryNode.accept(BinaryNode.java:339)
	at jdk.nashorn.internal.codegen.CodeGenerator.loadExpression(CodeGenerator.java:861)
	at jdk.nashorn.internal.codegen.CodeGenerator.loadExpression(CodeGenerator.java:837)
	at jdk.nashorn.internal.codegen.CodeGenerator.loadAndDiscard(CodeGenerator.java:3678)
	at jdk.nashorn.internal.codegen.CodeGenerator.loadCOMMARIGHT(CodeGenerator.java:4127)
	at jdk.nashorn.internal.codegen.CodeGenerator.access$3200(CodeGenerator.java:181)
	at jdk.nashorn.internal.codegen.CodeGenerator$1.enterCOMMARIGHT(CodeGenerator.java:1083)
	at jdk.nashorn.internal.ir.visitor.NodeOperatorVisitor.enterBinaryNode(NodeOperatorVisitor.java:145)
	at jdk.nashorn.internal.ir.BinaryNode.accept(BinaryNode.java:339)
	at jdk.nashorn.internal.codegen.CodeGenerator.loadExpression(CodeGenerator.java:861)
	at jdk.nashorn.internal.codegen.CodeGenerator.loadExpression(CodeGenerator.java:837)
	at jdk.nashorn.internal.codegen.CodeGenerator.loadExpressionAsBoolean(CodeGenerator.java:580)
	at jdk.nashorn.internal.codegen.CodeGenerator.loadExpressionAsType(CodeGenerator.java:826)
	at jdk.nashorn.internal.codegen.CodeGenerator$14.evaluate(CodeGenerator.java:3885)
	at jdk.nashorn.internal.codegen.CodeGenerator$Store.store(CodeGenerator.java:4502)
	at jdk.nashorn.internal.codegen.CodeGenerator.loadASSIGN(CodeGenerator.java:3887)
	at jdk.nashorn.internal.codegen.CodeGenerator.access$800(CodeGenerator.java:181)
	at jdk.nashorn.internal.codegen.CodeGenerator$1.enterASSIGN(CodeGenerator.java:923)
	at jdk.nashorn.internal.ir.visitor.NodeOperatorVisitor.enterBinaryNode(NodeOperatorVisitor.java:113)
	at jdk.nashorn.internal.ir.BinaryNode.accept(BinaryNode.java:339)
	at jdk.nashorn.internal.codegen.CodeGenerator.loadExpression(CodeGenerator.java:861)
	at jdk.nashorn.internal.codegen.CodeGenerator.loadExpression(CodeGenerator.java:837)
	at jdk.nashorn.internal.codegen.CodeGenerator.loadAndDiscard(CodeGenerator.java:3678)
	at jdk.nashorn.internal.codegen.CodeGenerator.enterExpressionStatement(CodeGenerator.java:1732)
	at jdk.nashorn.internal.ir.ExpressionStatement.accept(ExpressionStatement.java:63)
	at jdk.nashorn.internal.ir.Node.accept(Node.java:261)
	at jdk.nashorn.internal.ir.Block.accept(Block.java:154)
	at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:57)
	at jdk.nashorn.internal.ir.Block.accept(Block.java:409)
	at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:374)
	at jdk.nashorn.internal.ir.LexicalContextNode$Acceptor.accept(LexicalContextNode.java:57)
	at jdk.nashorn.internal.ir.LexicalContextExpression.accept(LexicalContextExpression.java:47)
	at jdk.nashorn.internal.ir.FunctionNode.accept(FunctionNode.java:57)
	at jdk.nashorn.internal.codegen.CompilationPhase.transformFunction(CompilationPhase.java:732)
	at jdk.nashorn.internal.codegen.CompilationPhase.access$100(CompilationPhase.java:69)
	at jdk.nashorn.internal.codegen.CompilationPhase$13.transform(CompilationPhase.java:473)
	... 15 more


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
true && true, true
---------- END SOURCE ----------


Comments
My hunch is this is related to JDK-8074484
09-05-2015

Checked this for JDK 8u40, 8u45, 8u60 ea b12, and 9 ea (b55-62). --------------------------------------------------------------------------------- 8u40: OK 8u45: OK 8u60 ea b12: FAIL 9 ea b55: FAIL 9 ea b62: FAIL ---------------------------------------------------------------------------------- Conclusion: This is a regression as the exception error is reproducible with JDK 8u60 ea b12 and 9 ea builds (55, 62), while it works fine for JDK 8u40 and 8u45. Output with JDK 8u60 ea b12, 9 ea (b55-b62): ------------------------------------------------- >jjs jjs> true && true, true Exception in thread "main" java.lang.AssertionError: Failed generating bytecode for <shell>:1 at jdk.nashorn.internal.codegen.CompilationPhase$13.transform(Compilatio nPhase.java:486) .................. ................... ..................... ----------------------------------------------------------------------------------------
06-05-2015