changeset 11781:492766ec345a

Rewrite write barrier addition phase
author Christos Kotselidis <christos.kotselidis@oracle.com>
date Wed, 25 Sep 2013 10:20:11 +0200
parents f517fefa7545
children 106bd0ff2498
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierAdditionPhase.java
diffstat 1 files changed, 30 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierAdditionPhase.java	Wed Sep 25 10:08:14 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierAdditionPhase.java	Wed Sep 25 10:20:11 2013 +0200
@@ -65,53 +65,60 @@
         }
     }
 
-    private static void addWriteNodeBarriers(WriteNode node, StructuredGraph graph) {
+    protected static void addG1PreWriteBarrier(AccessNode node, ValueNode object, ValueNode value, LocationNode location, boolean doLoad, boolean nullCheck, StructuredGraph graph) {
+        G1PreWriteBarrier preBarrier = graph.add(new G1PreWriteBarrier(object, value, location, doLoad, nullCheck));
+        preBarrier.setDeoptimizationState(node.getDeoptimizationState());
+        node.setNullCheck(false);
+        node.setDeoptimizationState(null);
+        graph.addBeforeFixed(node, preBarrier);
+    }
+
+    protected void addG1PostWriteBarrier(AccessNode node, ValueNode object, ValueNode value, LocationNode location, boolean precise, StructuredGraph graph) {
+        graph.addAfterFixed(node, graph.add(new G1PostWriteBarrier(object, value, location, precise)));
+    }
+
+    protected void addSerialPostWriteBarrier(AccessNode node, ValueNode object, ValueNode value, LocationNode location, boolean precise, StructuredGraph graph) {
+        graph.addAfterFixed(node, graph.add(new SerialWriteBarrier(object, value, location, precise)));
+    }
+
+    private void addWriteNodeBarriers(WriteNode node, StructuredGraph graph) {
         BarrierType barrierType = node.getBarrierType();
         if (barrierType == BarrierType.PRECISE) {
             if (useG1GC()) {
                 if (!node.isInitialization()) {
-                    G1PreWriteBarrier preBarrier = graph.add(new G1PreWriteBarrier(node.object(), null, node.location(), true, node.getNullCheck()));
-                    preBarrier.setDeoptimizationState(node.getDeoptimizationState());
-                    node.setNullCheck(false);
-                    node.setDeoptimizationState(null);
-                    graph.addBeforeFixed(node, preBarrier);
+                    addG1PreWriteBarrier(node, node.object(), null, node.location(), true, node.getNullCheck(), graph);
                 }
-                graph.addAfterFixed(node, graph.add(new G1PostWriteBarrier(node.object(), node.value(), node.location(), true)));
+                addG1PostWriteBarrier(node, node.object(), node.value(), node.location(), true, graph);
             } else {
-                graph.addAfterFixed(node, graph.add(new SerialWriteBarrier(node.object(), node.value(), node.location(), true)));
+                addSerialPostWriteBarrier(node, node.object(), node.value(), node.location(), true, graph);
             }
         } else if (barrierType == BarrierType.IMPRECISE) {
             if (useG1GC()) {
-                G1PreWriteBarrier preBarrier = graph.add(new G1PreWriteBarrier(node.object(), null, node.location(), true, node.getNullCheck()));
-                preBarrier.setDeoptimizationState(node.getDeoptimizationState());
-                node.setNullCheck(false);
-                node.setDeoptimizationState(null);
-                graph.addBeforeFixed(node, preBarrier);
-                graph.addAfterFixed(node, graph.add(new G1PostWriteBarrier(node.object(), node.value(), node.location(), false)));
+                addG1PreWriteBarrier(node, node.object(), null, node.location(), true, node.getNullCheck(), graph);
+                addG1PostWriteBarrier(node, node.object(), node.value(), node.location(), false, graph);
             } else {
-                graph.addAfterFixed(node, graph.add(new SerialWriteBarrier(node.object(), node.value(), node.location(), false)));
+                addSerialPostWriteBarrier(node, node.object(), node.value(), node.location(), false, graph);
             }
         } else {
             assert barrierType == BarrierType.NONE;
         }
-
     }
 
-    private static void addCASBarriers(LoweredCompareAndSwapNode node, StructuredGraph graph) {
+    private void addCASBarriers(LoweredCompareAndSwapNode node, StructuredGraph graph) {
         BarrierType barrierType = node.getBarrierType();
         if (barrierType == BarrierType.PRECISE) {
             if (useG1GC()) {
-                graph.addBeforeFixed(node, graph.add(new G1PreWriteBarrier(node.object(), node.getExpectedValue(), node.location(), false, false)));
-                graph.addAfterFixed(node, graph.add(new G1PostWriteBarrier(node.object(), node.getNewValue(), node.location(), true)));
+                addG1PreWriteBarrier(node, node.object(), node.getExpectedValue(), node.location(), false, false, graph);
+                addG1PostWriteBarrier(node, node.object(), node.getNewValue(), node.location(), true, graph);
             } else {
-                graph.addAfterFixed(node, graph.add(new SerialWriteBarrier(node.object(), node.getNewValue(), node.location(), true)));
+                addSerialPostWriteBarrier(node, node.object(), node.getNewValue(), node.location(), true, graph);
             }
         } else if (barrierType == BarrierType.IMPRECISE) {
             if (useG1GC()) {
-                graph.addBeforeFixed(node, graph.add(new G1PreWriteBarrier(node.object(), node.getExpectedValue(), node.location(), false, false)));
-                graph.addAfterFixed(node, graph.add(new G1PostWriteBarrier(node.object(), node.getNewValue(), node.location(), false)));
+                addG1PreWriteBarrier(node, node.object(), node.getExpectedValue(), node.location(), false, false, graph);
+                addG1PostWriteBarrier(node, node.object(), node.getNewValue(), node.location(), false, graph);
             } else {
-                graph.addAfterFixed(node, graph.add(new SerialWriteBarrier(node.object(), node.getNewValue(), node.location(), false)));
+                addSerialPostWriteBarrier(node, node.object(), node.getNewValue(), node.location(), false, graph);
             }
         } else {
             assert barrierType == BarrierType.NONE;
@@ -131,5 +138,4 @@
             graph.addAfterFixed(node, serialArrayRangeWriteBarrier);
         }
     }
-
 }