changeset 9634:f3dfca9fd0b3

PEA: replace customAction with addNode (GRAAL-260)
author Lukas Stadler <lukas.stadler@jku.at>
date Fri, 10 May 2013 13:17:38 +0200
parents 5207bb46598e
children dac93aca017b
files graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectCloneNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/VirtualizerTool.java graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/VirtualizerToolImpl.java
diffstat 5 files changed, 23 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectCloneNode.java	Fri May 10 13:07:44 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectCloneNode.java	Fri May 10 13:17:38 2013 +0200
@@ -123,16 +123,8 @@
                     final LoadFieldNode[] loads = new LoadFieldNode[fields.length];
                     for (int i = 0; i < fields.length; i++) {
                         state[i] = loads[i] = new LoadFieldNode(obj, fields[i]);
+                        tool.addNode(loads[i]);
                     }
-
-                    tool.customAction(new Runnable() {
-
-                        public void run() {
-                            for (LoadFieldNode load : loads) {
-                                graph().addBeforeFixed(ObjectCloneNode.this, graph().add(load));
-                            }
-                        }
-                    });
                     tool.createVirtualObject(newVirtual, state, null);
                     tool.replaceWithVirtual(newVirtual);
                 }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java	Fri May 10 13:07:44 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java	Fri May 10 13:17:38 2013 +0200
@@ -74,14 +74,8 @@
         if (!state.getVirtualObject().hasIdentity() && state.getVirtualObject().entryKind(0) == Kind.Boolean) {
             if (other.isConstant()) {
                 int expectedValue = ((Boolean) other.asConstant().asObject()) ? 1 : 0;
-                final IntegerEqualsNode equals = new IntegerEqualsNode(state.getEntry(0), ConstantNode.forInt(expectedValue, graph()));
-                tool.customAction(new Runnable() {
-
-                    @Override
-                    public void run() {
-                        graph().add(equals);
-                    }
-                });
+                IntegerEqualsNode equals = new IntegerEqualsNode(state.getEntry(0), ConstantNode.forInt(expectedValue, graph()));
+                tool.addNode(equals);
                 tool.replaceWithValue(equals);
             }
         } else {
@@ -118,14 +112,8 @@
                 assert stateX.getVirtualObject().entryCount() == 1 && stateY.getVirtualObject().entryCount() == 1;
                 assert stateX.getVirtualObject().type() == stateY.getVirtualObject().type();
                 assert stateX.getVirtualObject().entryKind(0) == Kind.Int || stateX.getVirtualObject().entryKind(0) == Kind.Long;
-                final IntegerEqualsNode equals = new IntegerEqualsNode(stateX.getEntry(0), stateY.getEntry(0));
-                tool.customAction(new Runnable() {
-
-                    @Override
-                    public void run() {
-                        graph().add(equals);
-                    }
-                });
+                IntegerEqualsNode equals = new IntegerEqualsNode(stateX.getEntry(0), stateY.getEntry(0));
+                tool.addNode(equals);
                 tool.replaceWithValue(equals);
             } else {
                 // both are virtual with identity: check if they refer to the same object
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/VirtualizerTool.java	Fri May 10 13:07:44 2013 +0200
+++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/VirtualizerTool.java	Fri May 10 13:17:38 2013 +0200
@@ -138,12 +138,12 @@
     void replaceFirstInput(Node oldInput, Node replacement);
 
     /**
-     * Performs a custom action on the current node. This action will only be performed when, and
-     * if, the changes are committed. Custom actions must not modify inputs of nodes.
+     * Adds the given node to the graph.This action will only be performed when, and if, the changes
+     * are committed.
      * 
-     * @param action the custom action.
+     * @param node the node to add.
      */
-    void customAction(Runnable action);
+    void addNode(ValueNode node);
 
     /**
      * This method performs either {@link #replaceWithValue(ValueNode)} or
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java	Fri May 10 13:07:44 2013 +0200
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java	Fri May 10 13:17:38 2013 +0200
@@ -199,12 +199,12 @@
     }
 
     private boolean processNode(final ValueNode node, FixedNode insertBefore, final BlockState state, final GraphEffectList effects) {
-        tool.reset(state, node);
+        tool.reset(state, node, insertBefore);
         if (node instanceof Virtualizable) {
             ((Virtualizable) node).virtualize(tool);
         }
         if (tool.isDeleted()) {
-            if (tool.isCustomAction() || !(node instanceof VirtualizableAllocation || node instanceof CyclicMaterializeStoreNode)) {
+            if (!(node instanceof VirtualizableAllocation || node instanceof CyclicMaterializeStoreNode)) {
                 changed = true;
             }
             return true;
@@ -283,9 +283,6 @@
                 }
             }
         }
-        if (tool.isCustomAction()) {
-            return false;
-        }
         for (ValueNode input : node.inputs().filter(ValueNode.class)) {
             ObjectState obj = state.getObjectState(input);
             if (obj != null) {
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/VirtualizerToolImpl.java	Fri May 10 13:07:44 2013 +0200
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/VirtualizerToolImpl.java	Fri May 10 13:17:38 2013 +0200
@@ -28,6 +28,7 @@
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
+import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.spi.Virtualizable.EscapeState;
 import com.oracle.graal.nodes.spi.Virtualizable.State;
 import com.oracle.graal.nodes.spi.*;
@@ -48,9 +49,9 @@
     }
 
     private boolean deleted;
-    private boolean customAction;
     private BlockState state;
     private ValueNode current;
+    private FixedNode position;
 
     @Override
     public MetaAccessProvider getMetaAccessProvider() {
@@ -66,21 +67,17 @@
         this.effects = effects;
     }
 
-    public void reset(BlockState newState, ValueNode newCurrent) {
+    public void reset(BlockState newState, ValueNode newCurrent, FixedNode newPosition) {
         deleted = false;
-        customAction = false;
-        this.state = newState;
-        this.current = newCurrent;
+        state = newState;
+        current = newCurrent;
+        position = newPosition;
     }
 
     public boolean isDeleted() {
         return deleted;
     }
 
-    public boolean isCustomAction() {
-        return customAction;
-    }
-
     @Override
     public State getObjectState(ValueNode value) {
         return state.getObjectState(value);
@@ -142,9 +139,12 @@
     }
 
     @Override
-    public void customAction(Runnable action) {
-        effects.customAction(action);
-        customAction = true;
+    public void addNode(ValueNode node) {
+        if (node instanceof FloatingNode) {
+            effects.addFloatingNode(node, "VirtualizerTool");
+        } else {
+            effects.addFixedNodeBefore((FixedWithNextNode) node, position);
+        }
     }
 
     @Override