changeset 9268:2d80e5f17bf8

Make GuardLoweringPhase reentrant.
author Roland Schatz <roland.schatz@oracle.com>
date Tue, 23 Apr 2013 17:49:11 +0200
parents 950a385e059b
children 71ebe4030676
files graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java
diffstat 2 files changed, 23 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Tue Apr 23 17:49:10 2013 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Tue Apr 23 17:49:11 2013 +0200
@@ -150,7 +150,7 @@
         // Add safepoints to loops
         new SafepointInsertionPhase().apply(graph);
 
-        new GuardLoweringPhase(target).apply(graph);
+        new GuardLoweringPhase().apply(graph, midTierContext);
 
         plan.runPhases(PhasePosition.LOW_LEVEL, graph);
 
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java	Tue Apr 23 17:49:10 2013 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/GuardLoweringPhase.java	Tue Apr 23 17:49:11 2013 +0200
@@ -25,7 +25,6 @@
 import java.util.*;
 import java.util.Map.Entry;
 
-import com.oracle.graal.api.code.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.calc.*;
@@ -34,8 +33,9 @@
 import com.oracle.graal.nodes.util.*;
 import com.oracle.graal.phases.*;
 import com.oracle.graal.phases.schedule.*;
+import com.oracle.graal.phases.tiers.*;
 
-public class GuardLoweringPhase extends Phase {
+public class GuardLoweringPhase extends BasePhase<MidTierContext> {
 
     private abstract static class ScheduledNodeIterator {
 
@@ -81,9 +81,14 @@
         protected abstract void processNode(Node node);
     }
 
-    private class UseImplicitNullChecks extends ScheduledNodeIterator {
+    private static class UseImplicitNullChecks extends ScheduledNodeIterator {
 
         private final IdentityHashMap<ValueNode, GuardNode> nullGuarded = new IdentityHashMap<>();
+        private final int implicitNullCheckLimit;
+
+        UseImplicitNullChecks(int implicitNullCheckLimit) {
+            this.implicitNullCheckLimit = implicitNullCheckLimit;
+        }
 
         @Override
         protected void processNode(Node node) {
@@ -134,9 +139,17 @@
                 nullGuarded.put(obj, guard);
             }
         }
+
+        private boolean isImplicitNullCheck(LocationNode location) {
+            if (location instanceof ConstantLocationNode) {
+                return ((ConstantLocationNode) location).displacement() < implicitNullCheckLimit;
+            } else {
+                return false;
+            }
+        }
     }
 
-    private class LowerGuards extends ScheduledNodeIterator {
+    private static class LowerGuards extends ScheduledNodeIterator {
 
         private final Block block;
 
@@ -193,35 +206,21 @@
         }
     }
 
-    private TargetDescription target;
-
-    public GuardLoweringPhase(TargetDescription target) {
-        this.target = target;
-    }
-
     @Override
-    protected void run(StructuredGraph graph) {
+    protected void run(StructuredGraph graph, MidTierContext context) {
         SchedulePhase schedule = new SchedulePhase();
         schedule.apply(graph);
 
         for (Block block : schedule.getCFG().getBlocks()) {
-            processBlock(block, schedule);
+            processBlock(block, schedule, context.getTarget().implicitNullCheckLimit);
         }
     }
 
-    private void processBlock(Block block, SchedulePhase schedule) {
+    private static void processBlock(Block block, SchedulePhase schedule, int implicitNullCheckLimit) {
         List<ScheduledNode> nodes = schedule.nodesFor(block);
-        if (GraalOptions.OptImplicitNullChecks && target.implicitNullCheckLimit > 0) {
-            new UseImplicitNullChecks().processNodes(nodes, block.getBeginNode());
+        if (GraalOptions.OptImplicitNullChecks && implicitNullCheckLimit > 0) {
+            new UseImplicitNullChecks(implicitNullCheckLimit).processNodes(nodes, block.getBeginNode());
         }
         new LowerGuards(block).processNodes(nodes, block.getBeginNode());
     }
-
-    private boolean isImplicitNullCheck(LocationNode location) {
-        if (location instanceof ConstantLocationNode) {
-            return ((ConstantLocationNode) location).displacement() < target.implicitNullCheckLimit;
-        } else {
-            return false;
-        }
-    }
 }