use of org.graalvm.compiler.nodes.ValuePhiNode in project graal by oracle.
the class TruffleGraphBuilderPlugins method registerCompilerAssertsPlugins.
public static void registerCompilerAssertsPlugins(InvocationPlugins plugins, MetaAccessProvider metaAccess, boolean canDelayIntrinsification) {
final ResolvedJavaType compilerAssertsType = getRuntime().resolveType(metaAccess, "com.oracle.truffle.api.CompilerAsserts");
Registration r = new Registration(plugins, new ResolvedJavaSymbol(compilerAssertsType));
r.register1("partialEvaluationConstant", Object.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
ValueNode curValue = value;
if (curValue instanceof BoxNode) {
BoxNode boxNode = (BoxNode) curValue;
curValue = boxNode.getValue();
}
if (curValue.isConstant()) {
return true;
} else if (canDelayIntrinsification) {
return false;
} else {
StringBuilder sb = new StringBuilder();
sb.append(curValue);
if (curValue instanceof ValuePhiNode) {
ValuePhiNode valuePhi = (ValuePhiNode) curValue;
sb.append(" (");
for (Node n : valuePhi.inputs()) {
sb.append(n);
sb.append("; ");
}
sb.append(")");
}
value.getDebug().dump(DebugContext.VERBOSE_LEVEL, value.graph(), "Graph before bailout at node %s", sb);
throw b.bailout("Partial evaluation did not reduce value to a constant, is a regular compiler node: " + sb);
}
}
});
r.register0("neverPartOfCompilation", new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
b.add(new NeverPartOfCompilationNode("CompilerAsserts.neverPartOfCompilation()"));
return true;
}
});
r.register1("neverPartOfCompilation", String.class, new InvocationPlugin() {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode message) {
if (message.isConstant()) {
String messageString = message.asConstant().toValueString();
b.add(new NeverPartOfCompilationNode(messageString));
return true;
} else {
throw b.bailout("message for never part of compilation is non-constant");
}
}
});
}
use of org.graalvm.compiler.nodes.ValuePhiNode in project graal by oracle.
the class FrameStateBuilder method createLoopPhi.
private ValueNode createLoopPhi(AbstractMergeNode block, ValueNode value, boolean stampFromValue) {
if (value == null || value == TWO_SLOT_MARKER) {
return value;
}
assert !block.isPhiAtMerge(value) : "phi function for this block already created";
ValuePhiNode phi = graph.addWithoutUnique(new ValuePhiNode(stampFromValue ? value.stamp(NodeView.DEFAULT) : value.stamp(NodeView.DEFAULT).unrestricted(), block));
phi.addInput(value);
return phi;
}
use of org.graalvm.compiler.nodes.ValuePhiNode in project graal by oracle.
the class LoadFieldNode method asPhi.
private static PhiNode asPhi(ConstantFieldProvider constantFields, ConstantReflectionProvider constantReflection, MetaAccessProvider metaAcccess, OptionValues options, ValueNode forObject, ResolvedJavaField field, Stamp stamp) {
if (!field.isStatic() && field.isFinal() && forObject instanceof ValuePhiNode && ((ValuePhiNode) forObject).values().filter(isNotA(ConstantNode.class)).isEmpty()) {
PhiNode phi = (PhiNode) forObject;
ConstantNode[] constantNodes = new ConstantNode[phi.valueCount()];
for (int i = 0; i < phi.valueCount(); i++) {
ConstantNode constant = ConstantFoldUtil.tryConstantFold(constantFields, constantReflection, metaAcccess, field, phi.valueAt(i).asJavaConstant(), options);
if (constant == null) {
return null;
}
constantNodes[i] = constant;
}
return new ValuePhiNode(stamp, phi.merge(), constantNodes);
}
return null;
}
use of org.graalvm.compiler.nodes.ValuePhiNode in project graal by oracle.
the class ConvertDeoptimizeToGuardPhase method trySplitFixedGuard.
private void trySplitFixedGuard(FixedGuardNode fixedGuard, PhaseContext context) {
LogicNode condition = fixedGuard.condition();
if (condition instanceof CompareNode) {
CompareNode compare = (CompareNode) condition;
ValueNode x = compare.getX();
ValuePhiNode xPhi = (x instanceof ValuePhiNode) ? (ValuePhiNode) x : null;
if (x instanceof ConstantNode || xPhi != null) {
ValueNode y = compare.getY();
ValuePhiNode yPhi = (y instanceof ValuePhiNode) ? (ValuePhiNode) y : null;
if (y instanceof ConstantNode || yPhi != null) {
processFixedGuardAndPhis(fixedGuard, context, compare, x, xPhi, y, yPhi);
}
}
}
}
use of org.graalvm.compiler.nodes.ValuePhiNode in project graal by oracle.
the class NodeLIRBuilder method createPhiIn.
private Value[] createPhiIn(AbstractMergeNode merge) {
List<Value> values = new ArrayList<>();
for (ValuePhiNode phi : merge.valuePhis()) {
assert getOperand(phi) == null;
Variable value = gen.newVariable(getExactPhiKind(phi));
values.add(value);
setResult(phi, value);
}
return values.toArray(new Value[values.size()]);
}
Aggregations