Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8079424

Code generator emits an extra POP for discarded boolean logical operation

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8u60, 9
    • Fix Version/s: 9
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      b66
    • CPU:
      x86_64
    • OS:
      linux

      Backports

        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 ----------

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  attila Attila Szegedi
                  Reporter:
                  webbuggrp Webbug Group
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: