changeset 7025:635349143c4f

Insert less placeholder nodes in snippet code Remove placeholder chains
author Gilles Duboscq <duboscq@ssw.jku.at>
date Mon, 26 Nov 2012 16:08:10 +0100
parents 24950e93b962
children d918b5ba3e89
files graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InsertStateAfterPlaceholderPhase.java
diffstat 1 files changed, 17 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InsertStateAfterPlaceholderPhase.java	Mon Nov 26 13:20:00 2012 +0100
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InsertStateAfterPlaceholderPhase.java	Mon Nov 26 16:08:10 2012 +0100
@@ -50,16 +50,29 @@
             if (stateAfter() == null) {
                 return null;
             }
+            FixedNode next = next();
+            if (next instanceof PlaceholderNode && ((PlaceholderNode) next).stateAfter() != null) {
+                return null;
+            }
             return this;
         }
     }
 
     @Override
     protected void run(StructuredGraph graph) {
-        for (ReturnNode ret : graph.getNodes(ReturnNode.class)) {
-            PlaceholderNode p = graph.add(new PlaceholderNode());
-            p.setStateAfter(graph.add(new FrameState(FrameState.AFTER_BCI)));
-            graph.addBeforeFixed(ret, p);
+        boolean needsPlaceHolder = false;
+        for (Node node : graph.getNodes().filterInterface(StateSplit.class)) {
+            StateSplit stateSplit = (StateSplit) node;
+            if (stateSplit.hasSideEffect() && stateSplit.stateAfter() != null) {
+                needsPlaceHolder = true;
+            }
+        }
+        if (needsPlaceHolder) {
+            for (ReturnNode ret : graph.getNodes(ReturnNode.class)) {
+                PlaceholderNode p = graph.add(new PlaceholderNode());
+                p.setStateAfter(graph.add(new FrameState(FrameState.AFTER_BCI)));
+                graph.addBeforeFixed(ret, p);
+            }
         }
     }