Search in sources :

Example 11 with ReturnNode

use of org.graalvm.compiler.nodes.ReturnNode in project graal by oracle.

the class ObjectAccessTest method assertRead.

private static void assertRead(StructuredGraph graph, JavaKind kind, boolean indexConvert, LocationIdentity locationIdentity) {
    JavaReadNode read = (JavaReadNode) graph.start().next();
    Assert.assertEquals(kind.getStackKind(), read.stamp(NodeView.DEFAULT).getStackKind());
    OffsetAddressNode address = (OffsetAddressNode) read.getAddress();
    Assert.assertEquals(graph.getParameter(0), address.getBase());
    Assert.assertEquals(locationIdentity, read.getLocationIdentity());
    if (indexConvert) {
        SignExtendNode convert = (SignExtendNode) address.getOffset();
        Assert.assertEquals(convert.getInputBits(), 32);
        Assert.assertEquals(convert.getResultBits(), 64);
        Assert.assertEquals(graph.getParameter(1), convert.getValue());
    } else {
        Assert.assertEquals(graph.getParameter(1), address.getOffset());
    }
    ReturnNode ret = (ReturnNode) read.next();
    Assert.assertEquals(read, ret.result());
}
Also used : JavaReadNode(org.graalvm.compiler.nodes.extended.JavaReadNode) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) SignExtendNode(org.graalvm.compiler.nodes.calc.SignExtendNode)

Example 12 with ReturnNode

use of org.graalvm.compiler.nodes.ReturnNode in project graal by oracle.

the class ObjectAccessTest method assertWrite.

private static void assertWrite(StructuredGraph graph, boolean indexConvert, LocationIdentity locationIdentity) {
    JavaWriteNode write = (JavaWriteNode) graph.start().next();
    Assert.assertEquals(graph.getParameter(2), write.value());
    OffsetAddressNode address = (OffsetAddressNode) write.getAddress();
    Assert.assertEquals(graph.getParameter(0), address.getBase());
    Assert.assertEquals(BytecodeFrame.AFTER_BCI, write.stateAfter().bci);
    Assert.assertEquals(locationIdentity, write.getLocationIdentity());
    if (indexConvert) {
        SignExtendNode convert = (SignExtendNode) address.getOffset();
        Assert.assertEquals(convert.getInputBits(), 32);
        Assert.assertEquals(convert.getResultBits(), 64);
        Assert.assertEquals(graph.getParameter(1), convert.getValue());
    } else {
        Assert.assertEquals(graph.getParameter(1), address.getOffset());
    }
    ReturnNode ret = (ReturnNode) write.next();
    Assert.assertEquals(null, ret.result());
}
Also used : ReturnNode(org.graalvm.compiler.nodes.ReturnNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) SignExtendNode(org.graalvm.compiler.nodes.calc.SignExtendNode) JavaWriteNode(org.graalvm.compiler.nodes.extended.JavaWriteNode)

Example 13 with ReturnNode

use of org.graalvm.compiler.nodes.ReturnNode in project graal by oracle.

the class PointerTest method assertRead.

private void assertRead(StructuredGraph graph, JavaKind kind, boolean indexConvert, LocationIdentity locationIdentity) {
    WordCastNode cast = (WordCastNode) graph.start().next();
    JavaReadNode read = (JavaReadNode) cast.next();
    Assert.assertEquals(kind.getStackKind(), read.stamp(NodeView.DEFAULT).getStackKind());
    OffsetAddressNode address = (OffsetAddressNode) read.getAddress();
    Assert.assertEquals(cast, address.getBase());
    Assert.assertEquals(graph.getParameter(0), cast.getInput());
    Assert.assertEquals(target.wordJavaKind, cast.stamp(NodeView.DEFAULT).getStackKind());
    Assert.assertEquals(locationIdentity, read.getLocationIdentity());
    if (indexConvert) {
        SignExtendNode convert = (SignExtendNode) address.getOffset();
        Assert.assertEquals(convert.getInputBits(), 32);
        Assert.assertEquals(convert.getResultBits(), 64);
        Assert.assertEquals(graph.getParameter(1), convert.getValue());
    } else {
        Assert.assertEquals(graph.getParameter(1), address.getOffset());
    }
    ReturnNode ret = (ReturnNode) read.next();
    Assert.assertEquals(read, ret.result());
}
Also used : JavaReadNode(org.graalvm.compiler.nodes.extended.JavaReadNode) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) WordCastNode(org.graalvm.compiler.word.WordCastNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) SignExtendNode(org.graalvm.compiler.nodes.calc.SignExtendNode)

Example 14 with ReturnNode

use of org.graalvm.compiler.nodes.ReturnNode in project graal by oracle.

the class InstanceOfTest method testConstantReturn.

private void testConstantReturn(String name, Object value) {
    StructuredGraph result = buildGraph(name);
    ReturnNode ret = result.getNodes(ReturnNode.TYPE).first();
    assertDeepEquals(1, result.getNodes(ReturnNode.TYPE).count());
    assertDeepEquals(true, ret.result().isConstant());
    assertDeepEquals(value, ret.result().asJavaConstant().asBoxedPrimitive());
}
Also used : ReturnNode(org.graalvm.compiler.nodes.ReturnNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph)

Example 15 with ReturnNode

use of org.graalvm.compiler.nodes.ReturnNode in project graal by oracle.

the class StringEqualsConstantTest method testStringEquals.

private void testStringEquals(String s0, String s1) {
    ResolvedJavaMethod method = getResolvedJavaMethod("stringEquals");
    StructuredGraph graph = parseForCompile(method);
    graph.getParameter(0).replaceAndDelete(asConstant(graph, s0));
    graph.getParameter(1).replaceAndDelete(asConstant(graph, s1));
    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 {
        int expected = s0.equals(s1) ? 1 : 0;
        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)

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