# HG changeset patch # User Bernhard Urban # Date 1371045882 -7200 # Node ID b5c87b5c6e9c74c00fe84b4d57beb3369f05379e # Parent 03b822ee729e4344a5e552905a59d0b4e381255e add option to enable ahead of time compilation for hotspot (GRAAL-290) diff -r 03b822ee729e -r b5c87b5c6e9c 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 Wed Jun 12 16:04:41 2013 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Wed Jun 12 16:04:42 2013 +0200 @@ -141,7 +141,7 @@ new VerifyUsageWithEquals(runtime, Register.class).apply(graph); } - CanonicalizerPhase canonicalizer = new CanonicalizerPhase(OptCanonicalizeReads.getValue()); + CanonicalizerPhase canonicalizer = new CanonicalizerPhase(!AOTCompilation.getValue()); HighTierContext highTierContext = new HighTierContext(runtime, assumptions, replacements); if (OptCanonicalizer.getValue()) { diff -r 03b822ee729e -r b5c87b5c6e9c 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 Wed Jun 12 16:04:41 2013 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/HighTier.java Wed Jun 12 16:04:42 2013 +0200 @@ -34,10 +34,10 @@ public class HighTier extends PhaseSuite { public HighTier() { - CanonicalizerPhase canonicalizer = new CanonicalizerPhase(OptCanonicalizeReads.getValue()); + CanonicalizerPhase canonicalizer = new CanonicalizerPhase(!AOTCompilation.getValue()); if (FullUnroll.getValue()) { - addPhase(new LoopFullUnrollPhase(OptCanonicalizeReads.getValue())); + addPhase(new LoopFullUnrollPhase(!AOTCompilation.getValue())); } if (OptTailDuplication.getValue()) { diff -r 03b822ee729e -r b5c87b5c6e9c 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 Wed Jun 12 16:04:41 2013 +0200 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/MidTier.java Wed Jun 12 16:04:42 2013 +0200 @@ -32,7 +32,7 @@ public class MidTier extends PhaseSuite { public MidTier() { - CanonicalizerPhase canonicalizer = new CanonicalizerPhase(OptCanonicalizeReads.getValue()); + CanonicalizerPhase canonicalizer = new CanonicalizerPhase(!AOTCompilation.getValue()); if (OptPushThroughPi.getValue()) { addPhase(new PushThroughPiPhase()); diff -r 03b822ee729e -r b5c87b5c6e9c graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java Wed Jun 12 16:04:41 2013 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java Wed Jun 12 16:04:42 2013 +0200 @@ -109,8 +109,8 @@ StructuredGraph graph = parse(test); ResolvedJavaMethod method = graph.method(); - boolean originalSetting = OptCanonicalizeReads.getValue(); - OptCanonicalizeReads.setValue(!compileAOT); + boolean originalSetting = AOTCompilation.getValue(); + AOTCompilation.setValue(compileAOT); PhasePlan phasePlan = new PhasePlan(); final StructuredGraph graphCopy = graph.copy(); GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL); @@ -119,14 +119,11 @@ CallingConvention cc = getCallingConvention(runtime, Type.JavaCallee, graph.method(), false); // create suites everytime, as we modify options for the compiler final Suites suitesLocal = Graal.getRequiredCapability(SuitesProvider.class).createSuites(); - if (compileAOT) { - suitesLocal.getHighTier().addPhase(new LoadJavaMirrorWithKlassPhase()); - } final CompilationResult compResult = GraalCompiler.compileGraph(graph, cc, method, runtime, replacements, backend, runtime().getTarget(), null, phasePlan, OptimisticOptimizations.ALL, new SpeculationLog(), suitesLocal); addMethod(method, compResult, graphCopy); - OptCanonicalizeReads.setValue(originalSetting); + AOTCompilation.setValue(originalSetting); return graph; } diff -r 03b822ee729e -r b5c87b5c6e9c graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Wed Jun 12 16:04:41 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Wed Jun 12 16:04:42 2013 +0200 @@ -1073,6 +1073,11 @@ public Suites createSuites() { Suites ret = Suites.createDefaultSuites(); + if (AOTCompilation.getValue()) { + // lowering introduces class constants, therefore it must be after lowering + ret.getHighTier().addPhase(new LoadJavaMirrorWithKlassPhase()); + } + ret.getMidTier().addPhase(new WriteBarrierAdditionPhase()); if (VerifyPhases.getValue()) { ret.getMidTier().addPhase(new WriteBarrierVerificationPhase()); diff -r 03b822ee729e -r b5c87b5c6e9c graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/IncrementalCanonicalizerPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/IncrementalCanonicalizerPhase.java Wed Jun 12 16:04:41 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/IncrementalCanonicalizerPhase.java Wed Jun 12 16:04:42 2013 +0200 @@ -45,6 +45,6 @@ protected void run(StructuredGraph graph, C context) { int mark = graph.getMark(); super.run(graph, context); - new CanonicalizerPhase.Instance(context.getRuntime(), context.getAssumptions(), OptCanonicalizeReads.getValue(), mark, customCanonicalizer).apply(graph); + new CanonicalizerPhase.Instance(context.getRuntime(), context.getAssumptions(), !AOTCompilation.getValue(), mark, customCanonicalizer).apply(graph); } } diff -r 03b822ee729e -r b5c87b5c6e9c graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java Wed Jun 12 16:04:41 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningPhase.java Wed Jun 12 16:04:42 2013 +0200 @@ -195,7 +195,7 @@ if (OptCanonicalizer.getValue()) { int markBeforeCanonicalization = callerGraph.getMark(); - new CanonicalizerPhase.Instance(runtime, callerAssumptions, OptCanonicalizeReads.getValue(), invokeUsages, markBeforeInlining, customCanonicalizer).apply(callerGraph); + new CanonicalizerPhase.Instance(runtime, callerAssumptions, !AOTCompilation.getValue(), invokeUsages, markBeforeInlining, customCanonicalizer).apply(callerGraph); // process invokes that are possibly created during canonicalization for (Node newNode : callerGraph.getNewNodes(markBeforeCanonicalization)) { @@ -280,7 +280,7 @@ } if (OptCanonicalizer.getValue()) { - new CanonicalizerPhase.Instance(runtime, assumptions, OptCanonicalizeReads.getValue()).apply(newGraph); + new CanonicalizerPhase.Instance(runtime, assumptions, !AOTCompilation.getValue()).apply(newGraph); } return newGraph; @@ -309,7 +309,7 @@ new DeadCodeEliminationPhase().apply(newGraph); if (OptCanonicalizer.getValue()) { - new CanonicalizerPhase.Instance(runtime, assumptions, OptCanonicalizeReads.getValue()).apply(newGraph); + new CanonicalizerPhase.Instance(runtime, assumptions, !AOTCompilation.getValue()).apply(newGraph); } if (CullFrameStates.getValue()) { diff -r 03b822ee729e -r b5c87b5c6e9c graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/IterativeConditionalEliminationPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/IterativeConditionalEliminationPhase.java Wed Jun 12 16:04:41 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/IterativeConditionalEliminationPhase.java Wed Jun 12 16:04:42 2013 +0200 @@ -46,7 +46,7 @@ if (canonicalizationRoots.isEmpty()) { break; } - new CanonicalizerPhase.Instance(context.getRuntime(), context.getAssumptions(), OptCanonicalizeReads.getValue(), canonicalizationRoots, null).apply(graph); + new CanonicalizerPhase.Instance(context.getRuntime(), context.getAssumptions(), !AOTCompilation.getValue(), canonicalizationRoots, null).apply(graph); canonicalizationRoots.clear(); } } diff -r 03b822ee729e -r b5c87b5c6e9c graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java Wed Jun 12 16:04:41 2013 +0200 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/TailDuplicationPhase.java Wed Jun 12 16:04:42 2013 +0200 @@ -300,7 +300,7 @@ phi.setMerge(mergeAfter); } } - new CanonicalizerPhase.Instance(phaseContext.getRuntime(), phaseContext.getAssumptions(), OptCanonicalizeReads.getValue(), graph.getNewNodes(startMark), null).apply(graph); + new CanonicalizerPhase.Instance(phaseContext.getRuntime(), phaseContext.getAssumptions(), !AOTCompilation.getValue(), graph.getNewNodes(startMark), null).apply(graph); Debug.dump(graph, "After tail duplication at %s", merge); } diff -r 03b822ee729e -r b5c87b5c6e9c graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java Wed Jun 12 16:04:41 2013 +0200 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/GraalOptions.java Wed Jun 12 16:04:42 2013 +0200 @@ -241,6 +241,10 @@ @Option(help = "") public static final OptionValue MinTableSwitchDensity = new OptionValue<>(0.5); + // Ahead of time compilation + @Option(help = "configure compiler to emit code compatible with AOT requirements for HotSpot") + public static final OptionValue AOTCompilation = new OptionValue<>(false); + // Runtime settings @Option(help = "") public static final OptionValue StackShadowPages = new OptionValue<>(2); @@ -257,8 +261,6 @@ @Option(help = "") public static final OptionValue OptCanonicalizer = new OptionValue<>(true); @Option(help = "") - public static final OptionValue OptCanonicalizeReads = new OptionValue<>(true); - @Option(help = "") public static final OptionValue OptScheduleOutOfLoops = new OptionValue<>(true); @Option(help = "") public static final OptionValue OptEliminateGuards = new OptionValue<>(true);