Mercurial > hg > truffle
diff graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java @ 9329:fa188fbfe3fe
Perform only targeted canonicalization after tail duplication.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Fri, 26 Apr 2013 15:58:41 +0200 |
parents | 8f01fe16e473 |
children | 50f02c7d1cec |
line wrap: on
line diff
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java Fri Apr 26 15:32:58 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java Fri Apr 26 15:58:41 2013 +0200 @@ -36,13 +36,14 @@ import com.oracle.graal.nodes.util.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.graph.*; +import com.oracle.graal.phases.tiers.*; /** * This class is a phase that looks for opportunities for tail duplication. The static method - * {@link #tailDuplicate(MergeNode, TailDuplicationDecision, List)} can also be used to drive tail - * duplication from other places, e.g., inlining. + * {@link #tailDuplicate(MergeNode, TailDuplicationDecision, List, PhaseContext)} can also be used + * to drive tail duplication from other places, e.g., inlining. */ -public class TailDuplicationPhase extends Phase { +public class TailDuplicationPhase extends BasePhase<PhaseContext> { /* * Various metrics on the circumstances in which tail duplication was/wasn't performed. @@ -129,14 +130,14 @@ }; @Override - protected void run(StructuredGraph graph) { + protected void run(StructuredGraph graph, PhaseContext phaseContext) { NodesToDoubles nodeProbabilities = new ComputeProbabilityClosure(graph).apply(); // A snapshot is taken here, so that new MergeNode instances aren't considered for tail // duplication. for (MergeNode merge : graph.getNodes(MergeNode.class).snapshot()) { if (!(merge instanceof LoopBeginNode) && nodeProbabilities.get(merge) >= GraalOptions.TailDuplicationProbability) { - tailDuplicate(merge, DEFAULT_DECISION, null); + tailDuplicate(merge, DEFAULT_DECISION, null, phaseContext); } } } @@ -156,8 +157,9 @@ * size needs to match the merge's end count. Each entry can either be null or a * {@link PiNode}, and is used to replace {@link PiNode#object()} with the * {@link PiNode} in the duplicated branch that corresponds to the entry. + * @param phaseContext */ - public static boolean tailDuplicate(MergeNode merge, TailDuplicationDecision decision, List<PiNode> replacements) { + public static boolean tailDuplicate(MergeNode merge, TailDuplicationDecision decision, List<PiNode> replacements, PhaseContext phaseContext) { assert !(merge instanceof LoopBeginNode); assert replacements == null || replacements.size() == merge.forwardEndCount(); FixedNode fixed = merge; @@ -171,14 +173,14 @@ metricDuplicationEnd.increment(); if (decision.doTransform(merge, fixedCount)) { metricDuplicationEndPerformed.increment(); - new DuplicationOperation(merge, replacements).duplicate(); + new DuplicationOperation(merge, replacements).duplicate(phaseContext); return true; } } else if (merge.stateAfter() != null) { metricDuplicationOther.increment(); if (decision.doTransform(merge, fixedCount)) { metricDuplicationOtherPerformed.increment(); - new DuplicationOperation(merge, replacements).duplicate(); + new DuplicationOperation(merge, replacements).duplicate(phaseContext); return true; } } @@ -220,10 +222,14 @@ * <li>Determines the complete set of duplicated nodes.</li> * <li>Performs the actual duplication.</li> * </ul> + * + * @param phaseContext */ - private void duplicate() { + private void duplicate(PhaseContext phaseContext) { Debug.log("tail duplication at merge %s in %s", merge, graph.method()); + int startMark = graph.getMark(); + ValueAnchorNode anchor = addValueAnchor(); // determine the fixed nodes that should be duplicated (currently: all nodes up until @@ -297,6 +303,7 @@ phi.setMerge(mergeAfter); } } + new CanonicalizerPhase(null, graph.getNewNodes(startMark)).apply(graph, phaseContext); Debug.dump(graph, "After tail duplication at %s", merge); }