# HG changeset patch # User Bernhard Urban # Date 1370529041 -7200 # Node ID 491cd7d695398529d7fc4fdda5e48d8c2b80ee53 # Parent d8a8d794f63199f42732c29ab4f16b8d1a6d52a7 CanonicalizerPhase: remove it from context, add it to tiers instead and configure/pass it there (GRAAL-309) diff -r d8a8d794f631 -r 491cd7d69539 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/BoxingEliminationTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/BoxingEliminationTest.java Thu Jun 06 20:02:12 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/BoxingEliminationTest.java Thu Jun 06 16:30:41 2013 +0200 @@ -307,9 +307,9 @@ private void processMethod(final String snippet) { graph = parse(snippet); Assumptions assumptions = new Assumptions(false); - HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, new CanonicalizerPhase(true)); + HighTierContext context = new HighTierContext(runtime(), assumptions, replacements); new InliningPhase(runtime(), null, replacements, assumptions, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(graph); - new PartialEscapeAnalysisPhase(false, false).apply(graph, context); + new PartialEscapeAnalysisPhase(false, false, new CanonicalizerPhase(true)).apply(graph, context); new CullFrameStatesPhase().apply(graph); } @@ -325,23 +325,24 @@ graph = parse(snippet); Assumptions assumptions = new Assumptions(false); - HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, new CanonicalizerPhase(true)); + HighTierContext context = new HighTierContext(runtime(), assumptions, replacements); + CanonicalizerPhase canonicalizer = new CanonicalizerPhase(true); new InliningPhase(runtime(), null, replacements, assumptions, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(graph); if (loopPeeling) { new LoopTransformHighPhase().apply(graph); } new DeadCodeEliminationPhase().apply(graph); - context.applyCanonicalizer(graph); - new PartialEscapeAnalysisPhase(false, false).apply(graph, context); + canonicalizer.apply(graph, context); + new PartialEscapeAnalysisPhase(false, false, canonicalizer).apply(graph, context); new CullFrameStatesPhase().apply(graph); new DeadCodeEliminationPhase().apply(graph); - context.applyCanonicalizer(graph); + canonicalizer.apply(graph, context); StructuredGraph referenceGraph = parse(referenceSnippet); new InliningPhase(runtime(), null, replacements, assumptions, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(referenceGraph); new DeadCodeEliminationPhase().apply(referenceGraph); - context.applyCanonicalizer(referenceGraph); + new CanonicalizerPhase(true).apply(referenceGraph, context); assertEquals(referenceGraph, graph, excludeVirtual); } diff -r d8a8d794f631 -r 491cd7d69539 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FloatingReadTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FloatingReadTest.java Thu Jun 06 20:02:12 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/FloatingReadTest.java Thu Jun 06 16:30:41 2013 +0200 @@ -59,7 +59,7 @@ public void run() { StructuredGraph graph = parse(snippet); - HighTierContext context = new HighTierContext(runtime(), new Assumptions(false), replacements, new CanonicalizerPhase(true)); + HighTierContext context = new HighTierContext(runtime(), new Assumptions(false), replacements); new LoweringPhase(LoweringType.BEFORE_GUARDS).apply(graph, context); new FloatingReadPhase().apply(graph); diff -r d8a8d794f631 -r 491cd7d69539 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java Thu Jun 06 20:02:12 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryScheduleTest.java Thu Jun 06 16:30:41 2013 +0200 @@ -220,8 +220,8 @@ public SchedulePhase call() throws Exception { StructuredGraph graph = parse(snippet); Assumptions assumptions = new Assumptions(false); - HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, new CanonicalizerPhase(true)); - context.applyCanonicalizer(graph); + HighTierContext context = new HighTierContext(runtime(), assumptions, replacements); + new CanonicalizerPhase(true).apply(graph, context); if (mode == TestMode.INLINED_WITHOUT_FRAMESTATES) { new InliningPhase(runtime(), null, replacements, assumptions, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(graph); } diff -r d8a8d794f631 -r 491cd7d69539 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PushNodesThroughPiTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PushNodesThroughPiTest.java Thu Jun 06 20:02:12 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/PushNodesThroughPiTest.java Thu Jun 06 16:30:41 2013 +0200 @@ -92,11 +92,12 @@ private StructuredGraph compileTestSnippet(final String snippet) { StructuredGraph graph = parse(snippet); - HighTierContext context = new HighTierContext(runtime(), new Assumptions(false), replacements, new CanonicalizerPhase(true)); + HighTierContext context = new HighTierContext(runtime(), new Assumptions(false), replacements); + CanonicalizerPhase canonicalizer = new CanonicalizerPhase(true); new LoweringPhase(LoweringType.BEFORE_GUARDS).apply(graph, context); - context.applyCanonicalizer(graph); + canonicalizer.apply(graph, context); new PushThroughPiPhase().apply(graph); - context.applyCanonicalizer(graph); + canonicalizer.apply(graph, context); return graph; } diff -r d8a8d794f631 -r 491cd7d69539 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReadAfterCheckCastTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReadAfterCheckCastTest.java Thu Jun 06 20:02:12 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ReadAfterCheckCastTest.java Thu Jun 06 16:30:41 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, new CanonicalizerPhase(true)); + HighTierContext context = new HighTierContext(runtime(), new Assumptions(false), replacements); new LoweringPhase(LoweringType.BEFORE_GUARDS).apply(graph, context); new FloatingReadPhase().apply(graph); new EliminatePartiallyRedundantGuardsPhase(true, false).apply(graph); new ReadEliminationPhase().apply(graph); - context.applyCanonicalizer(graph); + new CanonicalizerPhase(true).apply(graph, context); Debug.dump(graph, "After lowering"); diff -r d8a8d794f631 -r 491cd7d69539 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/WriteBarrierAdditionTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/WriteBarrierAdditionTest.java Thu Jun 06 20:02:12 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/WriteBarrierAdditionTest.java Thu Jun 06 16:30:41 2013 +0200 @@ -99,7 +99,7 @@ public void run() { StructuredGraph graph = parse(snippet); - HighTierContext context = new HighTierContext(runtime(), new Assumptions(false), replacements, new CanonicalizerPhase(true)); + HighTierContext context = new HighTierContext(runtime(), new Assumptions(false), replacements); new LoweringPhase(LoweringType.BEFORE_GUARDS).apply(graph, context); new WriteBarrierAdditionPhase().apply(graph); Debug.dump(graph, "After Write Barrier Addition"); diff -r d8a8d794f631 -r 491cd7d69539 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 Thu Jun 06 20:02:12 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/WriteBarrierVerificationTest.java Thu Jun 06 16:30:41 2013 +0200 @@ -621,9 +621,8 @@ public AssertionError call() { final StructuredGraph graph = parse(snippet); - CanonicalizerPhase canonicalizer = new CanonicalizerPhase(true); - HighTierContext highTierContext = new HighTierContext(runtime(), new Assumptions(false), replacements, canonicalizer); - MidTierContext midTierContext = new MidTierContext(runtime(), new Assumptions(false), replacements, canonicalizer, runtime().getTarget(), OptimisticOptimizations.ALL); + HighTierContext highTierContext = new HighTierContext(runtime(), new Assumptions(false), replacements); + MidTierContext midTierContext = new MidTierContext(runtime(), new Assumptions(false), replacements, runtime().getTarget(), OptimisticOptimizations.ALL); new LoweringPhase(LoweringType.BEFORE_GUARDS).apply(graph, highTierContext); new GuardLoweringPhase().apply(graph, midTierContext); diff -r d8a8d794f631 -r 491cd7d69539 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EscapeAnalysisTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EscapeAnalysisTest.java Thu Jun 06 20:02:12 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EscapeAnalysisTest.java Thu Jun 06 16:30:41 2013 +0200 @@ -219,10 +219,10 @@ new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph); Assumptions assumptions = new Assumptions(false); - HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, new CanonicalizerPhase(true)); + HighTierContext context = new HighTierContext(runtime(), assumptions, replacements); new InliningPhase(runtime(), null, replacements, assumptions, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(graph); new DeadCodeEliminationPhase().apply(graph); - new PartialEscapeAnalysisPhase(iterativeEscapeAnalysis, false).apply(graph, context); + new PartialEscapeAnalysisPhase(iterativeEscapeAnalysis, false, new CanonicalizerPhase(true)).apply(graph, context); Assert.assertEquals(1, graph.getNodes(ReturnNode.class).count()); ReturnNode returnNode = graph.getNodes(ReturnNode.class).first(); if (expectedConstantResult != null) { diff -r d8a8d794f631 -r 491cd7d69539 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/IterativeInliningTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/IterativeInliningTest.java Thu Jun 06 20:02:12 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/IterativeInliningTest.java Thu Jun 06 16:30:41 2013 +0200 @@ -103,7 +103,7 @@ private void processMethod(final String snippet) { graph = parse(snippet); OptEarlyReadElimination.setValue(true); - HighTierContext context = new HighTierContext(runtime(), new Assumptions(false), replacements, new CanonicalizerPhase(true)); - new IterativeInliningPhase(replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL, false).apply(graph, context); + HighTierContext context = new HighTierContext(runtime(), new Assumptions(false), replacements); + new IterativeInliningPhase(replacements, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL, false, new CanonicalizerPhase(true)).apply(graph, context); } } diff -r d8a8d794f631 -r 491cd7d69539 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java Thu Jun 06 20:02:12 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PEAReadEliminationTest.java Thu Jun 06 16:30:41 2013 +0200 @@ -222,8 +222,8 @@ private void processMethod(final String snippet) { graph = parse(snippet); Assumptions assumptions = new Assumptions(false); - HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, new CanonicalizerPhase(true)); + HighTierContext context = new HighTierContext(runtime(), assumptions, replacements); new InliningPhase(runtime(), null, replacements, assumptions, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(graph); - new PartialEscapeAnalysisPhase(false, true).apply(graph, context); + new PartialEscapeAnalysisPhase(false, true, new CanonicalizerPhase(true)).apply(graph, context); } } diff -r d8a8d794f631 -r 491cd7d69539 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PartialEscapeAnalysisTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PartialEscapeAnalysisTest.java Thu Jun 06 20:02:12 2013 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/PartialEscapeAnalysisTest.java Thu Jun 06 16:30:41 2013 +0200 @@ -161,15 +161,16 @@ StructuredGraph graph = parse(snippet); Assumptions assumptions = new Assumptions(false); - HighTierContext context = new HighTierContext(runtime(), assumptions, replacements, new CanonicalizerPhase(true)); + HighTierContext context = new HighTierContext(runtime(), assumptions, replacements); new InliningPhase(runtime(), null, replacements, assumptions, null, getDefaultPhasePlan(), OptimisticOptimizations.ALL).apply(graph); new DeadCodeEliminationPhase().apply(graph); - context.applyCanonicalizer(graph); - new PartialEscapeAnalysisPhase(false, false).apply(graph, context); + CanonicalizerPhase canonicalizer = new CanonicalizerPhase(true); + canonicalizer.apply(graph, context); + new PartialEscapeAnalysisPhase(false, false, canonicalizer).apply(graph, context); new CullFrameStatesPhase().apply(graph); new DeadCodeEliminationPhase().apply(graph); - context.applyCanonicalizer(graph); + canonicalizer.apply(graph, context); return graph; } }); diff -r d8a8d794f631 -r 491cd7d69539 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Thu Jun 06 20:02:12 2013 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Thu Jun 06 16:30:41 2013 +0200 @@ -141,21 +141,21 @@ } CanonicalizerPhase canonicalizer = new CanonicalizerPhase(OptCanonicalizeReads.getValue()); - HighTierContext highTierContext = new HighTierContext(runtime, assumptions, replacements, canonicalizer); + HighTierContext highTierContext = new HighTierContext(runtime, assumptions, replacements); if (OptCanonicalizer.getValue()) { - highTierContext.applyCanonicalizer(graph); + canonicalizer.apply(graph, highTierContext); } if (Inline.getValue() && !plan.isPhaseDisabled(InliningPhase.class)) { if (IterativeInlining.getValue()) { - new IterativeInliningPhase(replacements, cache, plan, optimisticOpts, OptEarlyReadElimination.getValue()).apply(graph, highTierContext); + new IterativeInliningPhase(replacements, cache, plan, optimisticOpts, OptEarlyReadElimination.getValue(), canonicalizer).apply(graph, highTierContext); } else { new InliningPhase(runtime, null, replacements, assumptions, cache, plan, optimisticOpts).apply(graph); new DeadCodeEliminationPhase().apply(graph); if (ConditionalElimination.getValue() && OptCanonicalizer.getValue()) { - highTierContext.applyCanonicalizer(graph); + canonicalizer.apply(graph, highTierContext); new IterativeConditionalEliminationPhase().apply(graph, highTierContext); } } @@ -165,12 +165,12 @@ plan.runPhases(PhasePosition.HIGH_LEVEL, graph); Suites.DEFAULT.getHighTier().apply(graph, highTierContext); - MidTierContext midTierContext = new MidTierContext(runtime, assumptions, replacements, canonicalizer, target, optimisticOpts); + MidTierContext midTierContext = new MidTierContext(runtime, assumptions, replacements, target, optimisticOpts); Suites.DEFAULT.getMidTier().apply(graph, midTierContext); plan.runPhases(PhasePosition.LOW_LEVEL, graph); - LowTierContext lowTierContext = new LowTierContext(runtime, assumptions, replacements, canonicalizer, target); + LowTierContext lowTierContext = new LowTierContext(runtime, assumptions, replacements, target); Suites.DEFAULT.getLowTier().apply(graph, lowTierContext); InliningPhase.storeStatisticsAfterLowTier(graph); diff -r d8a8d794f631 -r 491cd7d69539 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java Thu Jun 06 20:02:12 2013 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java Thu Jun 06 16:30:41 2013 +0200 @@ -34,6 +34,8 @@ public class HighTier extends PhaseSuite { public HighTier() { + CanonicalizerPhase canonicalizer = new CanonicalizerPhase(OptCanonicalizeReads.getValue()); + if (FullUnroll.getValue()) { addPhase(new LoopFullUnrollPhase()); } @@ -43,7 +45,7 @@ } if (PartialEscapeAnalysis.getValue()) { - addPhase(new PartialEscapeAnalysisPhase(true, OptEarlyReadElimination.getValue())); + addPhase(new PartialEscapeAnalysisPhase(true, OptEarlyReadElimination.getValue(), canonicalizer)); } if (OptConvertDeoptsToGuards.getValue()) { @@ -63,10 +65,9 @@ } if (OptCanonicalizer.getValue()) { - addPhase(new CanonicalizerPhase.Context()); + addPhase(canonicalizer); } addPhase(new LoweringPhase(LoweringType.BEFORE_GUARDS)); } - } diff -r d8a8d794f631 -r 491cd7d69539 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/MidTier.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/MidTier.java Thu Jun 06 20:02:12 2013 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/MidTier.java Thu Jun 06 16:30:41 2013 +0200 @@ -32,17 +32,19 @@ public class MidTier extends PhaseSuite { public MidTier() { + CanonicalizerPhase canonicalizer = new CanonicalizerPhase(OptCanonicalizeReads.getValue()); + if (OptPushThroughPi.getValue()) { addPhase(new PushThroughPiPhase()); if (OptCanonicalizer.getValue()) { - addPhase(new CanonicalizerPhase.Context()); + addPhase(canonicalizer); } } if (OptFloatingReads.getValue()) { - IncrementalCanonicalizerPhase canonicalizer = new IncrementalCanonicalizerPhase<>(); - canonicalizer.addPhase(new FloatingReadPhase()); - addPhase(canonicalizer); + IncrementalCanonicalizerPhase incCanonicalizer = new IncrementalCanonicalizerPhase<>(); + incCanonicalizer.addPhase(new FloatingReadPhase()); + addPhase(incCanonicalizer); if (OptReadElimination.getValue()) { addPhase(new ReadEliminationPhase()); } @@ -50,7 +52,7 @@ addPhase(new RemoveValueProxyPhase()); if (OptCanonicalizer.getValue()) { - addPhase(new CanonicalizerPhase.Context()); + addPhase(canonicalizer); } if (OptEliminatePartiallyRedundantGuards.getValue()) { @@ -66,7 +68,7 @@ } if (OptCanonicalizer.getValue()) { - addPhase(new CanonicalizerPhase.Context()); + addPhase(canonicalizer); } addPhase(new LoopSafepointEliminationPhase()); @@ -76,7 +78,7 @@ addPhase(new GuardLoweringPhase()); if (OptCanonicalizer.getValue()) { - addPhase(new CanonicalizerPhase.Context()); + addPhase(canonicalizer); } } } diff -r d8a8d794f631 -r 491cd7d69539 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java Thu Jun 06 20:02:12 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/replacements/ArrayCopyNode.java Thu Jun 06 16:30:41 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(true)); - context.applyCanonicalizer(snippetGraph); + HighTierContext context = new HighTierContext(tool.getRuntime(), tool.assumptions(), tool.getReplacements()); + new CanonicalizerPhase(true).apply(snippetGraph, context); new LoopFullUnrollPhase().apply(snippetGraph, context); - context.applyCanonicalizer(snippetGraph); + new CanonicalizerPhase(true).apply(snippetGraph, context); } @Override diff -r d8a8d794f631 -r 491cd7d69539 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java Thu Jun 06 20:02:12 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/CanonicalizerPhase.java Thu Jun 06 16:30:41 2013 +0200 @@ -359,12 +359,4 @@ } } } - - public static class Context extends BasePhase { - - @Override - protected void run(StructuredGraph graph, PhaseContext context) { - context.applyCanonicalizer(graph); - } - } } diff -r d8a8d794f631 -r 491cd7d69539 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Thu Jun 06 20:02:12 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java Thu Jun 06 16:30:41 2013 +0200 @@ -690,8 +690,7 @@ 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, - new CanonicalizerPhase(OptCanonicalizeReads.getValue()))); + TailDuplicationPhase.tailDuplicate(returnMerge, TailDuplicationPhase.TRUE_DECISION, replacementNodes, new HighTierContext(runtime, assumptions, replacements)); } } } diff -r d8a8d794f631 -r 491cd7d69539 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/HighTierContext.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/HighTierContext.java Thu Jun 06 20:02:12 2013 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/HighTierContext.java Thu Jun 06 16:30:41 2013 +0200 @@ -25,11 +25,10 @@ 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, BasePhase canonicalizer) { - super(runtime, assumptions, replacements, canonicalizer); + public HighTierContext(MetaAccessProvider runtime, Assumptions assumptions, Replacements replacements) { + super(runtime, assumptions, replacements); } } diff -r d8a8d794f631 -r 491cd7d69539 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/LowTierContext.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/LowTierContext.java Thu Jun 06 20:02:12 2013 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/LowTierContext.java Thu Jun 06 16:30:41 2013 +0200 @@ -25,14 +25,13 @@ 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, BasePhase canonicalizer, TargetDescription target) { - super(runtime, assumptions, replacements, canonicalizer); + public LowTierContext(MetaAccessProvider runtime, Assumptions assumptions, Replacements replacements, TargetDescription target) { + super(runtime, assumptions, replacements); this.target = target; } diff -r d8a8d794f631 -r 491cd7d69539 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/MidTierContext.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/MidTierContext.java Thu Jun 06 20:02:12 2013 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/MidTierContext.java Thu Jun 06 16:30:41 2013 +0200 @@ -32,9 +32,8 @@ private final TargetDescription target; private final OptimisticOptimizations optimisticOpts; - public MidTierContext(MetaAccessProvider runtime, Assumptions assumptions, Replacements replacements, BasePhase canonicalizer, TargetDescription target, - OptimisticOptimizations optimisticOpts) { - super(runtime, assumptions, replacements, canonicalizer); + public MidTierContext(MetaAccessProvider runtime, Assumptions assumptions, Replacements replacements, TargetDescription target, OptimisticOptimizations optimisticOpts) { + super(runtime, assumptions, replacements); this.target = target; this.optimisticOpts = optimisticOpts; } diff -r d8a8d794f631 -r 491cd7d69539 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/PhaseContext.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/PhaseContext.java Thu Jun 06 20:02:12 2013 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/PhaseContext.java Thu Jun 06 16:30:41 2013 +0200 @@ -24,22 +24,18 @@ 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 canonicalizer; - public PhaseContext(MetaAccessProvider runtime, Assumptions assumptions, Replacements replacements, BasePhase canonicalizer) { + public PhaseContext(MetaAccessProvider runtime, Assumptions assumptions, Replacements replacements) { this.runtime = runtime; this.assumptions = assumptions; this.replacements = replacements; - this.canonicalizer = canonicalizer; } public MetaAccessProvider getRuntime() { @@ -53,12 +49,4 @@ public Replacements getReplacements() { return replacements; } - - private BasePhase getCanonicalizer() { - return canonicalizer; - } - - public void applyCanonicalizer(StructuredGraph graph) { - getCanonicalizer().apply(graph, this); - } } diff -r d8a8d794f631 -r 491cd7d69539 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/IterativeInliningPhase.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/IterativeInliningPhase.java Thu Jun 06 20:02:12 2013 +0200 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/IterativeInliningPhase.java Thu Jun 06 16:30:41 2013 +0200 @@ -42,13 +42,15 @@ private final GraphCache cache; private final OptimisticOptimizations optimisticOpts; private final boolean readElimination; + private final CanonicalizerPhase canonicalizer; - public IterativeInliningPhase(Replacements replacements, GraphCache cache, PhasePlan plan, OptimisticOptimizations optimisticOpts, boolean readElimination) { + public IterativeInliningPhase(Replacements replacements, GraphCache cache, PhasePlan plan, OptimisticOptimizations optimisticOpts, boolean readElimination, CanonicalizerPhase canonicalizer) { this.replacements = replacements; this.cache = cache; this.plan = plan; this.optimisticOpts = optimisticOpts; this.readElimination = readElimination; + this.canonicalizer = canonicalizer; } public static final void trace(String format, Object... obj) { @@ -71,7 +73,7 @@ @Override public Boolean call() { boolean progress = false; - PartialEscapeAnalysisPhase ea = new PartialEscapeAnalysisPhase(false, readElimination); + PartialEscapeAnalysisPhase ea = new PartialEscapeAnalysisPhase(false, readElimination, canonicalizer); boolean eaResult = ea.runAnalysis(graph, context); progress |= eaResult; @@ -85,7 +87,7 @@ new DeadCodeEliminationPhase().apply(graph); if (ConditionalElimination.getValue() && OptCanonicalizer.getValue()) { - context.applyCanonicalizer(graph); + canonicalizer.apply(graph, context); new IterativeConditionalEliminationPhase().apply(graph, context); } diff -r d8a8d794f631 -r 491cd7d69539 graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeAnalysisPhase.java --- a/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeAnalysisPhase.java Thu Jun 06 20:02:12 2013 +0200 +++ b/graal/com.oracle.graal.virtual/src/com/oracle/graal/virtual/phases/ea/PartialEscapeAnalysisPhase.java Thu Jun 06 16:30:41 2013 +0200 @@ -51,10 +51,12 @@ private final boolean iterative; private final boolean readElimination; + private final CanonicalizerPhase canonicalizer; - public PartialEscapeAnalysisPhase(boolean iterative, boolean readElimination) { + public PartialEscapeAnalysisPhase(boolean iterative, boolean readElimination, CanonicalizerPhase canonicalizer) { this.iterative = iterative; this.readElimination = readElimination; + this.canonicalizer = canonicalizer; } @Override @@ -105,7 +107,7 @@ new DeadCodeEliminationPhase().apply(graph); if (OptCanonicalizer.getValue()) { - context.applyCanonicalizer(graph); + canonicalizer.apply(graph, context); } return true;