changeset 18954:e8a4803f27f0

Simplifications around PEA and using earliest possible schedule for nodes.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Mon, 26 Jan 2015 23:24:06 +0100
parents fe3a00661c32
children bef8b6316627
files graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsClosure.java graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsPhase.java graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/VirtualUtil.java
diffstat 4 files changed, 83 insertions(+), 60 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsClosure.java	Mon Jan 26 14:43:57 2015 -0800
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsClosure.java	Mon Jan 26 23:24:06 2015 +0100
@@ -32,6 +32,7 @@
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.cfg.*;
+import com.oracle.graal.nodes.spi.*;
 import com.oracle.graal.nodes.virtual.*;
 import com.oracle.graal.phases.graph.*;
 import com.oracle.graal.phases.graph.ReentrantBlockIterator.BlockIteratorClosure;
@@ -124,6 +125,9 @@
             aliases.set(node, null);
             if (node instanceof LoopExitNode) {
                 LoopExitNode loopExit = (LoopExitNode) node;
+                for (ProxyNode proxy : loopExit.proxies()) {
+                    changed |= processNode(proxy, state, effects, lastFixedNode);
+                }
                 processLoopExit(loopExit, loopEntryStates.get(loopExit.loopBegin()), state, blockEffects.get(block));
             }
             changed |= processNode(node, state, effects, lastFixedNode);
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsPhase.java	Mon Jan 26 14:43:57 2015 -0800
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/EffectsPhase.java	Mon Jan 26 23:24:06 2015 +0100
@@ -79,7 +79,7 @@
                     schedule = null;
                     cfg = ControlFlowGraph.compute(graph, true, true, false, false);
                 } else {
-                    schedule = new SchedulePhase();
+                    schedule = new SchedulePhase(SchedulePhase.SchedulingStrategy.EARLIEST);
                     schedule.apply(graph, false);
                     cfg = schedule.getCFG();
                 }
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java	Mon Jan 26 14:43:57 2015 -0800
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PEReadEliminationClosure.java	Mon Jan 26 23:24:06 2015 +0100
@@ -50,62 +50,78 @@
 
     @Override
     protected boolean processNode(Node node, PEReadEliminationBlockState state, GraphEffectList effects, FixedWithNextNode lastFixedNode) {
-        boolean deleted = super.processNode(node, state, effects, lastFixedNode);
-        if (!deleted) {
-            if (node instanceof LoadFieldNode) {
-                LoadFieldNode load = (LoadFieldNode) node;
-                if (!load.isVolatile()) {
-                    ValueNode object = GraphUtil.unproxify(load.object());
-                    ValueNode cachedValue = state.getReadCache(object, load.field(), this);
-                    if (cachedValue != null) {
-                        effects.replaceAtUsages(load, cachedValue);
-                        addScalarAlias(load, cachedValue);
-                        deleted = true;
-                    } else {
-                        state.addReadCache(object, load.field(), load, this);
-                    }
-                } else {
-                    processIdentity(state, ANY_LOCATION);
-                }
-            } else if (node instanceof StoreFieldNode) {
-                StoreFieldNode store = (StoreFieldNode) node;
-                if (!store.isVolatile()) {
-                    ValueNode object = GraphUtil.unproxify(store.object());
-                    ValueNode cachedValue = state.getReadCache(object, store.field(), this);
+        if (super.processNode(node, state, effects, lastFixedNode)) {
+            return true;
+        }
 
-                    ValueNode value = getScalarAlias(store.value());
-                    if (GraphUtil.unproxify(value) == GraphUtil.unproxify(cachedValue)) {
-                        effects.deleteFixedNode(store);
-                        deleted = true;
-                    }
-                    state.killReadCache(store.field());
-                    state.addReadCache(object, store.field(), value, this);
-                } else {
-                    processIdentity(state, ANY_LOCATION);
-                }
-            } else if (node instanceof ArrayLengthNode) {
-                ArrayLengthNode length = (ArrayLengthNode) node;
-                ValueNode array = GraphUtil.unproxify(length.array());
-                ValueNode cachedValue = state.getReadCache(array, ARRAY_LENGTH_LOCATION, this);
-                if (cachedValue != null) {
-                    effects.replaceAtUsages(length, cachedValue);
-                    addScalarAlias(length, cachedValue);
-                    deleted = true;
-                } else {
-                    state.addReadCache(array, ARRAY_LENGTH_LOCATION, length, this);
-                }
-            } else if (node instanceof MemoryCheckpoint.Single) {
-                METRIC_MEMORYCHECKPOINT.increment();
-                LocationIdentity identity = ((MemoryCheckpoint.Single) node).getLocationIdentity();
+        if (node instanceof LoadFieldNode) {
+            return processLoadField((LoadFieldNode) node, state, effects);
+        } else if (node instanceof StoreFieldNode) {
+            return processStoreField((StoreFieldNode) node, state, effects);
+        } else if (node instanceof ArrayLengthNode) {
+            return processArrayLength((ArrayLengthNode) node, state, effects);
+        } else if (node instanceof MemoryCheckpoint.Single) {
+            METRIC_MEMORYCHECKPOINT.increment();
+            LocationIdentity identity = ((MemoryCheckpoint.Single) node).getLocationIdentity();
+            processIdentity(state, identity);
+        } else if (node instanceof MemoryCheckpoint.Multi) {
+            METRIC_MEMORYCHECKPOINT.increment();
+            for (LocationIdentity identity : ((MemoryCheckpoint.Multi) node).getLocationIdentities()) {
                 processIdentity(state, identity);
-            } else if (node instanceof MemoryCheckpoint.Multi) {
-                METRIC_MEMORYCHECKPOINT.increment();
-                for (LocationIdentity identity : ((MemoryCheckpoint.Multi) node).getLocationIdentities()) {
-                    processIdentity(state, identity);
-                }
             }
         }
-        return deleted;
+
+        return false;
+    }
+
+    private boolean processArrayLength(ArrayLengthNode length, PEReadEliminationBlockState state, GraphEffectList effects) {
+        ValueNode array = GraphUtil.unproxify(length.array());
+        ValueNode cachedValue = state.getReadCache(array, ARRAY_LENGTH_LOCATION, this);
+        if (cachedValue != null) {
+            effects.replaceAtUsages(length, cachedValue);
+            addScalarAlias(length, cachedValue);
+            return true;
+        } else {
+            state.addReadCache(array, ARRAY_LENGTH_LOCATION, length, this);
+        }
+        return false;
+    }
+
+    private boolean processStoreField(StoreFieldNode store, PEReadEliminationBlockState state, GraphEffectList effects) {
+        if (!store.isVolatile()) {
+            ValueNode object = GraphUtil.unproxify(store.object());
+            ValueNode cachedValue = state.getReadCache(object, store.field(), this);
+
+            ValueNode value = getScalarAlias(store.value());
+            boolean result = false;
+            if (GraphUtil.unproxify(value) == GraphUtil.unproxify(cachedValue)) {
+                effects.deleteFixedNode(store);
+                result = true;
+            }
+            state.killReadCache(store.field());
+            state.addReadCache(object, store.field(), value, this);
+            return result;
+        } else {
+            processIdentity(state, ANY_LOCATION);
+        }
+        return false;
+    }
+
+    private boolean processLoadField(LoadFieldNode load, PEReadEliminationBlockState state, GraphEffectList effects) {
+        if (!load.isVolatile()) {
+            ValueNode object = GraphUtil.unproxify(load.object());
+            ValueNode cachedValue = state.getReadCache(object, load.field(), this);
+            if (cachedValue != null) {
+                effects.replaceAtUsages(load, cachedValue);
+                addScalarAlias(load, cachedValue);
+                return true;
+            } else {
+                state.addReadCache(object, load.field(), load, this);
+            }
+        } else {
+            processIdentity(state, ANY_LOCATION);
+        }
+        return false;
     }
 
     private static void processIdentity(PEReadEliminationBlockState state, LocationIdentity identity) {
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/VirtualUtil.java	Mon Jan 26 14:43:57 2015 -0800
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/VirtualUtil.java	Mon Jan 26 23:24:06 2015 +0100
@@ -117,15 +117,18 @@
 
     public static boolean matches(StructuredGraph graph, String filter) {
         if (filter != null) {
-            if (filter.startsWith("~")) {
-                ResolvedJavaMethod method = graph.method();
-                return method == null || !method.format("%H.%n").contains(filter.substring(1));
-            } else {
-                ResolvedJavaMethod method = graph.method();
-                return method != null && method.format("%H.%n").contains(filter);
-            }
+            return matchesHelper(graph, filter);
         }
         return true;
     }
 
+    private static boolean matchesHelper(StructuredGraph graph, String filter) {
+        if (filter.startsWith("~")) {
+            ResolvedJavaMethod method = graph.method();
+            return method == null || !method.format("%H.%n").contains(filter.substring(1));
+        } else {
+            ResolvedJavaMethod method = graph.method();
+            return method != null && method.format("%H.%n").contains(filter);
+        }
+    }
 }