src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.java/src/org/graalvm/compiler/java/BytecodeParser.java
changeset 58877 aec7bf35d6f5
parent 58533 46b0b7fe255c
equal deleted inserted replaced
58876:1a8d65e71a66 58877:aec7bf35d6f5
  3219             controlFlowSplit = true;
  3219             controlFlowSplit = true;
  3220             LoopBeginNode loopBegin = appendLoopBegin(this.lastInstr, block.startBci);
  3220             LoopBeginNode loopBegin = appendLoopBegin(this.lastInstr, block.startBci);
  3221             lastInstr = loopBegin;
  3221             lastInstr = loopBegin;
  3222 
  3222 
  3223             // Create phi functions for all local variables and operand stack slots.
  3223             // Create phi functions for all local variables and operand stack slots.
  3224             frameState.insertLoopPhis(liveness, block.loopId, loopBegin, forceLoopPhis(), stampFromValueForForcedPhis());
  3224             frameState.insertLoopPhis(liveness, block.loopId, loopBegin, forceLoopPhis() || this.graphBuilderConfig.replaceLocalsWithConstants(), stampFromValueForForcedPhis());
  3225             loopBegin.setStateAfter(createFrameState(block.startBci, loopBegin));
  3225             loopBegin.setStateAfter(createFrameState(block.startBci, loopBegin));
  3226 
  3226 
  3227             /*
  3227             /*
  3228              * We have seen all forward branches. All subsequent backward branches will merge to the
  3228              * We have seen all forward branches. All subsequent backward branches will merge to the
  3229              * loop header. This ensures that the loop header has exactly one non-loop predecessor.
  3229              * loop header. This ensures that the loop header has exactly one non-loop predecessor.
  3543                      * We do not want to `checkLoopExit` here: otherwise the deopt will go to the
  3543                      * We do not want to `checkLoopExit` here: otherwise the deopt will go to the
  3544                      * deoptBlock's BCI, skipping the branch in the interpreter, and the profile
  3544                      * deoptBlock's BCI, skipping the branch in the interpreter, and the profile
  3545                      * will never see that the branch is taken. This can lead to deopt loops or OSR
  3545                      * will never see that the branch is taken. This can lead to deopt loops or OSR
  3546                      * failure.
  3546                      * failure.
  3547                      */
  3547                      */
       
  3548                     double calculatedProbability = negated ? BranchProbabilityNode.DEOPT_PROBABILITY : 1.0 - BranchProbabilityNode.DEOPT_PROBABILITY;
  3548                     FixedNode deoptSuccessor = BeginNode.begin(deopt);
  3549                     FixedNode deoptSuccessor = BeginNode.begin(deopt);
  3549                     ValueNode ifNode = genIfNode(condition, negated ? deoptSuccessor : noDeoptSuccessor, negated ? noDeoptSuccessor : deoptSuccessor, negated ? 1 - probability : probability);
  3550                     ValueNode ifNode = genIfNode(condition, negated ? deoptSuccessor : noDeoptSuccessor, negated ? noDeoptSuccessor : deoptSuccessor, calculatedProbability);
  3550                     postProcessIfNode(ifNode);
  3551                     postProcessIfNode(ifNode);
  3551                     append(ifNode);
  3552                     append(ifNode);
  3552                 }
  3553                 }
  3553                 return;
  3554                 return;
  3554             }
  3555             }
  3567                     }
  3568                     }
  3568                 }
  3569                 }
  3569             }
  3570             }
  3570 
  3571 
  3571             this.controlFlowSplit = true;
  3572             this.controlFlowSplit = true;
  3572             FixedNode trueSuccessor = createTarget(trueBlock, frameState, false, false);
  3573             FixedNode falseSuccessor = createTarget(falseBlock, frameState, false, false);
  3573             FixedNode falseSuccessor = createTarget(falseBlock, frameState, false, true);
  3574             FixedNode trueSuccessor = createTarget(trueBlock, frameState, false, true);
       
  3575 
       
  3576             if (this.graphBuilderConfig.replaceLocalsWithConstants() && condition instanceof CompareNode) {
       
  3577                 CompareNode compareNode = (CompareNode) condition;
       
  3578                 if (compareNode.condition() == CanonicalCondition.EQ) {
       
  3579                     ValueNode constantNode = null;
       
  3580                     ValueNode nonConstantNode = null;
       
  3581                     if (compareNode.getX() instanceof ConstantNode) {
       
  3582                         constantNode = compareNode.getX();
       
  3583                         nonConstantNode = compareNode.getY();
       
  3584                     } else if (compareNode.getY() instanceof ConstantNode) {
       
  3585                         constantNode = compareNode.getY();
       
  3586                         nonConstantNode = compareNode.getX();
       
  3587                     }
       
  3588 
       
  3589                     if (constantNode != null && nonConstantNode != null) {
       
  3590                         this.getEntryState(trueBlock).replaceValue(nonConstantNode, constantNode);
       
  3591                     }
       
  3592                 }
       
  3593             }
       
  3594 
  3574             ValueNode ifNode = genIfNode(condition, trueSuccessor, falseSuccessor, probability);
  3595             ValueNode ifNode = genIfNode(condition, trueSuccessor, falseSuccessor, probability);
  3575             postProcessIfNode(ifNode);
  3596             postProcessIfNode(ifNode);
  3576             append(ifNode);
  3597             append(ifNode);
  3577         }
  3598         }
  3578     }
  3599     }