# HG changeset patch # User Lukas Stadler # Date 1368184658 -7200 # Node ID f3dfca9fd0b39d5f2128e08dd422b9fb80f60305 # Parent 5207bb46598ef3ac175649d617da0ab6f133fbb1 PEA: replace customAction with addNode (GRAAL-260) diff -r 5207bb46598e -r f3dfca9fd0b3 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ObjectCloneNode.java --- 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); } diff -r 5207bb46598e -r f3dfca9fd0b3 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/calc/ObjectEqualsNode.java --- 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 diff -r 5207bb46598e -r f3dfca9fd0b3 graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/spi/VirtualizerTool.java --- 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 diff -r 5207bb46598e -r f3dfca9fd0b3 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeClosure.java --- 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) { diff -r 5207bb46598e -r f3dfca9fd0b3 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/VirtualizerToolImpl.java --- 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