use of org.graalvm.compiler.nodes.ParameterNode in project graal by oracle.
the class GraalCompilerTest method bindArguments.
protected void bindArguments(StructuredGraph graph, Object[] argsToBind) {
ResolvedJavaMethod m = graph.method();
Object receiver = isStatic(m.getModifiers()) ? null : this;
Object[] args = argsWithReceiver(receiver, argsToBind);
JavaType[] parameterTypes = m.toParameterTypes();
assert parameterTypes.length == args.length;
for (ParameterNode param : graph.getNodes(ParameterNode.TYPE)) {
JavaConstant c = getSnippetReflection().forBoxed(parameterTypes[param.index()].getJavaKind(), args[param.index()]);
ConstantNode replacement = ConstantNode.forConstant(c, getMetaAccess(), graph);
param.replaceAtUsages(replacement);
}
}
use of org.graalvm.compiler.nodes.ParameterNode in project graal by oracle.
the class GuardPrioritiesTest method unknownTest.
@Test
public void unknownTest() {
assumeTrue("GuardPriorities must be turned one", GraalOptions.GuardPriorities.getValue(getInitialOptions()));
StructuredGraph graph = prepareGraph("unknownCondition");
new SchedulePhase(SchedulePhase.SchedulingStrategy.EARLIEST_WITH_GUARD_ORDER).apply(graph);
for (GuardNode g1 : graph.getNodes(GuardNode.TYPE)) {
for (GuardNode g2 : graph.getNodes(GuardNode.TYPE)) {
if (g1.getSpeculation().isNull() ^ g2.getSpeculation().isNull()) {
GuardNode withSpeculation = g1.getSpeculation().isNull() ? g2 : g1;
GuardNode withoutSpeculation = g1.getSpeculation().isNull() ? g1 : g2;
if (withoutSpeculation.isNegated() && withoutSpeculation.getCondition() instanceof IsNullNode) {
IsNullNode isNullNode = (IsNullNode) withoutSpeculation.getCondition();
if (isNullNode.getValue() instanceof ParameterNode && ((ParameterNode) isNullNode.getValue()).index() == 1) {
// this is the null check before the speculative guard, it's the only
// one that should be above
assertOrderedAfterLastSchedule(graph, withoutSpeculation, withSpeculation);
continue;
}
}
assertOrderedAfterLastSchedule(graph, withSpeculation, withoutSpeculation);
}
}
}
}
use of org.graalvm.compiler.nodes.ParameterNode in project graal by oracle.
the class CompareCanonicalizerTest method testIntegerTest.
@Test
public void testIntegerTest() {
for (int i = 1; i <= 4; i++) {
StructuredGraph graph = getCanonicalizedGraph("integerTest" + i);
ReturnNode returnNode = (ReturnNode) graph.start().next();
ConditionalNode conditional = (ConditionalNode) returnNode.result();
IntegerTestNode test = (IntegerTestNode) conditional.condition();
ParameterNode param0 = graph.getParameter(0);
ParameterNode param1 = graph.getParameter(1);
assertTrue((test.getX() == param0 && test.getY() == param1) || (test.getX() == param1 && test.getY() == param0));
}
}
use of org.graalvm.compiler.nodes.ParameterNode in project graal by oracle.
the class ReinterpretStampDoubleToLongTest method run.
@Test
public void run() {
ParameterNode param = new ParameterNode(0, StampPair.createSingle(inputStamp));
ValueNode reinterpret = ReinterpretNode.create(JavaKind.Long, param, NodeView.DEFAULT);
IntegerStamp resultStamp = (IntegerStamp) reinterpret.stamp(NodeView.DEFAULT);
Assert.assertEquals(Long.SIZE, resultStamp.getBits());
for (long result : interestingLongs) {
double input = Double.longBitsToDouble(result);
if (inputStamp.contains(input) && !resultStamp.contains(result)) {
Assert.fail(String.format("value %f (0x%x) is in input stamp, but not in result stamp (%s)", input, result, resultStamp));
}
}
}
use of org.graalvm.compiler.nodes.ParameterNode in project graal by oracle.
the class ReinterpretStampFloatToIntTest method run.
@Test
public void run() {
ParameterNode param = new ParameterNode(0, StampPair.createSingle(inputStamp));
ValueNode reinterpret = ReinterpretNode.create(JavaKind.Int, param, NodeView.DEFAULT);
reinterpret.inferStamp();
IntegerStamp resultStamp = (IntegerStamp) reinterpret.stamp(NodeView.DEFAULT);
Assert.assertEquals(Integer.SIZE, resultStamp.getBits());
for (int result : interestingInts) {
float input = Float.intBitsToFloat(result);
if (inputStamp.contains(input) && !resultStamp.contains(result)) {
Assert.fail(String.format("value %f (0x%x) is in input stamp, but not in result stamp (%s)", input, result, resultStamp));
}
}
}
Aggregations