changeset 10615:e9241e9cfcd5

Augment WriteBarrier Verification Phase for G1 (only post barriers)
author Christos Kotselidis <christos.kotselidis@oracle.com>
date Sun, 07 Jul 2013 15:24:17 +0200
parents 549a7568ce14
children 1d245cc635e3
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierVerificationPhase.java
diffstat 2 files changed, 25 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Sat Jul 06 11:56:27 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java	Sun Jul 07 15:24:17 2013 +0200
@@ -1214,7 +1214,7 @@
 
         ret.getMidTier().appendPhase(new WriteBarrierAdditionPhase());
         if (VerifyPhases.getValue()) {
-            ret.getMidTier().appendPhase(new WriteBarrierVerificationPhase());
+            ret.getMidTier().appendPhase(new WriteBarrierVerificationPhase(config.useG1GC));
         }
 
         return ret;
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierVerificationPhase.java	Sat Jul 06 11:56:27 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/phases/WriteBarrierVerificationPhase.java	Sun Jul 07 15:24:17 2013 +0200
@@ -41,12 +41,18 @@
  */
 public class WriteBarrierVerificationPhase extends Phase {
 
+    private final boolean useG1GC;
+
+    public WriteBarrierVerificationPhase(boolean useG1GC) {
+        this.useG1GC = useG1GC;
+    }
+
     @Override
     protected void run(StructuredGraph graph) {
         processWrites(graph);
     }
 
-    private static void processWrites(StructuredGraph graph) {
+    private void processWrites(StructuredGraph graph) {
         for (Node node : graph.getNodes()) {
             if (isObjectWrite(node)) {
                 validateWrite(node);
@@ -54,7 +60,7 @@
         }
     }
 
-    private static void validateWrite(Node write) {
+    private void validateWrite(Node write) {
         /*
          * The currently validated write is checked in order to discover if it has an appropriate
          * attached write barrier.
@@ -68,14 +74,25 @@
         while (iterator.hasNext()) {
             Node currentNode = iterator.next();
             assert !isSafepoint(currentNode) : "Write barrier must be present";
-            if (!(currentNode instanceof SerialWriteBarrier) || ((currentNode instanceof SerialWriteBarrier) && !validateBarrier(write, (SerialWriteBarrier) currentNode))) {
-                expandFrontier(frontier, currentNode);
+            if (useG1GC) {
+                if (!(currentNode instanceof G1PostWriteBarrier) || ((currentNode instanceof G1PostWriteBarrier) && !validateBarrier(write, (WriteBarrier) currentNode))) {
+                    expandFrontier(frontier, currentNode);
+                }
+            } else {
+                if (!(currentNode instanceof SerialWriteBarrier) || ((currentNode instanceof SerialWriteBarrier) && !validateBarrier(write, (WriteBarrier) currentNode))) {
+                    expandFrontier(frontier, currentNode);
+                }
             }
         }
     }
 
-    private static boolean hasAttachedBarrier(Node node) {
-        return (((FixedWithNextNode) node).next() instanceof SerialWriteBarrier) && validateBarrier(node, (SerialWriteBarrier) ((FixedWithNextNode) node).next());
+    private boolean hasAttachedBarrier(Node node) {
+        if (useG1GC) {
+            return ((FixedWithNextNode) node).next() instanceof G1PostWriteBarrier && ((FixedWithNextNode) node).predecessor() instanceof G1PreWriteBarrier &&
+                            validateBarrier(node, (G1PostWriteBarrier) ((FixedWithNextNode) node).next()) && validateBarrier(node, (G1PreWriteBarrier) ((FixedWithNextNode) node).predecessor());
+        } else {
+            return (((FixedWithNextNode) node).next() instanceof SerialWriteBarrier) && validateBarrier(node, (SerialWriteBarrier) ((FixedWithNextNode) node).next());
+        }
     }
 
     private static boolean isObjectWrite(Node node) {
@@ -103,7 +120,7 @@
         return ((node instanceof DeoptimizingNode) && ((DeoptimizingNode) node).canDeoptimize()) || (node instanceof LoopBeginNode);
     }
 
-    private static boolean validateBarrier(Node write, SerialWriteBarrier barrier) {
+    private static boolean validateBarrier(Node write, WriteBarrier barrier) {
         ValueNode writtenObject = null;
         LocationNode writtenLocation = null;
         if (write instanceof WriteNode) {