Search in sources :

Example 16 with ReturnNode

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());
    }
}
Also used : ReturnNode(org.graalvm.compiler.nodes.ReturnNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) JavaConstant(jdk.vm.ci.meta.JavaConstant) FixedNode(org.graalvm.compiler.nodes.FixedNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) Test(org.junit.Test) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest)

Example 17 with ReturnNode

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());
    }
}
Also used : ReturnNode(org.graalvm.compiler.nodes.ReturnNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) JavaConstant(jdk.vm.ci.meta.JavaConstant) FixedNode(org.graalvm.compiler.nodes.FixedNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) Test(org.junit.Test) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest)

Example 18 with ReturnNode

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();
}
Also used : ReturnNode(org.graalvm.compiler.nodes.ReturnNode)

Example 19 with ReturnNode

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));
    }
}
Also used : ReturnNode(org.graalvm.compiler.nodes.ReturnNode) ConditionalNode(org.graalvm.compiler.nodes.calc.ConditionalNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) IntegerTestNode(org.graalvm.compiler.nodes.calc.IntegerTestNode) Test(org.junit.Test)

Example 20 with ReturnNode

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);
    }
}
Also used : DebugDumpScope(org.graalvm.compiler.debug.DebugDumpScope) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) Node(org.graalvm.compiler.graph.Node) LoweringPhase(org.graalvm.compiler.phases.common.LoweringPhase) DebugContext(org.graalvm.compiler.debug.DebugContext) FloatingReadPhase(org.graalvm.compiler.phases.common.FloatingReadPhase) PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) MonitorExit(org.graalvm.compiler.nodes.extended.MonitorExit) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) CanonicalizerPhase(org.graalvm.compiler.phases.common.CanonicalizerPhase)

Aggregations

ReturnNode (org.graalvm.compiler.nodes.ReturnNode)40 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)22 ValueNode (org.graalvm.compiler.nodes.ValueNode)12 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)11 DebugContext (org.graalvm.compiler.debug.DebugContext)10 Node (org.graalvm.compiler.graph.Node)10 FixedNode (org.graalvm.compiler.nodes.FixedNode)10 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)8 Test (org.junit.Test)8 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)7 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)7 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)7 FrameState (org.graalvm.compiler.nodes.FrameState)7 MergeNode (org.graalvm.compiler.nodes.MergeNode)7 StartNode (org.graalvm.compiler.nodes.StartNode)7 JavaConstant (jdk.vm.ci.meta.JavaConstant)6 PhiNode (org.graalvm.compiler.nodes.PhiNode)6 ControlSinkNode (org.graalvm.compiler.nodes.ControlSinkNode)5 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)4 BeginNode (org.graalvm.compiler.nodes.BeginNode)4