Search in sources :

Example 11 with StoreFieldNode

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

the class EnsureVirtualizedNode method ensureVirtualFailure.

public static void ensureVirtualFailure(Node location, Stamp stamp) {
    String additionalReason = "";
    if (location instanceof FixedWithNextNode && !(location instanceof EnsureVirtualizedNode)) {
        FixedWithNextNode fixedWithNextNode = (FixedWithNextNode) location;
        FixedNode next = fixedWithNextNode.next();
        if (next instanceof StoreFieldNode) {
            additionalReason = " (must not store virtual object into a field)";
        } else if (next instanceof Invoke) {
            additionalReason = " (must not pass virtual object into an invoke that cannot be inlined)";
        } else {
            additionalReason = " (must not let virtual object escape at node " + next + ")";
        }
    }
    Throwable exception = new VerificationError("Object of type %s should not be materialized%s:", StampTool.typeOrNull(stamp).getName(), additionalReason);
    Node pos;
    if (location instanceof FixedWithNextNode) {
        pos = ((FixedWithNextNode) location).next();
    } else if (location instanceof AbstractEndNode) {
        pos = ((AbstractEndNode) location).merge();
    } else {
        pos = location;
    }
    throw GraphUtil.approxSourceException(pos, exception);
}
Also used : FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) StoreFieldNode(org.graalvm.compiler.nodes.java.StoreFieldNode) VerificationError(org.graalvm.compiler.graph.VerificationError) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) StoreFieldNode(org.graalvm.compiler.nodes.java.StoreFieldNode) Node(org.graalvm.compiler.graph.Node) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) Invoke(org.graalvm.compiler.nodes.Invoke)

Example 12 with StoreFieldNode

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

the class EarlyReadEliminationTest method testPhi.

@Test
public void testPhi() {
    StructuredGraph graph = processMethod("testPhiSnippet", false);
    assertTrue(graph.getNodes().filter(LoadFieldNode.class).isEmpty());
    List<ReturnNode> returnNodes = graph.getNodes(ReturnNode.TYPE).snapshot();
    assertDeepEquals(2, returnNodes.size());
    assertTrue(returnNodes.get(0).predecessor() instanceof StoreFieldNode);
    assertTrue(returnNodes.get(1).predecessor() instanceof StoreFieldNode);
    assertTrue(returnNodes.get(0).result().isConstant());
    assertTrue(returnNodes.get(1).result().isConstant());
}
Also used : ReturnNode(org.graalvm.compiler.nodes.ReturnNode) StoreFieldNode(org.graalvm.compiler.nodes.java.StoreFieldNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) Test(org.junit.Test) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest)

Aggregations

StoreFieldNode (org.graalvm.compiler.nodes.java.StoreFieldNode)12 LoadFieldNode (org.graalvm.compiler.nodes.java.LoadFieldNode)8 Node (org.graalvm.compiler.graph.Node)6 ValueNode (org.graalvm.compiler.nodes.ValueNode)6 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)5 ReturnNode (org.graalvm.compiler.nodes.ReturnNode)5 MethodCallTargetNode (org.graalvm.compiler.nodes.java.MethodCallTargetNode)5 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)4 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)3 FixedNode (org.graalvm.compiler.nodes.FixedNode)3 Invoke (org.graalvm.compiler.nodes.Invoke)3 RawLoadNode (org.graalvm.compiler.nodes.extended.RawLoadNode)3 RawStoreNode (org.graalvm.compiler.nodes.extended.RawStoreNode)3 NewInstanceNode (org.graalvm.compiler.nodes.java.NewInstanceNode)3 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)2 DebugContext (org.graalvm.compiler.debug.DebugContext)2 AbstractEndNode (org.graalvm.compiler.nodes.AbstractEndNode)2 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)2 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)2 FieldLocationIdentity (org.graalvm.compiler.nodes.FieldLocationIdentity)2