# HG changeset patch # User Lukas Stadler # Date 1368019806 -7200 # Node ID 76c40c3f6bb791f0c70aa0cc614de0f7a9684e49 # Parent c0d76a2ef720a5cc4acd9bd0bdce9d9e3bcf43a7 let ReentrantNodeIterator.processNode return the next state diff -r c0d76a2ef720 -r 76c40c3f6bb7 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/WriteBarrierVerificationTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/WriteBarrierVerificationTest.java Wed May 08 13:42:14 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/WriteBarrierVerificationTest.java Wed May 08 15:30:06 2013 +0200 @@ -634,17 +634,11 @@ final int barriers = graph.getNodes(SerialWriteBarrier.class).count(); Assert.assertTrue(expectedBarriers == barriers); - class State { - - boolean removeBarrier = false; - - } - // Iterate over all write nodes and remove barriers according to input indices. - NodeIteratorClosure closure = new NodeIteratorClosure() { + NodeIteratorClosure closure = new NodeIteratorClosure() { @Override - protected void processNode(FixedNode node, State currentState) { + protected Boolean processNode(FixedNode node, Boolean currentState) { if (node instanceof WriteNode) { WriteNode write = (WriteNode) node; LocationIdentity obj = write.getLocationIdentities()[0]; @@ -655,17 +649,18 @@ * the input barrier array. */ if (eliminateBarrier(write.value().asConstant().asInt(), removedBarrierIndices)) { - currentState.removeBarrier = true; + return true; } } } } else if (node instanceof SerialWriteBarrier) { // Remove flagged write barriers. - if (currentState.removeBarrier) { + if (currentState) { graph.removeFixed(((SerialWriteBarrier) node)); - currentState.removeBarrier = false; + return false; } } + return currentState; } private boolean eliminateBarrier(int index, int[] map) { @@ -678,24 +673,24 @@ } @Override - protected Map processLoop(LoopBeginNode loop, State initialState) { + protected Map processLoop(LoopBeginNode loop, Boolean initialState) { return ReentrantNodeIterator.processLoop(this, loop, initialState).exitStates; } @Override - protected State merge(MergeNode merge, List states) { - return new State(); + protected Boolean merge(MergeNode merge, List states) { + return false; } @Override - protected State afterSplit(AbstractBeginNode node, State oldState) { - return new State(); + protected Boolean afterSplit(AbstractBeginNode node, Boolean oldState) { + return false; } }; DebugConfig config = DebugScope.getConfig(); try { - ReentrantNodeIterator.apply(closure, graph.start(), new State(), null); + ReentrantNodeIterator.apply(closure, graph.start(), false, null); Debug.setConfig(Debug.fixedConfig(false, false, false, false, config.dumpHandlers(), config.output())); new WriteBarrierVerificationPhase().apply(graph); } catch (AssertionError error) { diff -r c0d76a2ef720 -r 76c40c3f6bb7 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java Wed May 08 13:42:14 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java Wed May 08 15:30:06 2013 +0200 @@ -88,12 +88,13 @@ } @Override - protected void processNode(FixedNode node, Set currentState) { + protected Set processNode(FixedNode node, Set currentState) { if (node instanceof MemoryCheckpoint) { for (LocationIdentity identity : ((MemoryCheckpoint) node).getLocationIdentities()) { currentState.add(identity); } } + return currentState; } @Override @@ -137,12 +138,13 @@ } @Override - protected void processNode(FixedNode node, MemoryMap state) { + protected MemoryMap processNode(FixedNode node, MemoryMap state) { if (node instanceof FloatableAccessNode) { processFloatable((FloatableAccessNode) node, state); } else if (node instanceof MemoryCheckpoint) { processCheckpoint((MemoryCheckpoint) node, state); } + return state; } private static void processCheckpoint(MemoryCheckpoint checkpoint, MemoryMap state) { diff -r c0d76a2ef720 -r 76c40c3f6bb7 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ReentrantNodeIterator.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ReentrantNodeIterator.java Wed May 08 13:42:14 2013 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/graph/ReentrantNodeIterator.java Wed May 08 15:30:06 2013 +0200 @@ -37,7 +37,7 @@ public abstract static class NodeIteratorClosure { - protected abstract void processNode(FixedNode node, StateT currentState); + protected abstract StateT processNode(FixedNode node, StateT currentState); protected abstract StateT merge(MergeNode merge, List states); @@ -82,13 +82,13 @@ current = null; } else { FixedNode next = ((FixedWithNextNode) current).next(); - closure.processNode(current, state); + state = closure.processNode(current, state); current = next; } } if (current != null) { - closure.processNode(current, state); + state = closure.processNode(current, state); NodeClassIterator successors = current.successors().iterator(); if (!successors.hasNext()) { diff -r c0d76a2ef720 -r 76c40c3f6bb7 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetFrameStateCleanupPhase.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetFrameStateCleanupPhase.java Wed May 08 13:42:14 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetFrameStateCleanupPhase.java Wed May 08 15:30:06 2013 +0200 @@ -45,33 +45,24 @@ @Override protected void run(StructuredGraph graph) { - ReentrantNodeIterator.apply(new SnippetFrameStateCleanupClosure(), graph.start(), new CleanupState(false), null); - } - - private static class CleanupState { - - public boolean containsFrameState; - - public CleanupState(boolean containsFrameState) { - this.containsFrameState = containsFrameState; - } + ReentrantNodeIterator.apply(new SnippetFrameStateCleanupClosure(), graph.start(), false, null); } /** * A proper (loop-aware) iteration over the graph is used to detect loops that contain invalid * frame states, so that they can be marked with an invalid frame state. */ - private static class SnippetFrameStateCleanupClosure extends NodeIteratorClosure { + private static class SnippetFrameStateCleanupClosure extends NodeIteratorClosure { @Override - protected void processNode(FixedNode node, CleanupState currentState) { + protected Boolean processNode(FixedNode node, Boolean currentState) { if (node instanceof StateSplit) { StateSplit stateSplit = (StateSplit) node; FrameState frameState = stateSplit.stateAfter(); if (frameState != null) { if (stateSplit.hasSideEffect()) { - currentState.containsFrameState = true; stateSplit.setStateAfter(node.graph().add(new FrameState(FrameState.INVALID_FRAMESTATE_BCI))); + return true; } else { stateSplit.setStateAfter(null); } @@ -80,36 +71,37 @@ } } } + return currentState; } @Override - protected CleanupState merge(MergeNode merge, List states) { - for (CleanupState state : states) { - if (state.containsFrameState) { - return new CleanupState(true); + protected Boolean merge(MergeNode merge, List states) { + for (boolean state : states) { + if (state) { + return true; } } - return new CleanupState(false); + return false; } @Override - protected CleanupState afterSplit(AbstractBeginNode node, CleanupState oldState) { - return new CleanupState(oldState.containsFrameState); + protected Boolean afterSplit(AbstractBeginNode node, Boolean oldState) { + return oldState; } @Override - protected Map processLoop(LoopBeginNode loop, CleanupState initialState) { - LoopInfo info = ReentrantNodeIterator.processLoop(this, loop, new CleanupState(false)); + protected Map processLoop(LoopBeginNode loop, Boolean initialState) { + LoopInfo info = ReentrantNodeIterator.processLoop(this, loop, false); boolean containsFrameState = false; - for (CleanupState state : info.endStates.values()) { - containsFrameState |= state.containsFrameState; + for (Boolean state : info.endStates.values()) { + containsFrameState |= state; } if (containsFrameState) { loop.setStateAfter(loop.graph().add(new FrameState(FrameState.INVALID_FRAMESTATE_BCI))); } - if (containsFrameState || initialState.containsFrameState) { - for (CleanupState state : info.exitStates.values()) { - state.containsFrameState = true; + if (containsFrameState || initialState) { + for (Map.Entry entry : info.exitStates.entrySet()) { + entry.setValue(true); } } return info.exitStates;