use of org.graalvm.compiler.nodes.LogicNegationNode in project graal by oracle.
the class BytecodeParser method genIf.
protected void genIf(LogicNode conditionInput, BciBlock trueBlockInput, BciBlock falseBlockInput, double probabilityInput) {
BciBlock trueBlock = trueBlockInput;
BciBlock falseBlock = falseBlockInput;
LogicNode condition = conditionInput;
double probability = probabilityInput;
FrameState stateBefore = null;
ProfilingPlugin profilingPlugin = this.graphBuilderConfig.getPlugins().getProfilingPlugin();
if (profilingPlugin != null && profilingPlugin.shouldProfile(this, method)) {
stateBefore = frameState.create(bci(), getNonIntrinsicAncestor(), false, null, null);
}
// Remove a logic negation node.
if (condition instanceof LogicNegationNode) {
LogicNegationNode logicNegationNode = (LogicNegationNode) condition;
BciBlock tmpBlock = trueBlock;
trueBlock = falseBlock;
falseBlock = tmpBlock;
probability = 1 - probability;
condition = logicNegationNode.getValue();
}
if (condition instanceof LogicConstantNode) {
genConstantTargetIf(trueBlock, falseBlock, condition);
} else {
if (condition.graph() == null) {
condition = genUnique(condition);
}
if (isNeverExecutedCode(probability)) {
append(new FixedGuardNode(condition, UnreachedCode, InvalidateReprofile, true));
if (profilingPlugin != null && profilingPlugin.shouldProfile(this, method)) {
profilingPlugin.profileGoto(this, method, bci(), falseBlock.startBci, stateBefore);
}
appendGoto(falseBlock);
return;
} else if (isNeverExecutedCode(1 - probability)) {
append(new FixedGuardNode(condition, UnreachedCode, InvalidateReprofile, false));
if (profilingPlugin != null && profilingPlugin.shouldProfile(this, method)) {
profilingPlugin.profileGoto(this, method, bci(), trueBlock.startBci, stateBefore);
}
appendGoto(trueBlock);
return;
}
if (profilingPlugin != null && profilingPlugin.shouldProfile(this, method)) {
profilingPlugin.profileIf(this, method, bci(), condition, trueBlock.startBci, falseBlock.startBci, stateBefore);
}
int oldBci = stream.currentBCI();
int trueBlockInt = checkPositiveIntConstantPushed(trueBlock);
if (trueBlockInt != -1) {
int falseBlockInt = checkPositiveIntConstantPushed(falseBlock);
if (falseBlockInt != -1) {
if (tryGenConditionalForIf(trueBlock, falseBlock, condition, oldBci, trueBlockInt, falseBlockInt)) {
return;
}
}
}
this.controlFlowSplit = true;
FixedNode trueSuccessor = createTarget(trueBlock, frameState, false, false);
FixedNode falseSuccessor = createTarget(falseBlock, frameState, false, true);
ValueNode ifNode = genIfNode(condition, trueSuccessor, falseSuccessor, probability);
postProcessIfNode(ifNode);
append(ifNode);
}
}
Aggregations