use of org.graalvm.compiler.nodes.ReturnNode in project graal by oracle.
the class StringHashConstantTest method test2.
@Test
public void test2() {
ResolvedJavaMethod method = getResolvedJavaMethod("constantHashCode");
StructuredGraph graph = parseForCompile(method);
FixedNode firstFixed = graph.start().next();
Assert.assertThat(firstFixed, instanceOf(ReturnNode.class));
ReturnNode ret = (ReturnNode) firstFixed;
JavaConstant result = ret.result().asJavaConstant();
if (result == null) {
Assert.fail("result not constant: " + ret.result());
} else {
int expected = A_CONSTANT_STRING.hashCode();
Assert.assertEquals("result", expected, result.asInt());
}
}
use of org.graalvm.compiler.nodes.ReturnNode in project graal by oracle.
the class StringHashConstantTest method test1.
@Test
public void test1() {
ResolvedJavaMethod method = getResolvedJavaMethod("parameterizedHashCode");
StructuredGraph graph = parseForCompile(method);
String s = "some string";
int expected = s.hashCode();
graph.getParameter(0).replaceAndDelete(asConstant(graph, s));
compile(method, graph);
FixedNode firstFixed = graph.start().next();
Assert.assertThat(firstFixed, instanceOf(ReturnNode.class));
ReturnNode ret = (ReturnNode) firstFixed;
JavaConstant result = ret.result().asJavaConstant();
if (result == null) {
Assert.fail("result not constant: " + ret.result());
} else {
Assert.assertEquals("result", expected, result.asInt());
}
}
use of org.graalvm.compiler.nodes.ReturnNode in project graal by oracle.
the class CompareCanonicalizerTest method getResult.
private static ValueNode getResult(StructuredGraph graph) {
assertTrue(graph.start().next() instanceof ReturnNode);
ReturnNode ret = (ReturnNode) graph.start().next();
return ret.result();
}
use of org.graalvm.compiler.nodes.ReturnNode 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.ReturnNode in project graal by oracle.
the class FloatingReadTest method test.
@SuppressWarnings("try")
private void test(final String snippet) {
DebugContext debug = getDebugContext();
try (DebugContext.Scope s = debug.scope("FloatingReadTest", new DebugDumpScope(snippet))) {
StructuredGraph graph = parseEager(snippet, AllowAssumptions.YES);
PhaseContext context = new PhaseContext(getProviders());
new LoweringPhase(new CanonicalizerPhase(), LoweringTool.StandardLoweringStage.HIGH_TIER).apply(graph, context);
new FloatingReadPhase().apply(graph);
ReturnNode returnNode = null;
MonitorExit monitorexit = null;
for (Node n : graph.getNodes()) {
if (n instanceof ReturnNode) {
assert returnNode == null;
returnNode = (ReturnNode) n;
} else if (n instanceof MonitorExit) {
monitorexit = (MonitorExit) n;
}
}
debug.dump(DebugContext.BASIC_LEVEL, graph, "After lowering");
Assert.assertNotNull(returnNode);
Assert.assertNotNull(monitorexit);
Assert.assertTrue(returnNode.result() instanceof FloatingReadNode);
FloatingReadNode read = (FloatingReadNode) returnNode.result();
assertOrderedAfterSchedule(graph, read, (Node) monitorexit);
} catch (Throwable e) {
throw debug.handle(e);
}
}
Aggregations