Mercurial > hg > truffle
changeset 11767:ac252c4c920b
FloatingReadPhase: use enum for describing the execution mode of the phase
author | Bernhard Urban <bernhard.urban@jku.at> |
---|---|
date | Tue, 24 Sep 2013 14:11:32 +0200 |
parents | c9c3f8efe6a9 |
children | e53399f1b2cd |
files | graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/FloatingReadPhase.java graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/SnippetTemplate.java |
diffstat | 2 files changed, 16 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- 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<Node> { private IdentityHashMap<LocationIdentity, ValueNode> 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<LoopBeginNode, Set<LocationIdentity>> modifiedInLoops = new IdentityHashMap<>(); ReentrantNodeIterator.apply(new CollectMemoryCheckpointsClosure(modifiedInLoops), graph.start(), new HashSet<LocationIdentity>(), 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<MemoryMapImpl> { private final Map<LoopBeginNode, Set<LocationIdentity>> modifiedInLoops; - private final boolean makeReadsFloating; + private final ExecutionMode execmode; - public FloatingReadClosure(Map<LoopBeginNode, Set<LocationIdentity>> modifiedInLoops, boolean makeFloating) { + public FloatingReadClosure(Map<LoopBeginNode, Set<LocationIdentity>> 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;
--- 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;