changeset 11708:9c9bc8c6a0df

Merge.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Thu, 19 Sep 2013 01:07:07 +0200
parents f6f5fceef2ce (current diff) 23d91654c363 (diff)
children 8fa3a9f1dda4
files
diffstat 15 files changed, 128 insertions(+), 118 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfig.java	Thu Sep 19 01:06:55 2013 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalDebugConfig.java	Thu Sep 19 01:07:07 2013 +0200
@@ -48,7 +48,6 @@
     public static final OptionValue<String> MethodFilter = new OptionValue<>(null);
     @Option(help = "How to print metric and timing values:%n" +
                    "Name - aggregate by unqualified name%n" +
-                   "CSV - aggregate by unqualified name and write to .csv files (e.g., for importing to R with read.csv)%n" +
                    "Partial - aggregate by partially qualified name (e.g., A.B.C.D.Counter and X.Y.Z.D.Counter will be merged to D.Counter)%n" +
                    "Complete - aggregate by qualified name%n" +
                    "Thread - aggregate by qualified name and thread")
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Thu Sep 19 01:06:55 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Thu Sep 19 01:07:07 2013 +0200
@@ -645,7 +645,7 @@
                 checkcastDynamicSnippets.lower(checkcastDynamicNode);
             }
         } else if (n instanceof UnsafeLoadNode) {
-            if (graph.getGuardsPhase().ordinal() > StructuredGraph.GuardsStage.FLOATING_GUARDS.ordinal()) {
+            if (graph.getGuardsStage().ordinal() > StructuredGraph.GuardsStage.FLOATING_GUARDS.ordinal()) {
                 UnsafeLoadNode load = (UnsafeLoadNode) n;
                 assert load.kind() != Kind.Illegal;
                 boolean compressible = (!load.object().isNullConstant() && load.accessKind() == Kind.Object);
@@ -685,7 +685,7 @@
             WriteNode hub = createWriteHub(graph, wordKind, storeHub.getObject(), storeHub.getValue());
             graph.replaceFixed(storeHub, hub);
         } else if (n instanceof CommitAllocationNode) {
-            if (graph.getGuardsPhase() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
+            if (graph.getGuardsStage() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
                 CommitAllocationNode commit = (CommitAllocationNode) n;
 
                 ValueNode[] allocations = new ValueNode[commit.getVirtualObjects().size()];
@@ -761,7 +761,7 @@
                 graph.removeFixed(commit);
             }
         } else if (n instanceof OSRStartNode) {
-            if (graph.getGuardsPhase() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
+            if (graph.getGuardsStage() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
                 OSRStartNode osrStart = (OSRStartNode) n;
                 StartNode newStart = graph.add(new StartNode());
                 LocalNode buffer = graph.unique(new LocalNode(0, StampFactory.forKind(wordKind())));
@@ -790,31 +790,31 @@
         } else if (n instanceof CheckCastDynamicNode) {
             checkcastDynamicSnippets.lower((CheckCastDynamicNode) n);
         } else if (n instanceof InstanceOfNode) {
-            if (graph.getGuardsPhase() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
+            if (graph.getGuardsStage() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
                 instanceofSnippets.lower((InstanceOfNode) n, tool);
             }
         } else if (n instanceof InstanceOfDynamicNode) {
-            if (graph.getGuardsPhase() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
+            if (graph.getGuardsStage() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
                 instanceofSnippets.lower((InstanceOfDynamicNode) n, tool);
             }
         } else if (n instanceof NewInstanceNode) {
-            if (graph.getGuardsPhase() == StructuredGraph.GuardsStage.AFTER_FSA) {
+            if (graph.getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) {
                 newObjectSnippets.lower((NewInstanceNode) n);
             }
         } else if (n instanceof NewArrayNode) {
-            if (graph.getGuardsPhase() == StructuredGraph.GuardsStage.AFTER_FSA) {
+            if (graph.getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) {
                 newObjectSnippets.lower((NewArrayNode) n);
             }
         } else if (n instanceof DynamicNewArrayNode) {
-            if (graph.getGuardsPhase() == StructuredGraph.GuardsStage.AFTER_FSA) {
+            if (graph.getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) {
                 newObjectSnippets.lower((DynamicNewArrayNode) n);
             }
         } else if (n instanceof MonitorEnterNode) {
-            if (graph.getGuardsPhase() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
+            if (graph.getGuardsStage() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
                 monitorSnippets.lower((MonitorEnterNode) n, tool);
             }
         } else if (n instanceof MonitorExitNode) {
-            if (graph.getGuardsPhase() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
+            if (graph.getGuardsStage() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
                 monitorSnippets.lower((MonitorExitNode) n, tool);
             }
         } else if (n instanceof G1PreWriteBarrier) {
@@ -832,7 +832,7 @@
         } else if (n instanceof G1ArrayRangePostWriteBarrier) {
             writeBarrierSnippets.lower((G1ArrayRangePostWriteBarrier) n, tool);
         } else if (n instanceof NewMultiArrayNode) {
-            if (graph.getGuardsPhase() == StructuredGraph.GuardsStage.AFTER_FSA) {
+            if (graph.getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) {
                 newObjectSnippets.lower((NewMultiArrayNode) n);
             }
         } else if (n instanceof LoadExceptionObjectNode) {
@@ -851,7 +851,7 @@
     }
 
     private static boolean addReadBarrier(UnsafeLoadNode load) {
-        if (useG1GC() && load.graph().getGuardsPhase() == StructuredGraph.GuardsStage.FIXED_DEOPTS && load.object().kind() == Kind.Object && load.accessKind() == Kind.Object &&
+        if (useG1GC() && load.graph().getGuardsStage() == StructuredGraph.GuardsStage.FIXED_DEOPTS && load.object().kind() == Kind.Object && load.accessKind() == Kind.Object &&
                         !ObjectStamp.isObjectAlwaysNull(load.object())) {
             ResolvedJavaType type = ObjectStamp.typeOrNull(load.object());
             if (type != null && !type.isArray()) {
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/UnsafeArrayCopyNode.java	Thu Sep 19 01:06:55 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/UnsafeArrayCopyNode.java	Thu Sep 19 01:07:07 2013 +0200
@@ -93,7 +93,7 @@
 
     @Override
     public void lower(LoweringTool tool) {
-        if (graph().getGuardsPhase() == StructuredGraph.GuardsStage.AFTER_FSA) {
+        if (graph().getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA) {
             UnsafeArrayCopySnippets.Templates templates = tool.getReplacements().getSnippetTemplateCache(UnsafeArrayCopySnippets.Templates.class);
             templates.lower(this);
         }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.java	Thu Sep 19 01:06:55 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/FixedGuardNode.java	Thu Sep 19 01:07:07 2013 +0200
@@ -107,7 +107,7 @@
 
     @Override
     public void lower(LoweringTool tool) {
-        if (graph().getGuardsPhase() == StructuredGraph.GuardsStage.FLOATING_GUARDS) {
+        if (graph().getGuardsStage() == StructuredGraph.GuardsStage.FLOATING_GUARDS) {
             GuardingNode guard = tool.createGuard(condition(), getReason(), getAction(), isNegated());
             ValueAnchorNode newAnchor = graph().add(new ValueAnchorNode(guard.asNode()));
             this.replaceAtUsages(guard.asNode());
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardingPiNode.java	Thu Sep 19 01:06:55 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/GuardingPiNode.java	Thu Sep 19 01:07:07 2013 +0200
@@ -77,7 +77,7 @@
 
     @Override
     public void lower(LoweringTool tool) {
-        if (graph().getGuardsPhase() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
+        if (graph().getGuardsStage() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
             throw new GraalInternalError("Cannot create guards in after-guard lowering");
         }
         GuardingNode guard = tool.createGuard(condition, reason, action, negated);
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java	Thu Sep 19 01:06:55 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/StructuredGraph.java	Thu Sep 19 01:07:07 2013 +0200
@@ -77,7 +77,7 @@
     private final ResolvedJavaMethod method;
     private final long graphId;
     private final int entryBCI;
-    private GuardsStage guardsPhase = GuardsStage.FLOATING_GUARDS;
+    private GuardsStage guardsStage = GuardsStage.FLOATING_GUARDS;
 
     /**
      * Creates a new Graph containing a single {@link AbstractBeginNode} as the {@link #start()
@@ -417,12 +417,12 @@
         }
     }
 
-    public GuardsStage getGuardsPhase() {
-        return guardsPhase;
+    public GuardsStage getGuardsStage() {
+        return guardsStage;
     }
 
-    public void setGuardsPhase(GuardsStage guardsPhase) {
-        assert guardsPhase.ordinal() >= this.guardsPhase.ordinal();
-        this.guardsPhase = guardsPhase;
+    public void setGuardsStage(GuardsStage guardsStage) {
+        assert guardsStage.ordinal() >= this.guardsStage.ordinal();
+        this.guardsStage = guardsStage;
     }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/WriteBarrier.java	Thu Sep 19 01:06:55 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/WriteBarrier.java	Thu Sep 19 01:07:07 2013 +0200
@@ -54,7 +54,7 @@
 
     @Override
     public void lower(LoweringTool generator) {
-        assert graph().getGuardsPhase() == StructuredGraph.GuardsStage.AFTER_FSA;
+        assert graph().getGuardsStage() == StructuredGraph.GuardsStage.AFTER_FSA;
         generator.getRuntime().lower(this, generator);
     }
 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java	Thu Sep 19 01:06:55 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/LoadHubNode.java	Thu Sep 19 01:07:07 2013 +0200
@@ -59,7 +59,7 @@
 
     @Override
     public void lower(LoweringTool tool) {
-        if (graph().getGuardsPhase() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
+        if (graph().getGuardsStage() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
             tool.getRuntime().lower(this, tool);
         }
     }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FrameStateAssignmentPhase.java	Thu Sep 19 01:06:55 2013 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FrameStateAssignmentPhase.java	Thu Sep 19 01:07:07 2013 +0200
@@ -89,7 +89,7 @@
         assert checkFixedDeopts(graph);
         ReentrantNodeIterator.apply(new FrameStateAssignmentClosure(), graph.start(), null, null);
 
-        graph.setGuardsPhase(GuardsStage.AFTER_FSA);
+        graph.setGuardsStage(GuardsStage.AFTER_FSA);
     }
 
     private static boolean checkFixedDeopts(StructuredGraph graph) {
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java	Thu Sep 19 01:06:55 2013 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java	Thu Sep 19 01:07:07 2013 +0200
@@ -189,7 +189,7 @@
             processBlock(block, schedule, context.getTarget().implicitNullCheckLimit);
         }
 
-        graph.setGuardsPhase(GuardsStage.FIXED_DEOPTS);
+        graph.setGuardsStage(GuardsStage.FIXED_DEOPTS);
     }
 
     private static void processBlock(Block block, SchedulePhase schedule, int implicitNullCheckLimit) {
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java	Thu Sep 19 01:06:55 2013 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LoweringPhase.java	Thu Sep 19 01:07:07 2013 +0200
@@ -95,7 +95,7 @@
 
         @Override
         public GuardingNode createGuard(LogicNode condition, DeoptimizationReason deoptReason, DeoptimizationAction action, boolean negated) {
-            if (condition.graph().getGuardsPhase().ordinal() > StructuredGraph.GuardsStage.FLOATING_GUARDS.ordinal()) {
+            if (condition.graph().getGuardsStage().ordinal() > StructuredGraph.GuardsStage.FLOATING_GUARDS.ordinal()) {
                 throw new GraalInternalError("Cannot create guards after guard lowering");
             }
             if (OptEliminateGuards.getValue()) {
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerExactArithmeticSplitNode.java	Thu Sep 19 01:06:55 2013 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/arithmetic/IntegerExactArithmeticSplitNode.java	Thu Sep 19 01:07:07 2013 +0200
@@ -81,7 +81,7 @@
     protected abstract Value generateArithmetic(LIRGeneratorTool generator);
 
     static void lower(LoweringTool tool, IntegerExactArithmeticNode node) {
-        if (node.asNode().graph().getGuardsPhase() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
+        if (node.asNode().graph().getGuardsStage() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
             FloatingNode floatingNode = (FloatingNode) node;
             FixedWithNextNode previous = tool.lastFixedNode();
             FixedNode next = previous.next();
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomTypeCheckNode.java	Thu Sep 19 01:06:55 2013 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/CustomTypeCheckNode.java	Thu Sep 19 01:07:07 2013 +0200
@@ -51,7 +51,7 @@
     }
 
     public void lower(LoweringTool tool) {
-        if (graph().getGuardsPhase() == StructuredGraph.GuardsStage.FLOATING_GUARDS) {
+        if (graph().getGuardsStage() == StructuredGraph.GuardsStage.FLOATING_GUARDS) {
             this.replaceAtUsages(graph().unique(new IntegerEqualsNode(condition, ConstantNode.forInt(1, graph()))));
             this.safeDelete();
         }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/TypeCastNode.java	Thu Sep 19 01:06:55 2013 +0200
+++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/nodes/typesystem/TypeCastNode.java	Thu Sep 19 01:07:07 2013 +0200
@@ -60,7 +60,7 @@
     }
 
     public void lower(LoweringTool tool) {
-        if (graph().getGuardsPhase() == StructuredGraph.GuardsStage.FLOATING_GUARDS) {
+        if (graph().getGuardsStage() == StructuredGraph.GuardsStage.FLOATING_GUARDS) {
             ValueAnchorNode valueAnchorNode = graph().add(new ValueAnchorNode());
             UnsafeCastNode unsafeCast = graph().unique(new UnsafeCastNode(object, this.stamp(), (GuardingNode) valueAnchorNode));
             this.replaceAtUsages(unsafeCast);
--- a/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java	Thu Sep 19 01:06:55 2013 +0200
+++ b/graal/com.oracle.graal.word/src/com/oracle/graal/word/phases/WordTypeRewriterPhase.java	Thu Sep 19 01:07:07 2013 +0200
@@ -36,7 +36,6 @@
 import com.oracle.graal.nodes.type.*;
 import com.oracle.graal.nodes.util.*;
 import com.oracle.graal.phases.*;
-import com.oracle.graal.phases.util.*;
 import com.oracle.graal.word.*;
 import com.oracle.graal.word.Word.Opcode;
 import com.oracle.graal.word.Word.Operation;
@@ -87,7 +86,13 @@
         boolean stampChanged;
         do {
             stampChanged = false;
-            for (Node n : GraphOrder.forwardGraph(graph)) {
+            /*
+             * We could use GraphOrder.forwardGraph() to process the nodes in a defined order and
+             * propagate long def-use chains in fewer iterations. However, measurements showed that
+             * we have few iterations anyway, and the overhead of computing the order is much higher
+             * than the benefit.
+             */
+            for (Node n : graph.getNodes()) {
                 if (n instanceof ValueNode) {
                     ValueNode node = (ValueNode) n;
                     if (node.kind() == Kind.Object) {
@@ -197,108 +202,114 @@
      */
     protected void rewriteInvoke(StructuredGraph graph, MethodCallTargetNode callTargetNode) {
         ResolvedJavaMethod targetMethod = callTargetNode.targetMethod();
-        if (!callTargetNode.isStatic() && (callTargetNode.receiver().kind() == wordKind || isWord(callTargetNode.receiver()))) {
+        if (!wordBaseType.isAssignableFrom(targetMethod.getDeclaringClass())) {
+            /* Not a method defined on WordBase or a subclass / subinterface, so nothing to rewrite. */
+            return;
+        }
+
+        if (!callTargetNode.isStatic()) {
+            assert callTargetNode.receiver().kind() == wordKind : "changeToWord() missed the receiver";
             targetMethod = wordImplType.resolveMethod(targetMethod);
         }
         Operation operation = targetMethod.getAnnotation(Word.Operation.class);
-        if (operation != null) {
-            NodeInputList<ValueNode> arguments = callTargetNode.arguments();
-            Invoke invoke = callTargetNode.invoke();
+        assert operation != null : targetMethod;
 
-            switch (operation.opcode()) {
-                case NODE_CLASS:
-                    assert arguments.size() == 2;
-                    ValueNode left = arguments.get(0);
-                    ValueNode right = operation.rightOperandIsInt() ? toUnsigned(graph, arguments.get(1), Kind.Int) : fromSigned(graph, arguments.get(1));
+        NodeInputList<ValueNode> arguments = callTargetNode.arguments();
+        Invoke invoke = callTargetNode.invoke();
 
-                    ValueNode replacement = graph.addOrUnique(createBinaryNodeInstance(operation.node(), wordKind, left, right));
-                    if (replacement instanceof FixedWithNextNode) {
-                        graph.addBeforeFixed(invoke.asNode(), (FixedWithNextNode) replacement);
-                    }
-                    replace(invoke, replacement);
-                    break;
+        switch (operation.opcode()) {
+            case NODE_CLASS:
+                assert arguments.size() == 2;
+                ValueNode left = arguments.get(0);
+                ValueNode right = operation.rightOperandIsInt() ? toUnsigned(graph, arguments.get(1), Kind.Int) : fromSigned(graph, arguments.get(1));
 
-                case COMPARISON:
-                    assert arguments.size() == 2;
-                    replace(invoke, comparisonOp(graph, operation.condition(), arguments.get(0), fromSigned(graph, arguments.get(1))));
-                    break;
+                ValueNode replacement = graph.addOrUnique(createBinaryNodeInstance(operation.node(), wordKind, left, right));
+                if (replacement instanceof FixedWithNextNode) {
+                    graph.addBeforeFixed(invoke.asNode(), (FixedWithNextNode) replacement);
+                }
+                replace(invoke, replacement);
+                break;
 
-                case NOT:
-                    assert arguments.size() == 1;
-                    replace(invoke, graph.unique(new XorNode(wordKind, arguments.get(0), ConstantNode.forIntegerKind(wordKind, -1, graph))));
-                    break;
+            case COMPARISON:
+                assert arguments.size() == 2;
+                replace(invoke, comparisonOp(graph, operation.condition(), arguments.get(0), fromSigned(graph, arguments.get(1))));
+                break;
 
-                case READ: {
-                    assert arguments.size() == 2 || arguments.size() == 3;
-                    Kind readKind = asKind(callTargetNode.returnType());
-                    LocationNode location;
-                    if (arguments.size() == 2) {
-                        location = makeLocation(graph, arguments.get(1), readKind, ANY_LOCATION);
-                    } else {
-                        location = makeLocation(graph, arguments.get(1), readKind, arguments.get(2));
-                    }
-                    replace(invoke, readOp(graph, arguments.get(0), invoke, location, BarrierType.NONE, false));
-                    break;
-                }
-                case READ_HEAP: {
-                    assert arguments.size() == 4;
-                    Kind readKind = asKind(callTargetNode.returnType());
-                    LocationNode location = makeLocation(graph, arguments.get(1), readKind, ANY_LOCATION);
-                    BarrierType barrierType = (BarrierType) arguments.get(2).asConstant().asObject();
-                    replace(invoke, readOp(graph, arguments.get(0), invoke, location, barrierType, arguments.get(3).asConstant().asInt() == 0 ? false : true));
-                    break;
+            case NOT:
+                assert arguments.size() == 1;
+                replace(invoke, graph.unique(new XorNode(wordKind, arguments.get(0), ConstantNode.forIntegerKind(wordKind, -1, graph))));
+                break;
+
+            case READ: {
+                assert arguments.size() == 2 || arguments.size() == 3;
+                Kind readKind = asKind(callTargetNode.returnType());
+                LocationNode location;
+                if (arguments.size() == 2) {
+                    location = makeLocation(graph, arguments.get(1), readKind, ANY_LOCATION);
+                } else {
+                    location = makeLocation(graph, arguments.get(1), readKind, arguments.get(2));
                 }
-                case WRITE:
-                case INITIALIZE: {
-                    assert arguments.size() == 3 || arguments.size() == 4;
-                    Kind writeKind = asKind(targetMethod.getSignature().getParameterType(1, targetMethod.getDeclaringClass()));
-                    LocationNode location;
-                    if (arguments.size() == 3) {
-                        location = makeLocation(graph, arguments.get(1), writeKind, LocationIdentity.ANY_LOCATION);
-                    } else {
-                        location = makeLocation(graph, arguments.get(1), writeKind, arguments.get(3));
-                    }
-                    replace(invoke, writeOp(graph, arguments.get(0), arguments.get(2), invoke, location, operation.opcode()));
-                    break;
+                replace(invoke, readOp(graph, arguments.get(0), invoke, location, BarrierType.NONE, false));
+                break;
+            }
+            case READ_HEAP: {
+                assert arguments.size() == 4;
+                Kind readKind = asKind(callTargetNode.returnType());
+                LocationNode location = makeLocation(graph, arguments.get(1), readKind, ANY_LOCATION);
+                BarrierType barrierType = (BarrierType) arguments.get(2).asConstant().asObject();
+                replace(invoke, readOp(graph, arguments.get(0), invoke, location, barrierType, arguments.get(3).asConstant().asInt() == 0 ? false : true));
+                break;
+            }
+            case WRITE:
+            case INITIALIZE: {
+                assert arguments.size() == 3 || arguments.size() == 4;
+                Kind writeKind = asKind(targetMethod.getSignature().getParameterType(1, targetMethod.getDeclaringClass()));
+                LocationNode location;
+                if (arguments.size() == 3) {
+                    location = makeLocation(graph, arguments.get(1), writeKind, LocationIdentity.ANY_LOCATION);
+                } else {
+                    location = makeLocation(graph, arguments.get(1), writeKind, arguments.get(3));
                 }
-                case ZERO:
-                    assert arguments.size() == 0;
-                    replace(invoke, ConstantNode.forIntegerKind(wordKind, 0L, graph));
-                    break;
-
-                case FROM_UNSIGNED:
-                    assert arguments.size() == 1;
-                    replace(invoke, fromUnsigned(graph, arguments.get(0)));
-                    break;
+                replace(invoke, writeOp(graph, arguments.get(0), arguments.get(2), invoke, location, operation.opcode()));
+                break;
+            }
+            case ZERO:
+                assert arguments.size() == 0;
+                replace(invoke, ConstantNode.forIntegerKind(wordKind, 0L, graph));
+                break;
 
-                case FROM_SIGNED:
-                    assert arguments.size() == 1;
-                    replace(invoke, fromSigned(graph, arguments.get(0)));
-                    break;
+            case FROM_UNSIGNED:
+                assert arguments.size() == 1;
+                replace(invoke, fromUnsigned(graph, arguments.get(0)));
+                break;
 
-                case TO_RAW_VALUE:
-                    assert arguments.size() == 1;
-                    replace(invoke, toUnsigned(graph, arguments.get(0), Kind.Long));
-                    break;
+            case FROM_SIGNED:
+                assert arguments.size() == 1;
+                replace(invoke, fromSigned(graph, arguments.get(0)));
+                break;
+
+            case TO_RAW_VALUE:
+                assert arguments.size() == 1;
+                replace(invoke, toUnsigned(graph, arguments.get(0), Kind.Long));
+                break;
 
-                case FROM_OBJECT:
-                    assert arguments.size() == 1;
-                    replace(invoke, graph.unique(new UnsafeCastNode(arguments.get(0), StampFactory.forKind(wordKind))));
-                    break;
+            case FROM_OBJECT:
+                assert arguments.size() == 1;
+                replace(invoke, graph.unique(new UnsafeCastNode(arguments.get(0), StampFactory.forKind(wordKind))));
+                break;
 
-                case FROM_ARRAY:
-                    assert arguments.size() == 2;
-                    replace(invoke, graph.unique(new ComputeAddressNode(arguments.get(0), arguments.get(1), StampFactory.forKind(wordKind))));
-                    break;
+            case FROM_ARRAY:
+                assert arguments.size() == 2;
+                replace(invoke, graph.unique(new ComputeAddressNode(arguments.get(0), arguments.get(1), StampFactory.forKind(wordKind))));
+                break;
 
-                case TO_OBJECT:
-                    assert arguments.size() == 1;
-                    replace(invoke, graph.unique(new UnsafeCastNode(arguments.get(0), invoke.asNode().stamp())));
-                    break;
+            case TO_OBJECT:
+                assert arguments.size() == 1;
+                replace(invoke, graph.unique(new UnsafeCastNode(arguments.get(0), invoke.asNode().stamp())));
+                break;
 
-                default:
-                    throw new GraalInternalError("Unknown opcode: %s", operation.opcode());
-            }
+            default:
+                throw new GraalInternalError("Unknown opcode: %s", operation.opcode());
         }
     }