changeset 9906:fc93d919f896

PhaseContext: add an instance of CanonicalizerPhase to context
author Bernhard Urban <bernhard.urban@jku.at>
date Wed, 05 Jun 2013 21:17:38 +0200
parents 97cabe2c4642
children 7e0a3f8fbd70
files graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/BoxingEliminationTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FloatingReadTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PushNodesThroughPiTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReadAfterCheckCastTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/WriteBarrierAdditionTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/WriteBarrierVerificationTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EscapeAnalysisTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/IterativeInliningTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PartialEscapeAnalysisTest.java graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/HighTierContext.java graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/LowTierContext.java graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/MidTierContext.java graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/PhaseContext.java graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/IterativeInliningPhase.java graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeAnalysisPhase.java
diffstat 22 files changed, 63 insertions(+), 60 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/BoxingEliminationTest.java	Wed Jun 05 21:17:25 2013 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/BoxingEliminationTest.java	Wed Jun 05 21:17:38 2013 +0200
@@ -307,7 +307,7 @@
     private void processMethod(final String snippet) {
         graph = parse(snippet);
         Assumptions assumptions = new Assumptions(false);
-        HighTierContext context = new HighTierContext(runtime(), assumptions, replacements);
+        HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, new CanonicalizerPhase());
         new InliningPhase(runtime(), null, replacements, assumptions, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(graph);
         new PartialEscapeAnalysisPhase(false, false).apply(graph, context);
         new CullFrameStatesPhase().apply(graph);
@@ -325,23 +325,23 @@
                 graph = parse(snippet);
 
                 Assumptions assumptions = new Assumptions(false);
-                HighTierContext context = new HighTierContext(runtime(), assumptions, replacements);
+                HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, new CanonicalizerPhase());
                 new InliningPhase(runtime(), null, replacements, assumptions, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(graph);
                 if (loopPeeling) {
                     new LoopTransformHighPhase().apply(graph);
                 }
                 new DeadCodeEliminationPhase().apply(graph);
-                new CanonicalizerPhase().apply(graph, context);
+                context.applyCanonicalizer(graph);
                 new PartialEscapeAnalysisPhase(false, false).apply(graph, context);
 
                 new CullFrameStatesPhase().apply(graph);
                 new DeadCodeEliminationPhase().apply(graph);
-                new CanonicalizerPhase().apply(graph, context);
+                context.applyCanonicalizer(graph);
 
                 StructuredGraph referenceGraph = parse(referenceSnippet);
                 new InliningPhase(runtime(), null, replacements, assumptions, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(referenceGraph);
                 new DeadCodeEliminationPhase().apply(referenceGraph);
-                new CanonicalizerPhase().apply(referenceGraph, context);
+                context.applyCanonicalizer(referenceGraph);
 
                 assertEquals(referenceGraph, graph, excludeVirtual);
             }
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FloatingReadTest.java	Wed Jun 05 21:17:25 2013 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FloatingReadTest.java	Wed Jun 05 21:17:38 2013 +0200
@@ -59,7 +59,7 @@
 
             public void run() {
                 StructuredGraph graph = parse(snippet);
-                HighTierContext context = new HighTierContext(runtime(), new Assumptions(false), replacements);
+                HighTierContext context = new HighTierContext(runtime(), new Assumptions(false), replacements, new CanonicalizerPhase());
                 new LoweringPhase(LoweringType.BEFORE_GUARDS).apply(graph, context);
                 new FloatingReadPhase().apply(graph);
 
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java	Wed Jun 05 21:17:25 2013 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java	Wed Jun 05 21:17:38 2013 +0200
@@ -33,7 +33,7 @@
 import com.oracle.graal.graph.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.extended.*;
-import com.oracle.graal.nodes.spi.Lowerable.*;
+import com.oracle.graal.nodes.spi.Lowerable.LoweringType;
 import com.oracle.graal.nodes.util.*;
 import com.oracle.graal.phases.*;
 import com.oracle.graal.phases.common.*;
@@ -220,11 +220,11 @@
             public SchedulePhase call() throws Exception {
                 StructuredGraph graph = parse(snippet);
                 Assumptions assumptions = new Assumptions(false);
-                new CanonicalizerPhase.Instance(runtime, assumptions).apply(graph);
+                HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, new CanonicalizerPhase());
+                context.applyCanonicalizer(graph);
                 if (mode == TestMode.INLINED_WITHOUT_FRAMESTATES) {
                     new InliningPhase(runtime(), null, replacements, assumptions, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(graph);
                 }
-                HighTierContext context = new HighTierContext(runtime(), assumptions, replacements);
                 new LoweringPhase(LoweringType.BEFORE_GUARDS).apply(graph, context);
                 if (mode == TestMode.WITHOUT_FRAMESTATES || mode == TestMode.INLINED_WITHOUT_FRAMESTATES) {
                     for (Node node : graph.getNodes()) {
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PushNodesThroughPiTest.java	Wed Jun 05 21:17:25 2013 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PushNodesThroughPiTest.java	Wed Jun 05 21:17:38 2013 +0200
@@ -92,11 +92,11 @@
 
     private StructuredGraph compileTestSnippet(final String snippet) {
         StructuredGraph graph = parse(snippet);
-        HighTierContext context = new HighTierContext(runtime(), new Assumptions(false), replacements);
+        HighTierContext context = new HighTierContext(runtime(), new Assumptions(false), replacements, new CanonicalizerPhase());
         new LoweringPhase(LoweringType.BEFORE_GUARDS).apply(graph, context);
-        new CanonicalizerPhase().apply(graph, context);
+        context.applyCanonicalizer(graph);
         new PushThroughPiPhase().apply(graph);
-        new CanonicalizerPhase().apply(graph, context);
+        context.applyCanonicalizer(graph);
 
         return graph;
     }
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReadAfterCheckCastTest.java	Wed Jun 05 21:17:25 2013 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReadAfterCheckCastTest.java	Wed Jun 05 21:17:38 2013 +0200
@@ -84,12 +84,12 @@
             // structure changes significantly
             public void run() {
                 StructuredGraph graph = parse(snippet);
-                HighTierContext context = new HighTierContext(runtime(), new Assumptions(false), replacements);
+                HighTierContext context = new HighTierContext(runtime(), new Assumptions(false), replacements, new CanonicalizerPhase());
                 new LoweringPhase(LoweringType.BEFORE_GUARDS).apply(graph, context);
                 new FloatingReadPhase().apply(graph);
                 new EliminatePartiallyRedundantGuardsPhase(true, false).apply(graph);
                 new ReadEliminationPhase().apply(graph);
-                new CanonicalizerPhase().apply(graph, context);
+                context.applyCanonicalizer(graph);
 
                 Debug.dump(graph, "After lowering");
 
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/WriteBarrierAdditionTest.java	Wed Jun 05 21:17:25 2013 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/WriteBarrierAdditionTest.java	Wed Jun 05 21:17:38 2013 +0200
@@ -99,7 +99,7 @@
 
             public void run() {
                 StructuredGraph graph = parse(snippet);
-                HighTierContext context = new HighTierContext(runtime(), new Assumptions(false), replacements);
+                HighTierContext context = new HighTierContext(runtime(), new Assumptions(false), replacements, new CanonicalizerPhase());
                 new LoweringPhase(LoweringType.BEFORE_GUARDS).apply(graph, context);
                 new WriteBarrierAdditionPhase().apply(graph);
                 Debug.dump(graph, "After Write Barrier Addition");
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/WriteBarrierVerificationTest.java	Wed Jun 05 21:17:25 2013 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/WriteBarrierVerificationTest.java	Wed Jun 05 21:17:38 2013 +0200
@@ -621,8 +621,9 @@
 
             public AssertionError call() {
                 final StructuredGraph graph = parse(snippet);
-                HighTierContext highTierContext = new HighTierContext(runtime(), new Assumptions(false), replacements);
-                MidTierContext midTierContext = new MidTierContext(runtime(), new Assumptions(false), replacements, runtime().getTarget(), OptimisticOptimizations.ALL);
+                CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
+                HighTierContext highTierContext = new HighTierContext(runtime(), new Assumptions(false), replacements, canonicalizer);
+                MidTierContext midTierContext = new MidTierContext(runtime(), new Assumptions(false), replacements, canonicalizer, runtime().getTarget(), OptimisticOptimizations.ALL);
 
                 new LoweringPhase(LoweringType.BEFORE_GUARDS).apply(graph, highTierContext);
                 new GuardLoweringPhase().apply(graph, midTierContext);
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EscapeAnalysisTest.java	Wed Jun 05 21:17:25 2013 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EscapeAnalysisTest.java	Wed Jun 05 21:17:38 2013 +0200
@@ -219,7 +219,7 @@
                 new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph);
 
                 Assumptions assumptions = new Assumptions(false);
-                HighTierContext context = new HighTierContext(runtime(), assumptions, replacements);
+                HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, new CanonicalizerPhase());
                 new InliningPhase(runtime(), null, replacements, assumptions, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(graph);
                 new DeadCodeEliminationPhase().apply(graph);
                 new PartialEscapeAnalysisPhase(iterativeEscapeAnalysis, false).apply(graph, context);
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/IterativeInliningTest.java	Wed Jun 05 21:17:25 2013 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/IterativeInliningTest.java	Wed Jun 05 21:17:38 2013 +0200
@@ -34,6 +34,7 @@
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.java.*;
 import com.oracle.graal.phases.*;
+import com.oracle.graal.phases.common.*;
 import com.oracle.graal.phases.tiers.*;
 import com.oracle.graal.virtual.phases.ea.*;
 
@@ -102,7 +103,7 @@
     private void processMethod(final String snippet) {
         graph = parse(snippet);
         OptEarlyReadElimination.setValue(true);
-        HighTierContext context = new HighTierContext(runtime(), new Assumptions(false), replacements);
+        HighTierContext context = new HighTierContext(runtime(), new Assumptions(false), replacements, new CanonicalizerPhase());
         new IterativeInliningPhase(replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL, false).apply(graph, context);
     }
 }
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java	Wed Jun 05 21:17:25 2013 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java	Wed Jun 05 21:17:38 2013 +0200
@@ -222,7 +222,7 @@
     private void processMethod(final String snippet) {
         graph = parse(snippet);
         Assumptions assumptions = new Assumptions(false);
-        HighTierContext context = new HighTierContext(runtime(), assumptions, replacements);
+        HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, new CanonicalizerPhase());
         new InliningPhase(runtime(), null, replacements, assumptions, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(graph);
         new PartialEscapeAnalysisPhase(false, true).apply(graph, context);
     }
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PartialEscapeAnalysisTest.java	Wed Jun 05 21:17:25 2013 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PartialEscapeAnalysisTest.java	Wed Jun 05 21:17:38 2013 +0200
@@ -161,15 +161,15 @@
                 StructuredGraph graph = parse(snippet);
 
                 Assumptions assumptions = new Assumptions(false);
-                HighTierContext context = new HighTierContext(runtime(), assumptions, replacements);
+                HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, new CanonicalizerPhase());
                 new InliningPhase(runtime(), null, replacements, assumptions, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(graph);
                 new DeadCodeEliminationPhase().apply(graph);
-                new CanonicalizerPhase().apply(graph, context);
+                context.applyCanonicalizer(graph);
                 new PartialEscapeAnalysisPhase(false, false).apply(graph, context);
 
                 new CullFrameStatesPhase().apply(graph);
                 new DeadCodeEliminationPhase().apply(graph);
-                new CanonicalizerPhase().apply(graph, context);
+                context.applyCanonicalizer(graph);
                 return graph;
             }
         });
--- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Wed Jun 05 21:17:25 2013 +0200
+++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java	Wed Jun 05 21:17:38 2013 +0200
@@ -140,12 +140,13 @@
             new VerifyUsageWithEquals(runtime, Register.class).apply(graph);
         }
 
+        CanonicalizerPhase canonicalizer = new CanonicalizerPhase();
+        HighTierContext highTierContext = new HighTierContext(runtime, assumptions, replacements, canonicalizer);
+
         if (OptCanonicalizer.getValue()) {
-            new CanonicalizerPhase.Instance(runtime, assumptions).apply(graph);
+            highTierContext.applyCanonicalizer(graph);
         }
 
-        HighTierContext highTierContext = new HighTierContext(runtime, assumptions, replacements);
-
         if (Inline.getValue() && !plan.isPhaseDisabled(InliningPhase.class)) {
             if (IterativeInlining.getValue()) {
                 new IterativeInliningPhase(replacements, cache, plan, optimisticOpts, OptEarlyReadElimination.getValue()).apply(graph, highTierContext);
@@ -154,7 +155,7 @@
                 new DeadCodeEliminationPhase().apply(graph);
 
                 if (ConditionalElimination.getValue() && OptCanonicalizer.getValue()) {
-                    new CanonicalizerPhase.Instance(runtime, assumptions).apply(graph);
+                    highTierContext.applyCanonicalizer(graph);
                     new IterativeConditionalEliminationPhase().apply(graph, highTierContext);
                 }
             }
@@ -164,12 +165,12 @@
         plan.runPhases(PhasePosition.HIGH_LEVEL, graph);
         Suites.DEFAULT.getHighTier().apply(graph, highTierContext);
 
-        MidTierContext midTierContext = new MidTierContext(runtime, assumptions, replacements, target, optimisticOpts);
+        MidTierContext midTierContext = new MidTierContext(runtime, assumptions, replacements, canonicalizer, target, optimisticOpts);
         Suites.DEFAULT.getMidTier().apply(graph, midTierContext);
 
         plan.runPhases(PhasePosition.LOW_LEVEL, graph);
 
-        LowTierContext lowTierContext = new LowTierContext(runtime, assumptions, replacements, target);
+        LowTierContext lowTierContext = new LowTierContext(runtime, assumptions, replacements, canonicalizer, target);
         Suites.DEFAULT.getLowTier().apply(graph, lowTierContext);
         InliningPhase.storeStatisticsAfterLowTier(graph);
 
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java	Wed Jun 05 21:17:25 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java	Wed Jun 05 21:17:38 2013 +0200
@@ -83,10 +83,10 @@
         }
         // the canonicalization before loop unrolling is needed to propagate the length into
         // additions, etc.
-        HighTierContext context = new HighTierContext(tool.getRuntime(), tool.assumptions(), tool.getReplacements());
-        new CanonicalizerPhase().apply(snippetGraph, context);
+        HighTierContext context = new HighTierContext(tool.getRuntime(), tool.assumptions(), tool.getReplacements(), new CanonicalizerPhase());
+        context.applyCanonicalizer(snippetGraph);
         new LoopFullUnrollPhase().apply(snippetGraph, context);
-        new CanonicalizerPhase().apply(snippetGraph, context);
+        context.applyCanonicalizer(snippetGraph);
     }
 
     @Override
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java	Wed Jun 05 21:17:25 2013 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java	Wed Jun 05 21:17:38 2013 +0200
@@ -47,30 +47,14 @@
     private static final DebugMetric METRIC_SIMPLIFICATION_CONSIDERED_NODES = Debug.metric("SimplificationConsideredNodes");
     public static final DebugMetric METRIC_GLOBAL_VALUE_NUMBERING_HITS = Debug.metric("GlobalValueNumberingHits");
 
-    private final CustomCanonicalizer customCanonicalizer;
-    private final Iterable<Node> workingSet;
-
     public interface CustomCanonicalizer {
 
         ValueNode canonicalize(ValueNode node);
     }
 
-    public CanonicalizerPhase() {
-        this(null);
-    }
-
-    public CanonicalizerPhase(CustomCanonicalizer customCanonicalizer) {
-        this(customCanonicalizer, null);
-    }
-
-    public CanonicalizerPhase(CustomCanonicalizer customCanonicalizer, Iterable<Node> workingSet) {
-        this.customCanonicalizer = customCanonicalizer;
-        this.workingSet = workingSet;
-    }
-
     @Override
     protected void run(StructuredGraph graph, PhaseContext context) {
-        new Instance(context.getRuntime(), context.getAssumptions(), workingSet, customCanonicalizer).run(graph);
+        new Instance(context.getRuntime(), context.getAssumptions()).run(graph);
     }
 
     public static class Instance extends Phase {
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java	Wed Jun 05 21:17:25 2013 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java	Wed Jun 05 21:17:38 2013 +0200
@@ -690,7 +690,8 @@
                 if (opportunities > 0) {
                     metricInliningTailDuplication.increment();
                     Debug.log("MultiTypeGuardInlineInfo starting tail duplication (%d opportunities)", opportunities);
-                    TailDuplicationPhase.tailDuplicate(returnMerge, TailDuplicationPhase.TRUE_DECISION, replacementNodes, new HighTierContext(runtime, assumptions, replacements));
+                    TailDuplicationPhase.tailDuplicate(returnMerge, TailDuplicationPhase.TRUE_DECISION, replacementNodes, new HighTierContext(runtime, assumptions, replacements,
+                                    new CanonicalizerPhase()));
                 }
             }
         }
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java	Wed Jun 05 21:17:25 2013 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java	Wed Jun 05 21:17:38 2013 +0200
@@ -300,7 +300,7 @@
                     phi.setMerge(mergeAfter);
                 }
             }
-            new CanonicalizerPhase(null, graph.getNewNodes(startMark)).apply(graph, phaseContext);
+            new CanonicalizerPhase.Instance(phaseContext.getRuntime(), phaseContext.getAssumptions(), graph.getNewNodes(startMark), null).apply(graph);
             Debug.dump(graph, "After tail duplication at %s", merge);
         }
 
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/HighTierContext.java	Wed Jun 05 21:17:25 2013 +0200
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/HighTierContext.java	Wed Jun 05 21:17:38 2013 +0200
@@ -25,10 +25,11 @@
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.phases.*;
 
 public class HighTierContext extends PhaseContext {
 
-    public HighTierContext(MetaAccessProvider runtime, Assumptions assumptions, Replacements replacements) {
-        super(runtime, assumptions, replacements);
+    public HighTierContext(MetaAccessProvider runtime, Assumptions assumptions, Replacements replacements, BasePhase<PhaseContext> canonicalizer) {
+        super(runtime, assumptions, replacements, canonicalizer);
     }
 }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/LowTierContext.java	Wed Jun 05 21:17:25 2013 +0200
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/LowTierContext.java	Wed Jun 05 21:17:38 2013 +0200
@@ -25,13 +25,14 @@
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
 import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.phases.*;
 
 public class LowTierContext extends PhaseContext {
 
     private final TargetDescription target;
 
-    public LowTierContext(MetaAccessProvider runtime, Assumptions assumptions, Replacements replacements, TargetDescription target) {
-        super(runtime, assumptions, replacements);
+    public LowTierContext(MetaAccessProvider runtime, Assumptions assumptions, Replacements replacements, BasePhase<PhaseContext> canonicalizer, TargetDescription target) {
+        super(runtime, assumptions, replacements, canonicalizer);
         this.target = target;
     }
 
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/MidTierContext.java	Wed Jun 05 21:17:25 2013 +0200
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/MidTierContext.java	Wed Jun 05 21:17:38 2013 +0200
@@ -32,8 +32,9 @@
     private final TargetDescription target;
     private final OptimisticOptimizations optimisticOpts;
 
-    public MidTierContext(MetaAccessProvider runtime, Assumptions assumptions, Replacements replacements, TargetDescription target, OptimisticOptimizations optimisticOpts) {
-        super(runtime, assumptions, replacements);
+    public MidTierContext(MetaAccessProvider runtime, Assumptions assumptions, Replacements replacements, BasePhase<PhaseContext> canonicalizer, TargetDescription target,
+                    OptimisticOptimizations optimisticOpts) {
+        super(runtime, assumptions, replacements, canonicalizer);
         this.target = target;
         this.optimisticOpts = optimisticOpts;
     }
--- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/PhaseContext.java	Wed Jun 05 21:17:25 2013 +0200
+++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/PhaseContext.java	Wed Jun 05 21:17:38 2013 +0200
@@ -24,18 +24,22 @@
 
 import com.oracle.graal.api.code.*;
 import com.oracle.graal.api.meta.*;
+import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.spi.*;
+import com.oracle.graal.phases.*;
 
 public class PhaseContext {
 
     private final MetaAccessProvider runtime;
     private final Assumptions assumptions;
     private final Replacements replacements;
+    private final BasePhase<PhaseContext> canonicalizer;
 
-    public PhaseContext(MetaAccessProvider runtime, Assumptions assumptions, Replacements replacements) {
+    public PhaseContext(MetaAccessProvider runtime, Assumptions assumptions, Replacements replacements, BasePhase<PhaseContext> canonicalizer) {
         this.runtime = runtime;
         this.assumptions = assumptions;
         this.replacements = replacements;
+        this.canonicalizer = canonicalizer;
     }
 
     public MetaAccessProvider getRuntime() {
@@ -49,4 +53,12 @@
     public Replacements getReplacements() {
         return replacements;
     }
+
+    private BasePhase<PhaseContext> getCanonicalizer() {
+        return canonicalizer;
+    }
+
+    public void applyCanonicalizer(StructuredGraph graph) {
+        getCanonicalizer().apply(graph, this);
+    }
 }
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/IterativeInliningPhase.java	Wed Jun 05 21:17:25 2013 +0200
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/IterativeInliningPhase.java	Wed Jun 05 21:17:38 2013 +0200
@@ -85,7 +85,7 @@
                     new DeadCodeEliminationPhase().apply(graph);
 
                     if (ConditionalElimination.getValue() && OptCanonicalizer.getValue()) {
-                        new CanonicalizerPhase().apply(graph, context);
+                        context.applyCanonicalizer(graph);
                         new IterativeConditionalEliminationPhase().apply(graph, context);
                     }
 
--- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeAnalysisPhase.java	Wed Jun 05 21:17:25 2013 +0200
+++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeAnalysisPhase.java	Wed Jun 05 21:17:38 2013 +0200
@@ -105,7 +105,7 @@
                     new DeadCodeEliminationPhase().apply(graph);
 
                     if (OptCanonicalizer.getValue()) {
-                        new CanonicalizerPhase.Instance(context.getRuntime(), context.getAssumptions()).apply(graph);
+                        context.applyCanonicalizer(graph);
                     }
 
                     return true;