# HG changeset patch # User Bernhard Urban # Date 1380024692 -7200 # Node ID ac252c4c920bef1f486a169decb46d207e775f10 # Parent c9c3f8efe6a99547a38219169a38990a4da0c5b9 FloatingReadPhase: use enum for describing the execution mode of the phase diff -r c9c3f8efe6a9 -r ac252c4c920b 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 Tue Sep 24 14:11:31 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java Tue Sep 24 14:11:32 2013 +0200 @@ -38,6 +38,10 @@ public class FloatingReadPhase extends Phase { + public enum ExecutionMode { + ANALYSIS_ONLY, CREATE_FLOATING_READS + } + public static class MemoryMapImpl implements MemoryMap { private IdentityHashMap lastMemorySnapshot; @@ -76,22 +80,22 @@ } } - private final boolean makeReadsFloating; + private final ExecutionMode execmode; public FloatingReadPhase() { - this(true); + this(ExecutionMode.CREATE_FLOATING_READS); } - public FloatingReadPhase(boolean makeReadsFloating) { - this.makeReadsFloating = makeReadsFloating; + public FloatingReadPhase(ExecutionMode execmode) { + this.execmode = execmode; } @Override protected void run(StructuredGraph graph) { Map> modifiedInLoops = new IdentityHashMap<>(); ReentrantNodeIterator.apply(new CollectMemoryCheckpointsClosure(modifiedInLoops), graph.start(), new HashSet(), null); - ReentrantNodeIterator.apply(new FloatingReadClosure(modifiedInLoops, makeReadsFloating), graph.start(), new MemoryMapImpl(graph.start()), null); - if (makeReadsFloating) { + ReentrantNodeIterator.apply(new FloatingReadClosure(modifiedInLoops, execmode), graph.start(), new MemoryMapImpl(graph.start()), null); + if (execmode == ExecutionMode.CREATE_FLOATING_READS) { assert !graph.isAfterFloatingReadPhase(); graph.setAfterFloatingReadPhase(true); } @@ -152,16 +156,16 @@ private static class FloatingReadClosure extends NodeIteratorClosure { private final Map> modifiedInLoops; - private final boolean makeReadsFloating; + private final ExecutionMode execmode; - public FloatingReadClosure(Map> modifiedInLoops, boolean makeFloating) { + public FloatingReadClosure(Map> modifiedInLoops, ExecutionMode execmode) { this.modifiedInLoops = modifiedInLoops; - this.makeReadsFloating = makeFloating; + this.execmode = execmode; } @Override protected MemoryMapImpl processNode(FixedNode node, MemoryMapImpl state) { - if (node instanceof FloatableAccessNode && makeReadsFloating) { + if (node instanceof FloatableAccessNode && execmode == ExecutionMode.CREATE_FLOATING_READS) { processFloatable((FloatableAccessNode) node, state); } else if (node instanceof MemoryCheckpoint.Single) { processCheckpoint((MemoryCheckpoint.Single) node, state); @@ -170,7 +174,7 @@ } assert MemoryCheckpoint.TypeAssertion.correctType(node) : node; - if (!makeReadsFloating && node instanceof ReturnNode) { + if (execmode == ExecutionMode.ANALYSIS_ONLY && node instanceof ReturnNode) { node.graph().add(new MemoryState(new MemoryMapImpl(state), node)); } return state; diff -r c9c3f8efe6a9 -r ac252c4c920b graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Tue Sep 24 14:11:31 2013 +0200 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java Tue Sep 24 14:11:32 2013 +0200 @@ -536,7 +536,7 @@ assert checkAllVarargPlaceholdersAreDeleted(parameterCount, placeholders); - new FloatingReadPhase(false).apply(snippetCopy); + new FloatingReadPhase(FloatingReadPhase.ExecutionMode.ANALYSIS_ONLY).apply(snippetCopy); this.memoryMap = null; this.snippet = snippetCopy;