# HG changeset patch # User Josef Eisl # Date 1423667330 -3600 # Node ID 313f9a9647e5eca8377774be6c8dd597881dbcd3 # Parent ab81848b92642becc39ed65107ae7d25cfe832f1# Parent fdb93d2ed5c810018dcf1822373a3ddc79700af4 Merge (rename LowLevel{Phases,..} to LIR{Phases,..}) diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java --- a/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.baseline/src/com/oracle/graal/baseline/BaselineBytecodeParser.java Wed Feb 11 16:08:50 2015 +0100 @@ -145,9 +145,9 @@ throw Debug.handle(e); } - try (Scope s = Debug.scope("LowLevelTier", this)) { - LowLevelSuites lowLevelSuites = backend.getSuites().getDefaultLowLevelSuites(); - return GraalCompiler.emitLowLevel(target, codeEmittingOrder, linearScanOrder, lirGenRes, gen, lowLevelSuites); + try (Scope s = Debug.scope("LIRTier", this)) { + LIRSuites lirSuites = backend.getSuites().getDefaultLIRSuites(); + return GraalCompiler.emitLowLevel(target, codeEmittingOrder, linearScanOrder, lirGenRes, gen, lirSuites); } catch (Throwable e) { throw Debug.handle(e); } diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Wed Feb 11 16:08:50 2015 +0100 @@ -91,7 +91,7 @@ private final Providers providers; private final Backend backend; private final DerivedOptionValue suites; - private final DerivedOptionValue lowLevelSuites; + private final DerivedOptionValue lirSuites; /** * Can be overridden by unit tests to verify properties of the graph. @@ -167,8 +167,8 @@ return ret; } - protected LowLevelSuites createLowLevelSuites() { - LowLevelSuites ret = backend.getSuites().createLowLevelSuites(); + protected LIRSuites createLIRSuites() { + LIRSuites ret = backend.getSuites().createLIRSuites(); return ret; } @@ -176,7 +176,7 @@ this.backend = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend(); this.providers = getBackend().getProviders(); this.suites = new DerivedOptionValue<>(this::createSuites); - this.lowLevelSuites = new DerivedOptionValue<>(this::createLowLevelSuites); + this.lirSuites = new DerivedOptionValue<>(this::createLIRSuites); installSubstitutions(); } @@ -197,7 +197,7 @@ } this.providers = backend.getProviders(); this.suites = new DerivedOptionValue<>(this::createSuites); - this.lowLevelSuites = new DerivedOptionValue<>(this::createLowLevelSuites); + this.lirSuites = new DerivedOptionValue<>(this::createLIRSuites); installSubstitutions(); } @@ -365,8 +365,8 @@ return suites.getValue(); } - protected LowLevelSuites getLowLevelSuites() { - return lowLevelSuites.getValue(); + protected LIRSuites getLIRSuites() { + return lirSuites.getValue(); } protected Providers getProviders() { @@ -755,7 +755,7 @@ lastCompiledGraph = graphToCompile; CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graphToCompile.method(), false); Request request = new Request<>(graphToCompile, cc, installedCodeOwner, getProviders(), getBackend(), getCodeCache().getTarget(), null, getDefaultGraphBuilderSuite(), - OptimisticOptimizations.ALL, getProfilingInfo(graphToCompile), getSpeculationLog(), getSuites(), getLowLevelSuites(), new CompilationResult(), + OptimisticOptimizations.ALL, getProfilingInfo(graphToCompile), getSpeculationLog(), getSuites(), getLIRSuites(), new CompilationResult(), CompilationResultBuilderFactory.Default); return GraalCompiler.compile(request); } diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java Wed Feb 11 16:08:50 2015 +0100 @@ -63,7 +63,7 @@ final StructuredGraph graph = parseEager(method, ALLOW_OPTIMISTIC_ASSUMPTIONS); CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); final CompilationResult cr = compileGraph(graph, cc, graph.method(), getProviders(), getBackend(), getCodeCache().getTarget(), null, getDefaultGraphBuilderSuite(), - OptimisticOptimizations.ALL, getProfilingInfo(graph), null, getSuites(), getLowLevelSuites(), new CompilationResult(), CompilationResultBuilderFactory.Default); + OptimisticOptimizations.ALL, getProfilingInfo(graph), null, getSuites(), getLIRSuites(), new CompilationResult(), CompilationResultBuilderFactory.Default); for (Infopoint sp : cr.getInfopoints()) { assertNotNull(sp.reason); if (sp instanceof Call) { @@ -86,7 +86,7 @@ CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); PhaseSuite graphBuilderSuite = getCustomGraphBuilderSuite(GraphBuilderConfiguration.getFullDebugDefault()); final CompilationResult cr = compileGraph(graph, cc, graph.method(), getProviders(), getBackend(), getCodeCache().getTarget(), null, graphBuilderSuite, OptimisticOptimizations.ALL, - getProfilingInfo(graph), getSpeculationLog(), getSuites(), getLowLevelSuites(), new CompilationResult(), CompilationResultBuilderFactory.Default); + getProfilingInfo(graph), getSpeculationLog(), getSuites(), getLIRSuites(), new CompilationResult(), CompilationResultBuilderFactory.Default); int lineSPs = 0; for (Infopoint sp : cr.getInfopoints()) { assertNotNull(sp.reason); diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/BackendTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/BackendTest.java Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/backend/BackendTest.java Wed Feb 11 16:08:50 2015 +0100 @@ -54,7 +54,7 @@ } CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); - LIRGenerationResult lirGen = GraalCompiler.emitLIR(getBackend(), getBackend().getTarget(), schedule, graph, null, cc, null, getLowLevelSuites()); + LIRGenerationResult lirGen = GraalCompiler.emitLIR(getBackend(), getBackend().getTarget(), schedule, graph, null, cc, null, getLIRSuites()); return lirGen; } diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/tutorial/InvokeGraal.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/tutorial/InvokeGraal.java Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/tutorial/InvokeGraal.java Wed Feb 11 16:08:50 2015 +0100 @@ -101,7 +101,7 @@ /* * The low-level phases that are applied to the low-level representation. */ - LowLevelSuites lowLevelSuites = backend.getSuites().createLowLevelSuites(); + LIRSuites lirSuites = backend.getSuites().createLIRSuites(); /* * The calling convention for the machine code. You should have a very good reason @@ -127,7 +127,7 @@ SpeculationLog speculationLog = null; /* Invoke the whole Graal compilation pipeline. */ - GraalCompiler.compileGraph(graph, callingConvention, method, providers, backend, target, cache, graphBuilderSuite, optimisticOpts, profilingInfo, speculationLog, suites, lowLevelSuites, + GraalCompiler.compileGraph(graph, callingConvention, method, providers, backend, target, cache, graphBuilderSuite, optimisticOpts, profilingInfo, speculationLog, suites, lirSuites, compilationResult, factory); /* diff -r fdb93d2ed5c8 -r 313f9a9647e5 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 Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Wed Feb 11 16:08:50 2015 +0100 @@ -44,9 +44,9 @@ import com.oracle.graal.lir.framemap.*; import com.oracle.graal.lir.gen.*; import com.oracle.graal.lir.phases.*; -import com.oracle.graal.lir.phases.LowLevelHighTierPhase.LowLevelHighTierContext; -import com.oracle.graal.lir.phases.LowLevelLowTierPhase.LowLevelLowTierContext; -import com.oracle.graal.lir.phases.LowLevelMidTierPhase.LowLevelMidTierContext; +import com.oracle.graal.lir.phases.LIRHighTierPhase.LIRHighTierContext; +import com.oracle.graal.lir.phases.LIRLowTierPhase.LIRLowTierContext; +import com.oracle.graal.lir.phases.LIRMidTierPhase.LIRMidTierContext; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.cfg.*; import com.oracle.graal.nodes.spi.*; @@ -143,7 +143,7 @@ public final ProfilingInfo profilingInfo; public final SpeculationLog speculationLog; public final Suites suites; - public final LowLevelSuites lowLevelSuites; + public final LIRSuites lirSuites; public final T compilationResult; public final CompilationResultBuilderFactory factory; @@ -161,13 +161,13 @@ * @param profilingInfo * @param speculationLog * @param suites - * @param lowLevelSuites + * @param lirSuites * @param compilationResult * @param factory */ public Request(StructuredGraph graph, CallingConvention cc, ResolvedJavaMethod installedCodeOwner, Providers providers, Backend backend, TargetDescription target, Map cache, PhaseSuite graphBuilderSuite, OptimisticOptimizations optimisticOpts, ProfilingInfo profilingInfo, - SpeculationLog speculationLog, Suites suites, LowLevelSuites lowLevelSuites, T compilationResult, CompilationResultBuilderFactory factory) { + SpeculationLog speculationLog, Suites suites, LIRSuites lirSuites, T compilationResult, CompilationResultBuilderFactory factory) { this.graph = graph; this.cc = cc; this.installedCodeOwner = installedCodeOwner; @@ -180,7 +180,7 @@ this.profilingInfo = profilingInfo; this.speculationLog = speculationLog; this.suites = suites; - this.lowLevelSuites = lowLevelSuites; + this.lirSuites = lirSuites; this.compilationResult = compilationResult; this.factory = factory; } @@ -206,8 +206,8 @@ */ public static T compileGraph(StructuredGraph graph, CallingConvention cc, ResolvedJavaMethod installedCodeOwner, Providers providers, Backend backend, TargetDescription target, Map cache, PhaseSuite graphBuilderSuite, OptimisticOptimizations optimisticOpts, - ProfilingInfo profilingInfo, SpeculationLog speculationLog, Suites suites, LowLevelSuites lowLevelSuites, T compilationResult, CompilationResultBuilderFactory factory) { - return compile(new Request<>(graph, cc, installedCodeOwner, providers, backend, target, cache, graphBuilderSuite, optimisticOpts, profilingInfo, speculationLog, suites, lowLevelSuites, + ProfilingInfo profilingInfo, SpeculationLog speculationLog, Suites suites, LIRSuites lirSuites, T compilationResult, CompilationResultBuilderFactory factory) { + return compile(new Request<>(graph, cc, installedCodeOwner, providers, backend, target, cache, graphBuilderSuite, optimisticOpts, profilingInfo, speculationLog, suites, lirSuites, compilationResult, factory)); } @@ -220,7 +220,7 @@ assert !r.graph.isFrozen(); try (Scope s0 = Debug.scope("GraalCompiler", r.graph, r.providers.getCodeCache())) { SchedulePhase schedule = emitFrontEnd(r.providers, r.target, r.graph, r.cache, r.graphBuilderSuite, r.optimisticOpts, r.profilingInfo, r.speculationLog, r.suites); - emitBackEnd(r.graph, null, r.cc, r.installedCodeOwner, r.backend, r.target, r.compilationResult, r.factory, schedule, null, r.lowLevelSuites); + emitBackEnd(r.graph, null, r.cc, r.installedCodeOwner, r.backend, r.target, r.compilationResult, r.factory, schedule, null, r.lirSuites); } catch (Throwable e) { throw Debug.handle(e); } @@ -274,10 +274,10 @@ } public static void emitBackEnd(StructuredGraph graph, Object stub, CallingConvention cc, ResolvedJavaMethod installedCodeOwner, Backend backend, - TargetDescription target, T compilationResult, CompilationResultBuilderFactory factory, SchedulePhase schedule, RegisterConfig registerConfig, LowLevelSuites lowLevelSuites) { + TargetDescription target, T compilationResult, CompilationResultBuilderFactory factory, SchedulePhase schedule, RegisterConfig registerConfig, LIRSuites lirSuites) { try (TimerCloseable a = BackEnd.start()) { LIRGenerationResult lirGen = null; - lirGen = emitLIR(backend, target, schedule, graph, stub, cc, registerConfig, lowLevelSuites); + lirGen = emitLIR(backend, target, schedule, graph, stub, cc, registerConfig, lirSuites); try (Scope s = Debug.scope("CodeGen", lirGen, lirGen.getLIR())) { emitCode(backend, graph.getAssumptions(), lirGen, compilationResult, installedCodeOwner, factory); } catch (Throwable e) { @@ -300,7 +300,7 @@ } public static LIRGenerationResult emitLIR(Backend backend, TargetDescription target, SchedulePhase schedule, StructuredGraph graph, Object stub, CallingConvention cc, - RegisterConfig registerConfig, LowLevelSuites lowLevelSuites) { + RegisterConfig registerConfig, LIRSuites lirSuites) { List blocks = schedule.getCFG().getBlocks(); Block startBlock = schedule.getCFG().getStartBlock(); assert startBlock != null; @@ -339,8 +339,8 @@ throw Debug.handle(e); } - try (Scope s = Debug.scope("LowLevelTier", nodeLirGen)) { - return emitLowLevel(target, codeEmittingOrder, linearScanOrder, lirGenRes, lirGen, lowLevelSuites); + try (Scope s = Debug.scope("LIRTier", nodeLirGen)) { + return emitLowLevel(target, codeEmittingOrder, linearScanOrder, lirGenRes, lirGen, lirSuites); } catch (Throwable e) { throw Debug.handle(e); } @@ -350,15 +350,15 @@ } public static > LIRGenerationResult emitLowLevel(TargetDescription target, List codeEmittingOrder, List linearScanOrder, LIRGenerationResult lirGenRes, - LIRGeneratorTool lirGen, LowLevelSuites lowLevelSuites) { - LowLevelHighTierContext highTierContext = new LowLevelHighTierContext(lirGen); - lowLevelSuites.getHighTier().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, highTierContext); + LIRGeneratorTool lirGen, LIRSuites lirSuites) { + LIRHighTierContext highTierContext = new LIRHighTierContext(lirGen); + lirSuites.getHighTier().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, highTierContext); - LowLevelMidTierContext midTierContext = new LowLevelMidTierContext(); - lowLevelSuites.getMidTier().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, midTierContext); + LIRMidTierContext midTierContext = new LIRMidTierContext(); + lirSuites.getMidTier().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, midTierContext); - LowLevelLowTierContext lowTierContext = new LowLevelLowTierContext(); - lowLevelSuites.getLowTier().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, lowTierContext); + LIRLowTierContext lowTierContext = new LIRLowTierContext(); + lirSuites.getLowTier().apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, lowTierContext); return lirGenRes; } diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/BasicCompilerConfiguration.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/BasicCompilerConfiguration.java Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/phases/BasicCompilerConfiguration.java Wed Feb 11 16:08:50 2015 +0100 @@ -24,9 +24,9 @@ import com.oracle.graal.api.runtime.*; import com.oracle.graal.lir.phases.*; -import com.oracle.graal.lir.phases.LowLevelHighTierPhase.*; -import com.oracle.graal.lir.phases.LowLevelLowTierPhase.*; -import com.oracle.graal.lir.phases.LowLevelMidTierPhase.*; +import com.oracle.graal.lir.phases.LIRHighTierPhase.*; +import com.oracle.graal.lir.phases.LIRLowTierPhase.*; +import com.oracle.graal.lir.phases.LIRMidTierPhase.*; import com.oracle.graal.phases.*; import com.oracle.graal.phases.tiers.*; @@ -45,16 +45,16 @@ return new LowTier(); } - public LowLevelPhaseSuite createLowLevelHighTier() { - return new LowLevelHighTier(); + public LIRPhaseSuite createLIRHighTier() { + return new LIRHighTier(); } - public LowLevelPhaseSuite createLowLevelMidTier() { - return new LowLevelMidTier(); + public LIRPhaseSuite createLIRMidTier() { + return new LIRMidTier(); } - public LowLevelPhaseSuite createLowLevelLowTier() { - return new LowLevelLowTier(); + public LIRPhaseSuite createLIRLowTier() { + return new LIRLowTier(); } } diff -r fdb93d2ed5c8 -r 313f9a9647e5 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 Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/AheadOfTimeCompilationTest.java Wed Feb 11 16:08:50 2015 +0100 @@ -213,9 +213,9 @@ // create suites everytime, as we modify options for the compiler SuitesProvider suitesProvider = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getSuites(); final Suites suitesLocal = suitesProvider.createSuites(); - final LowLevelSuites lowLevelSuitesLocal = suitesProvider.createLowLevelSuites(); + final LIRSuites lirSuitesLocal = suitesProvider.createLIRSuites(); final CompilationResult compResult = compileGraph(graph, cc, method, getProviders(), getBackend(), getCodeCache().getTarget(), null, getDefaultGraphBuilderSuite(), - OptimisticOptimizations.ALL, getProfilingInfo(graph), getSpeculationLog(), suitesLocal, lowLevelSuitesLocal, new CompilationResult(), + OptimisticOptimizations.ALL, getProfilingInfo(graph), getSpeculationLog(), suitesLocal, lirSuitesLocal, new CompilationResult(), CompilationResultBuilderFactory.Default); addMethod(method, compResult); } diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Wed Feb 11 16:08:50 2015 +0100 @@ -139,8 +139,8 @@ return providers.getSuites().getDefaultSuites(); } - protected LowLevelSuites getLowLevelSuites(HotSpotProviders providers) { - return providers.getSuites().getDefaultLowLevelSuites(); + protected LIRSuites getLIRSuites(HotSpotProviders providers) { + return providers.getSuites().getDefaultLIRSuites(); } protected PhaseSuite getGraphBuilderSuite(HotSpotProviders providers) { @@ -228,7 +228,7 @@ cc = new CallingConvention(cc.getStackSize(), cc.getReturn(), tmp.getArgument(0)); } Suites suites = getSuites(providers); - LowLevelSuites lowLevelSuites = getLowLevelSuites(providers); + LIRSuites lirSuites = getLIRSuites(providers); ProfilingInfo profilingInfo = getProfilingInfo(); OptimisticOptimizations optimisticOpts = getOptimisticOpts(profilingInfo); if (isOSR) { @@ -237,7 +237,7 @@ optimisticOpts.remove(Optimization.RemoveNeverExecutedCode); } result = compileGraph(graph, cc, method, providers, backend, backend.getTarget(), graphCache, getGraphBuilderSuite(providers), optimisticOpts, profilingInfo, - method.getSpeculationLog(), suites, lowLevelSuites, new CompilationResult(), CompilationResultBuilderFactory.Default); + method.getSpeculationLog(), suites, lirSuites, new CompilationResult(), CompilationResultBuilderFactory.Default); } result.setId(getId()); result.setEntryBCI(entryBCI); diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java Wed Feb 11 16:08:50 2015 +0100 @@ -45,7 +45,7 @@ protected final DerivedOptionValue defaultSuites; protected final PhaseSuite defaultGraphBuilderSuite; - private final DerivedOptionValue defaultLowLevelSuites; + private final DerivedOptionValue defaultLIRSuites; protected final HotSpotGraalRuntimeProvider runtime; private class SuitesSupplier implements OptionSupplier { @@ -58,12 +58,12 @@ } - private class LowLevelSuitesSupplier implements OptionSupplier { + private class LIRSuitesSupplier implements OptionSupplier { private static final long serialVersionUID = -1558586374095874299L; - public LowLevelSuites get() { - return createLowLevelSuites(); + public LIRSuites get() { + return createLIRSuites(); } } @@ -72,7 +72,7 @@ this.runtime = runtime; this.defaultGraphBuilderSuite = createGraphBuilderSuite(); this.defaultSuites = new DerivedOptionValue<>(new SuitesSupplier()); - this.defaultLowLevelSuites = new DerivedOptionValue<>(new LowLevelSuitesSupplier()); + this.defaultLIRSuites = new DerivedOptionValue<>(new LIRSuitesSupplier()); } public Suites getDefaultSuites() { @@ -135,12 +135,12 @@ return gbs; } - public LowLevelSuites getDefaultLowLevelSuites() { - return defaultLowLevelSuites.getValue(); + public LIRSuites getDefaultLIRSuites() { + return defaultLIRSuites.getValue(); } - public LowLevelSuites createLowLevelSuites() { - return Suites.createDefaultLowLevelSuites(); + public LIRSuites createLIRSuites() { + return Suites.createDefaultLIRSuites(); } } diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/HotSpotNativeFunctionInterface.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/HotSpotNativeFunctionInterface.java Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/nfi/HotSpotNativeFunctionInterface.java Wed Feb 11 16:08:50 2015 +0100 @@ -161,11 +161,11 @@ private InstalledCode installNativeFunctionStub(long functionPointer, Class returnType, Class... argumentTypes) { StructuredGraph g = getGraph(providers, factory, functionPointer, returnType, argumentTypes); Suites suites = providers.getSuites().createSuites(); - LowLevelSuites lowLevelSuites = providers.getSuites().createLowLevelSuites(); + LIRSuites lirSuites = providers.getSuites().createLIRSuites(); PhaseSuite phaseSuite = backend.getSuites().getDefaultGraphBuilderSuite().copy(); CallingConvention cc = getCallingConvention(providers.getCodeCache(), Type.JavaCallee, g.method(), false); CompilationResult compResult = GraalCompiler.compileGraph(g, cc, g.method(), providers, backend, backend.getTarget(), null, phaseSuite, OptimisticOptimizations.ALL, - DefaultProfilingInfo.get(TriState.UNKNOWN), null, suites, lowLevelSuites, new CompilationResult(), CompilationResultBuilderFactory.Default); + DefaultProfilingInfo.get(TriState.UNKNOWN), null, suites, lirSuites, new CompilationResult(), CompilationResultBuilderFactory.Default); InstalledCode installedCode; try (Scope s = Debug.scope("CodeInstall", providers.getCodeCache(), g.method())) { installedCode = providers.getCodeCache().addMethod(g.method(), compResult, null, null); diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java Wed Feb 11 16:08:50 2015 +0100 @@ -175,9 +175,8 @@ Suites suites = new Suites(new PhaseSuite<>(), defaultSuites.getMidTier(), defaultSuites.getLowTier()); SchedulePhase schedule = emitFrontEnd(providers, target, graph, null, providers.getSuites().getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL, getProfilingInfo(graph), null, suites); - LowLevelSuites lowLevelSuites = providers.getSuites().getDefaultLowLevelSuites(); - emitBackEnd(graph, Stub.this, incomingCc, getInstalledCodeOwner(), backend, target, compResult, CompilationResultBuilderFactory.Default, schedule, getRegisterConfig(), - lowLevelSuites); + LIRSuites lirSuites = providers.getSuites().getDefaultLIRSuites(); + emitBackEnd(graph, Stub.this, incomingCc, getInstalledCodeOwner(), backend, target, compResult, CompilationResultBuilderFactory.Default, schedule, getRegisterConfig(), lirSuites); } catch (Throwable e) { throw Debug.handle(e); } diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.java/src/com/oracle/graal/java/DefaultSuitesProvider.java --- a/graal/com.oracle.graal.java/src/com/oracle/graal/java/DefaultSuitesProvider.java Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.java/src/com/oracle/graal/java/DefaultSuitesProvider.java Wed Feb 11 16:08:50 2015 +0100 @@ -32,7 +32,7 @@ private final DerivedOptionValue defaultSuites; private final PhaseSuite defaultGraphBuilderSuite; - private final DerivedOptionValue defaultLowLevelSuites; + private final DerivedOptionValue defaultLIRSuites; private class SuitesSupplier implements OptionSupplier { @@ -44,12 +44,12 @@ } - private class LowLevelSuitesSupplier implements OptionSupplier { + private class LIRSuitesSupplier implements OptionSupplier { private static final long serialVersionUID = 312070237227476252L; - public LowLevelSuites get() { - return createLowLevelSuites(); + public LIRSuites get() { + return createLIRSuites(); } } @@ -57,7 +57,7 @@ public DefaultSuitesProvider() { this.defaultGraphBuilderSuite = createGraphBuilderSuite(); this.defaultSuites = new DerivedOptionValue<>(new SuitesSupplier()); - this.defaultLowLevelSuites = new DerivedOptionValue<>(new LowLevelSuitesSupplier()); + this.defaultLIRSuites = new DerivedOptionValue<>(new LIRSuitesSupplier()); } public Suites getDefaultSuites() { @@ -78,12 +78,12 @@ return suite; } - public LowLevelSuites getDefaultLowLevelSuites() { - return defaultLowLevelSuites.getValue(); + public LIRSuites getDefaultLIRSuites() { + return defaultLIRSuites.getValue(); } - public LowLevelSuites createLowLevelSuites() { - return Suites.createDefaultLowLevelSuites(); + public LIRSuites createLIRSuites() { + return Suites.createDefaultLIRSuites(); } } diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ControlFlowOptimizer.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ControlFlowOptimizer.java Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/ControlFlowOptimizer.java Wed Feb 11 16:08:50 2015 +0100 @@ -35,7 +35,7 @@ /** * This class performs basic optimizations on the control flow graph after LIR generation. */ -public final class ControlFlowOptimizer extends LowLevelLowTierPhase { +public final class ControlFlowOptimizer extends LIRLowTierPhase { /** * Performs control flow optimizations on the given LIR graph. diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/EdgeMoveOptimizer.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/EdgeMoveOptimizer.java Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/EdgeMoveOptimizer.java Wed Feb 11 16:08:50 2015 +0100 @@ -48,7 +48,7 @@ * Because this optimization works best when a block contains only a few moves, it has a huge impact * on the number of blocks that are totally empty. */ -public final class EdgeMoveOptimizer extends LowLevelLowTierPhase { +public final class EdgeMoveOptimizer extends LIRLowTierPhase { @Override protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/NullCheckOptimizer.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/NullCheckOptimizer.java Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/NullCheckOptimizer.java Wed Feb 11 16:08:50 2015 +0100 @@ -31,7 +31,7 @@ import com.oracle.graal.lir.gen.*; import com.oracle.graal.lir.phases.*; -public final class NullCheckOptimizer extends LowLevelLowTierPhase { +public final class NullCheckOptimizer extends LIRLowTierPhase { @Override protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/RedundantMoveElimination.java Wed Feb 11 16:08:50 2015 +0100 @@ -41,7 +41,7 @@ /** * Removes move instructions, where the destination value is already in place. */ -public final class RedundantMoveElimination extends LowLevelLowTierPhase { +public final class RedundantMoveElimination extends LIRLowTierPhase { @Override protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanPhase.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanPhase.java Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LinearScanPhase.java Wed Feb 11 16:08:50 2015 +0100 @@ -29,7 +29,7 @@ import com.oracle.graal.lir.gen.*; import com.oracle.graal.lir.phases.*; -public final class LinearScanPhase extends LowLevelMidTierPhase { +public final class LinearScanPhase extends LIRMidTierPhase { @Override protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LocationMarker.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LocationMarker.java Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/alloc/lsra/LocationMarker.java Wed Feb 11 16:08:50 2015 +0100 @@ -42,7 +42,7 @@ * Mark all live references for a frame state. The frame state use this information to build the OOP * maps. */ -public final class LocationMarker extends LowLevelMidTierPhase { +public final class LocationMarker extends LIRMidTierPhase { public static class Options { // @formatter:off diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantLoadOptimization.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantLoadOptimization.java Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/constopt/ConstantLoadOptimization.java Wed Feb 11 16:08:50 2015 +0100 @@ -47,12 +47,12 @@ * a constant, which is potentially scheduled into a block with high probability, with one or more * definitions in blocks with a lower probability. */ -public final class ConstantLoadOptimization extends LowLevelHighTierPhase { +public final class ConstantLoadOptimization extends LIRHighTierPhase { public static class Options { // @formatter:off @Option(help = "Enable constant load optimization.", type = OptionType.Debug) - public static final OptionValue ConstantLoadOptimization = new OptionValue<>(true); + public static final OptionValue LIROptConstantLoadOptimization = new OptionValue<>(true); // @formatter:on } diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRHighTier.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRHighTier.java Wed Feb 11 16:08:50 2015 +0100 @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.lir.phases; + +import com.oracle.graal.lir.constopt.*; +import com.oracle.graal.lir.phases.LIRHighTierPhase.*; + +public class LIRHighTier extends LIRPhaseSuite { + public LIRHighTier() { + if (ConstantLoadOptimization.Options.LIROptConstantLoadOptimization.getValue()) { + appendPhase(new ConstantLoadOptimization()); + } + } +} diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRHighTierPhase.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRHighTierPhase.java Wed Feb 11 16:08:50 2015 +0100 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.lir.phases; + +import java.util.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.compiler.common.cfg.*; +import com.oracle.graal.lir.gen.*; + +public abstract class LIRHighTierPhase extends LIRPhase { + + public static final class LIRHighTierContext { + private final LIRGeneratorTool lirGen; + + public LIRHighTierContext(LIRGeneratorTool lirGen) { + this.lirGen = lirGen; + } + + } + + @Override + protected final > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, LIRHighTierContext context) { + run(target, lirGenRes, codeEmittingOrder, linearScanOrder, context.lirGen); + } + + protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, LIRGeneratorTool lirGen); + +} diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRLowTier.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRLowTier.java Wed Feb 11 16:08:50 2015 +0100 @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.lir.phases; + +import com.oracle.graal.lir.*; +import com.oracle.graal.lir.phases.LIRLowTierPhase.*; +import com.oracle.graal.options.*; + +public class LIRLowTier extends LIRPhaseSuite { + public static class Options { + // @formatter:off + @Option(help = "", type = OptionType.Debug) + public static final OptionValue LIROptEdgeMoveOptimizer = new OptionValue<>(true); + @Option(help = "", type = OptionType.Debug) + public static final OptionValue LIROptControlFlowOptmizer = new OptionValue<>(true); + @Option(help = "", type = OptionType.Debug) + public static final OptionValue LIROptRedundantMoveElimination = new OptionValue<>(true); + @Option(help = "", type = OptionType.Debug) + public static final OptionValue LIROptNullCheckOptimizer = new OptionValue<>(true); + // @formatter:on + } + + public LIRLowTier() { + if (Options.LIROptEdgeMoveOptimizer.getValue()) { + appendPhase(new EdgeMoveOptimizer()); + } + if (Options.LIROptControlFlowOptmizer.getValue()) { + appendPhase(new ControlFlowOptimizer()); + } + if (Options.LIROptRedundantMoveElimination.getValue()) { + appendPhase(new RedundantMoveElimination()); + } + if (Options.LIROptNullCheckOptimizer.getValue()) { + appendPhase(new NullCheckOptimizer()); + } + } +} diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRLowTierPhase.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRLowTierPhase.java Wed Feb 11 16:08:50 2015 +0100 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.lir.phases; + +import java.util.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.compiler.common.cfg.*; +import com.oracle.graal.lir.gen.*; + +public abstract class LIRLowTierPhase extends LIRPhase { + + public static final class LIRLowTierContext { + } + + @Override + protected final > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, LIRLowTierContext context) { + run(target, lirGenRes, codeEmittingOrder, linearScanOrder); + } + + protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder); + +} diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRMidTier.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRMidTier.java Wed Feb 11 16:08:50 2015 +0100 @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.lir.phases; + +import com.oracle.graal.lir.alloc.lsra.*; +import com.oracle.graal.lir.phases.LIRMidTierPhase.*; +import com.oracle.graal.lir.stackslotalloc.*; + +public class LIRMidTier extends LIRPhaseSuite { + public LIRMidTier() { + appendPhase(new LinearScanPhase()); + + // build frame map + if (LSStackSlotAllocator.Options.LIROptLSStackSlotAllocator.getValue()) { + appendPhase(new LSStackSlotAllocator()); + } else { + appendPhase(new SimpleStackSlotAllocator()); + } + // currently we mark locations only if we do register allocation + appendPhase(new LocationMarker()); + } +} diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRMidTierPhase.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRMidTierPhase.java Wed Feb 11 16:08:50 2015 +0100 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.lir.phases; + +import java.util.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.compiler.common.cfg.*; +import com.oracle.graal.lir.gen.*; + +public abstract class LIRMidTierPhase extends LIRPhase { + + public static final class LIRMidTierContext { + } + + @Override + protected final > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, LIRMidTierContext context) { + run(target, lirGenRes, codeEmittingOrder, linearScanOrder); + } + + protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder); + +} diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRPhase.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRPhase.java Wed Feb 11 16:08:50 2015 +0100 @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.lir.phases; + +import java.util.*; +import java.util.regex.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.compiler.common.cfg.*; +import com.oracle.graal.debug.*; +import com.oracle.graal.debug.Debug.Scope; +import com.oracle.graal.debug.DebugMemUseTracker.Closeable; +import com.oracle.graal.debug.internal.*; +import com.oracle.graal.lir.*; +import com.oracle.graal.lir.gen.*; + +/** + * Base class for all {@link LIR low-level} phases. Subclasses should be stateless. There will be + * one global instance for each phase that is shared for all compilations. + */ +public abstract class LIRPhase { + + private static final int PHASE_DUMP_LEVEL = 2; + + private CharSequence name; + + /** + * Records time spent within {@link #apply}. + */ + private final DebugTimer timer; + + /** + * Records memory usage within {@link #apply}. + */ + private final DebugMemUseTracker memUseTracker; + + private static final Pattern NAME_PATTERN = Pattern.compile("[A-Z][A-Za-z0-9]+"); + + private static boolean checkName(String name) { + assert name == null || NAME_PATTERN.matcher(name).matches() : "illegal phase name: " + name; + return true; + } + + public LIRPhase() { + timer = Debug.timer("LIRPhaseTime_%s", getClass()); + memUseTracker = Debug.memUseTracker("LIRPhaseMemUse_%s", getClass()); + } + + protected LIRPhase(String name) { + assert checkName(name); + this.name = name; + timer = Debug.timer("LIRPhaseTime_%s", getClass()); + memUseTracker = Debug.memUseTracker("LIRPhaseMemUse_%s", getClass()); + } + + public final > void apply(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, C context) { + apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, context, true); + } + + public final > void apply(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, C context, boolean dumpLIR) { + try (TimerCloseable a = timer.start(); Scope s = Debug.scope(getName(), this); Closeable c = memUseTracker.start()) { + run(target, lirGenRes, codeEmittingOrder, linearScanOrder, context); + if (dumpLIR && Debug.isDumpEnabled(PHASE_DUMP_LEVEL)) { + Debug.dump(PHASE_DUMP_LEVEL, lirGenRes.getLIR(), "After phase %s", getName()); + } + } catch (Throwable e) { + throw Debug.handle(e); + } + } + + protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, C context); + + protected CharSequence createName() { + String className = LIRPhase.this.getClass().getName(); + String s = className.substring(className.lastIndexOf(".") + 1); // strip the package name + if (s.endsWith("Phase")) { + s = s.substring(0, s.length() - "Phase".length()); + } + return s; + } + + public final CharSequence getName() { + if (name == null) { + name = createName(); + } + return name; + } + +} diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRPhaseSuite.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRPhaseSuite.java Wed Feb 11 16:08:50 2015 +0100 @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.lir.phases; + +import java.util.*; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.compiler.common.cfg.*; +import com.oracle.graal.lir.gen.*; + +public abstract class LIRPhaseSuite extends LIRPhase { + private final List> phases; + + public LIRPhaseSuite() { + phases = new ArrayList<>(); + } + + /** + * Add a new phase at the beginning of this suite. + */ + public final void prependPhase(LIRPhase phase) { + phases.add(0, phase); + } + + /** + * Add a new phase at the end of this suite. + */ + public final void appendPhase(LIRPhase phase) { + phases.add(phase); + } + + public final ListIterator> findPhase(Class> phaseClass) { + ListIterator> it = phases.listIterator(); + if (findNextPhase(it, phaseClass)) { + return it; + } else { + return null; + } + } + + public static boolean findNextPhase(ListIterator> it, Class> phaseClass) { + while (it.hasNext()) { + LIRPhase phase = it.next(); + if (phaseClass.isInstance(phase)) { + return true; + } + } + return false; + } + + @Override + protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, C context) { + for (LIRPhase phase : phases) { + phase.apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, context); + } + } + +} diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRSuites.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LIRSuites.java Wed Feb 11 16:08:50 2015 +0100 @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.graal.lir.phases; + +import com.oracle.graal.api.code.*; +import com.oracle.graal.lir.*; +import com.oracle.graal.lir.gen.*; +import com.oracle.graal.lir.phases.LIRHighTierPhase.LIRHighTierContext; +import com.oracle.graal.lir.phases.LIRLowTierPhase.LIRLowTierContext; +import com.oracle.graal.lir.phases.LIRMidTierPhase.LIRMidTierContext; + +public class LIRSuites { + + private final LIRPhaseSuite highTier; + private final LIRPhaseSuite midTier; + private final LIRPhaseSuite lowTier; + + public LIRSuites(LIRPhaseSuite highTier, LIRPhaseSuite midTier, LIRPhaseSuite lowTier) { + this.highTier = highTier; + this.midTier = midTier; + this.lowTier = lowTier; + } + + /** + * {@link LIRHighTierPhase}s are executed between {@link LIR} generation and register + * allocation. + *

+ * {@link LIRHighTierPhase Implementers} can create new + * {@link LIRGeneratorTool#newVariable variables}, {@link LIRGenerationResult#getFrameMap stack + * slots} and {@link LIRGenerationResult#getFrameMapBuilder virtual stack slots}. + */ + public LIRPhaseSuite getHighTier() { + return highTier; + } + + /** + * {@link LIRMidTierPhase}s are responsible for register allocation and translating + * {@link VirtualStackSlot}s into {@link StackSlot}s. + *

+ * After the {@link LIRMidTier} there should be no more {@link Variable}s and + * {@link VirtualStackSlot}s. + */ + public LIRPhaseSuite getMidTier() { + return midTier; + } + + /** + * {@link LIRLowTierPhase}s are executed after register allocation and before machine code + * generation. + *

+ * A {@link LIRLowTierPhase} must not introduce new {@link Variable}s, + * {@link VirtualStackSlot}s or {@link StackSlot}s. + */ + public LIRPhaseSuite getLowTier() { + return lowTier; + } + +} diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelHighTier.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelHighTier.java Tue Feb 10 17:16:30 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.lir.phases; - -import com.oracle.graal.lir.constopt.*; -import com.oracle.graal.lir.phases.LowLevelHighTierPhase.*; - -public class LowLevelHighTier extends LowLevelPhaseSuite { - public LowLevelHighTier() { - if (ConstantLoadOptimization.Options.ConstantLoadOptimization.getValue()) { - appendPhase(new ConstantLoadOptimization()); - } - } -} diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelHighTierPhase.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelHighTierPhase.java Tue Feb 10 17:16:30 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.lir.phases; - -import java.util.*; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.compiler.common.cfg.*; -import com.oracle.graal.lir.gen.*; - -public abstract class LowLevelHighTierPhase extends LowLevelPhase { - - public static final class LowLevelHighTierContext { - private final LIRGeneratorTool lirGen; - - public LowLevelHighTierContext(LIRGeneratorTool lirGen) { - this.lirGen = lirGen; - } - - } - - @Override - protected final > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, LowLevelHighTierContext context) { - run(target, lirGenRes, codeEmittingOrder, linearScanOrder, context.lirGen); - } - - protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, LIRGeneratorTool lirGen); - -} diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelLowTier.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelLowTier.java Tue Feb 10 17:16:30 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.lir.phases; - -import com.oracle.graal.lir.*; -import com.oracle.graal.lir.phases.LowLevelLowTierPhase.*; - -public class LowLevelLowTier extends LowLevelPhaseSuite { - public LowLevelLowTier() { - appendPhase(new EdgeMoveOptimizer()); - appendPhase(new ControlFlowOptimizer()); - appendPhase(new RedundantMoveElimination()); - appendPhase(new NullCheckOptimizer()); - } -} diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelLowTierPhase.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelLowTierPhase.java Tue Feb 10 17:16:30 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.lir.phases; - -import java.util.*; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.compiler.common.cfg.*; -import com.oracle.graal.lir.gen.*; - -public abstract class LowLevelLowTierPhase extends LowLevelPhase { - - public static final class LowLevelLowTierContext { - } - - @Override - protected final > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, LowLevelLowTierContext context) { - run(target, lirGenRes, codeEmittingOrder, linearScanOrder); - } - - protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder); - -} diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelMidTier.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelMidTier.java Tue Feb 10 17:16:30 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.lir.phases; - -import com.oracle.graal.lir.alloc.lsra.*; -import com.oracle.graal.lir.phases.LowLevelMidTierPhase.*; -import com.oracle.graal.lir.stackslotalloc.*; - -public class LowLevelMidTier extends LowLevelPhaseSuite { - public LowLevelMidTier() { - appendPhase(new LinearScanPhase()); - - // build frame map - if (LSStackSlotAllocator.Options.LSStackSlotAllocation.getValue()) { - appendPhase(new LSStackSlotAllocator()); - } else { - appendPhase(new SimpleStackSlotAllocator()); - } - // currently we mark locations only if we do register allocation - appendPhase(new LocationMarker()); - } -} diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelMidTierPhase.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelMidTierPhase.java Tue Feb 10 17:16:30 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.lir.phases; - -import java.util.*; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.compiler.common.cfg.*; -import com.oracle.graal.lir.gen.*; - -public abstract class LowLevelMidTierPhase extends LowLevelPhase { - - public static final class LowLevelMidTierContext { - } - - @Override - protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, LowLevelMidTierContext context) { - run(target, lirGenRes, codeEmittingOrder, linearScanOrder); - } - - protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder); - -} diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelPhase.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelPhase.java Tue Feb 10 17:16:30 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.lir.phases; - -import java.util.*; -import java.util.regex.*; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.compiler.common.cfg.*; -import com.oracle.graal.debug.*; -import com.oracle.graal.debug.Debug.Scope; -import com.oracle.graal.debug.DebugMemUseTracker.Closeable; -import com.oracle.graal.debug.internal.*; -import com.oracle.graal.lir.*; -import com.oracle.graal.lir.gen.*; - -/** - * Base class for all {@link LIR low-level} phases. Subclasses should be stateless. There will be - * one global instance for each phase that is shared for all compilations. - */ -public abstract class LowLevelPhase { - - private static final int PHASE_DUMP_LEVEL = 2; - - private CharSequence name; - - /** - * Records time spent within {@link #apply}. - */ - private final DebugTimer timer; - - /** - * Records memory usage within {@link #apply}. - */ - private final DebugMemUseTracker memUseTracker; - - private static final Pattern NAME_PATTERN = Pattern.compile("[A-Z][A-Za-z0-9]+"); - - private static boolean checkName(String name) { - assert name == null || NAME_PATTERN.matcher(name).matches() : "illegal phase name: " + name; - return true; - } - - public LowLevelPhase() { - timer = Debug.timer("LowLevelPhaseTime_%s", getClass()); - memUseTracker = Debug.memUseTracker("LowLevelPhaseMemUse_%s", getClass()); - } - - protected LowLevelPhase(String name) { - assert checkName(name); - this.name = name; - timer = Debug.timer("LowLevelPhaseTime_%s", getClass()); - memUseTracker = Debug.memUseTracker("LowLevelPhaseMemUse_%s", getClass()); - } - - public final > void apply(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, C context) { - apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, context, true); - } - - public final > void apply(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, C context, boolean dumpLIR) { - try (TimerCloseable a = timer.start(); Scope s = Debug.scope(getName(), this); Closeable c = memUseTracker.start()) { - run(target, lirGenRes, codeEmittingOrder, linearScanOrder, context); - if (dumpLIR && Debug.isDumpEnabled(PHASE_DUMP_LEVEL)) { - Debug.dump(PHASE_DUMP_LEVEL, lirGenRes.getLIR(), "After phase %s", getName()); - } - } catch (Throwable e) { - throw Debug.handle(e); - } - } - - protected abstract > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, C context); - - protected CharSequence createName() { - String className = LowLevelPhase.this.getClass().getName(); - String s = className.substring(className.lastIndexOf(".") + 1); // strip the package name - if (s.endsWith("Phase")) { - s = s.substring(0, s.length() - "Phase".length()); - } - return s; - } - - public final CharSequence getName() { - if (name == null) { - name = createName(); - } - return name; - } - -} diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelPhaseSuite.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelPhaseSuite.java Tue Feb 10 17:16:30 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.lir.phases; - -import java.util.*; - -import com.oracle.graal.api.code.*; -import com.oracle.graal.compiler.common.cfg.*; -import com.oracle.graal.lir.gen.*; - -public abstract class LowLevelPhaseSuite extends LowLevelPhase { - private final List> phases; - - public LowLevelPhaseSuite() { - phases = new ArrayList<>(); - } - - /** - * Add a new phase at the beginning of this suite. - */ - public final void prependPhase(LowLevelPhase phase) { - phases.add(0, phase); - } - - /** - * Add a new phase at the end of this suite. - */ - public final void appendPhase(LowLevelPhase phase) { - phases.add(phase); - } - - public final ListIterator> findPhase(Class> phaseClass) { - ListIterator> it = phases.listIterator(); - if (findNextPhase(it, phaseClass)) { - return it; - } else { - return null; - } - } - - public static boolean findNextPhase(ListIterator> it, Class> phaseClass) { - while (it.hasNext()) { - LowLevelPhase phase = it.next(); - if (phaseClass.isInstance(phase)) { - return true; - } - } - return false; - } - - @Override - protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder, C context) { - for (LowLevelPhase phase : phases) { - phase.apply(target, lirGenRes, codeEmittingOrder, linearScanOrder, context); - } - } - -} diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelSuites.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/phases/LowLevelSuites.java Tue Feb 10 17:16:30 2015 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.graal.lir.phases; - -import com.oracle.graal.lir.phases.LowLevelHighTierPhase.LowLevelHighTierContext; -import com.oracle.graal.lir.phases.LowLevelLowTierPhase.LowLevelLowTierContext; -import com.oracle.graal.lir.phases.LowLevelMidTierPhase.LowLevelMidTierContext; - -public class LowLevelSuites { - - private final LowLevelPhaseSuite highTier; - private final LowLevelPhaseSuite midTier; - private final LowLevelPhaseSuite lowTier; - - public LowLevelSuites(LowLevelPhaseSuite highTier, LowLevelPhaseSuite midTier, LowLevelPhaseSuite lowTier) { - this.highTier = highTier; - this.midTier = midTier; - this.lowTier = lowTier; - } - - public LowLevelPhaseSuite getHighTier() { - return highTier; - } - - public LowLevelPhaseSuite getMidTier() { - return midTier; - } - - public LowLevelPhaseSuite getLowTier() { - return lowTier; - } - -} diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/LSStackSlotAllocator.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/LSStackSlotAllocator.java Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/LSStackSlotAllocator.java Wed Feb 11 16:08:50 2015 +0100 @@ -51,12 +51,12 @@ * {@link OperandFlag#UNINITIALIZED}. Otherwise the stack slot might be reused and its content * destroyed. */ -public final class LSStackSlotAllocator extends LowLevelMidTierPhase implements StackSlotAllocator { +public final class LSStackSlotAllocator extends LIRMidTierPhase implements StackSlotAllocator { public static class Options { // @formatter:off @Option(help = "Use linear scan stack slot allocation.", type = OptionType.Debug) - public static final OptionValue LSStackSlotAllocation = new OptionValue<>(true); + public static final OptionValue LIROptLSStackSlotAllocator = new OptionValue<>(true); // @formatter:on } diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/SimpleStackSlotAllocator.java --- a/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/SimpleStackSlotAllocator.java Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.lir/src/com/oracle/graal/lir/stackslotalloc/SimpleStackSlotAllocator.java Wed Feb 11 16:08:50 2015 +0100 @@ -36,7 +36,7 @@ import com.oracle.graal.lir.gen.*; import com.oracle.graal.lir.phases.*; -public class SimpleStackSlotAllocator extends LowLevelMidTierPhase implements StackSlotAllocator { +public class SimpleStackSlotAllocator extends LIRMidTierPhase implements StackSlotAllocator { @Override protected > void run(TargetDescription target, LIRGenerationResult lirGenRes, List codeEmittingOrder, List linearScanOrder) { diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/CompilerConfiguration.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/CompilerConfiguration.java Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/CompilerConfiguration.java Wed Feb 11 16:08:50 2015 +0100 @@ -24,9 +24,9 @@ import com.oracle.graal.api.runtime.*; import com.oracle.graal.lir.phases.*; -import com.oracle.graal.lir.phases.LowLevelHighTierPhase.*; -import com.oracle.graal.lir.phases.LowLevelLowTierPhase.*; -import com.oracle.graal.lir.phases.LowLevelMidTierPhase.*; +import com.oracle.graal.lir.phases.LIRHighTierPhase.*; +import com.oracle.graal.lir.phases.LIRLowTierPhase.*; +import com.oracle.graal.lir.phases.LIRMidTierPhase.*; import com.oracle.graal.phases.*; public interface CompilerConfiguration extends Service { @@ -37,9 +37,9 @@ PhaseSuite createLowTier(); - LowLevelPhaseSuite createLowLevelHighTier(); + LIRPhaseSuite createLIRHighTier(); - LowLevelPhaseSuite createLowLevelMidTier(); + LIRPhaseSuite createLIRMidTier(); - LowLevelPhaseSuite createLowLevelLowTier(); + LIRPhaseSuite createLIRLowTier(); } diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/Suites.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/Suites.java Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/Suites.java Wed Feb 11 16:08:50 2015 +0100 @@ -130,21 +130,21 @@ return new Suites(config); } - public static LowLevelSuites createDefaultLowLevelSuites() { + public static LIRSuites createDefaultLIRSuites() { String selected = CompilerConfiguration.getValue(); if (selected.equals("")) { - return new LowLevelSuites(defaultConfiguration.createLowLevelHighTier(), defaultConfiguration.createLowLevelMidTier(), defaultConfiguration.createLowLevelLowTier()); + return new LIRSuites(defaultConfiguration.createLIRHighTier(), defaultConfiguration.createLIRMidTier(), defaultConfiguration.createLIRLowTier()); } else { - return createLowLevelSuites(selected); + return createLIRSuites(selected); } } - public static LowLevelSuites createLowLevelSuites(String name) { + public static LIRSuites createLIRSuites(String name) { CompilerConfiguration config = configurations.get(name); if (config == null) { throw new GraalInternalError("unknown compiler configuration: " + name); } - return new LowLevelSuites(config.createLowLevelHighTier(), config.createLowLevelMidTier(), config.createLowLevelLowTier()); + return new LIRSuites(config.createLIRHighTier(), config.createLIRMidTier(), config.createLIRLowTier()); } } diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/SuitesProvider.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/SuitesProvider.java Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/tiers/SuitesProvider.java Wed Feb 11 16:08:50 2015 +0100 @@ -46,12 +46,12 @@ /** * Get the default phase suites of this compiler. */ - LowLevelSuites getDefaultLowLevelSuites(); + LIRSuites getDefaultLIRSuites(); /** * Create a new set of low-level phase suites. Initially, the suites are the same as the - * {@link #getDefaultLowLevelSuites default} suites. + * {@link #getDefaultLIRSuites default} suites. */ - LowLevelSuites createLowLevelSuites(); + LIRSuites createLIRSuites(); } diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java --- a/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.truffle.hotspot/src/com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime.java Wed Feb 11 16:08:50 2015 +0100 @@ -177,7 +177,7 @@ MetaAccessProvider metaAccess = providers.getMetaAccess(); SuitesProvider suitesProvider = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getSuites(); Suites suites = suitesProvider.createSuites(); - LowLevelSuites lowLevelSuites = suitesProvider.createLowLevelSuites(); + LIRSuites lirSuites = suitesProvider.createLIRSuites(); removeInliningPhase(suites); StructuredGraph graph = new StructuredGraph(javaMethod, DONT_ALLOW_OPTIMISTIC_ASSUMPTIONS); new GraphBuilderPhase.Instance(metaAccess, providers.getStampProvider(), providers.getConstantReflection(), GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph); @@ -186,7 +186,7 @@ Backend backend = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend(); CompilationResultBuilderFactory factory = getOptimizedCallTargetInstrumentationFactory(backend.getTarget().arch.getName(), javaMethod); return compileGraph(graph, cc, javaMethod, providers, backend, providers.getCodeCache().getTarget(), null, graphBuilderSuite, OptimisticOptimizations.ALL, getProfilingInfo(graph), null, - suites, lowLevelSuites, new CompilationResult(), factory); + suites, lirSuites, new CompilationResult(), factory); } private static Providers getGraalProviders() { diff -r fdb93d2ed5c8 -r 313f9a9647e5 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Tue Feb 10 17:16:30 2015 +0100 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Wed Feb 11 16:08:50 2015 +0100 @@ -61,7 +61,7 @@ private final Providers providers; private final Suites suites; - private final LowLevelSuites lowLevelSuites; + private final LIRSuites lirSuites; private final PartialEvaluator partialEvaluator; private final Backend backend; private final GraphBuilderConfiguration config; @@ -84,7 +84,7 @@ ConstantReflectionProvider constantReflection = new TruffleConstantReflectionProvider(backend.getProviders().getConstantReflection(), backend.getProviders().getMetaAccess()); this.providers = backend.getProviders().copyWith(truffleReplacements).copyWith(constantReflection); this.suites = backend.getSuites().getDefaultSuites(); - this.lowLevelSuites = backend.getSuites().getDefaultLowLevelSuites(); + this.lirSuites = backend.getSuites().getDefaultLIRSuites(); ResolvedJavaType[] skippedExceptionTypes = getSkippedExceptionTypes(providers.getMetaAccess()); GraphBuilderConfiguration eagerConfig = GraphBuilderConfiguration.getEagerDefault().withSkippedExceptionTypes(skippedExceptionTypes); @@ -159,7 +159,7 @@ CallingConvention cc = getCallingConvention(codeCache, Type.JavaCallee, graph.method(), false); CompilationResult compilationResult = new CompilationResult(name); result = compileGraph(graph, cc, graph.method(), providers, backend, codeCache.getTarget(), null, graphBuilderSuite == null ? createGraphBuilderSuite().suite : graphBuilderSuite, - Optimizations, getProfilingInfo(graph), speculationLog, suites, lowLevelSuites, compilationResult, CompilationResultBuilderFactory.Default); + Optimizations, getProfilingInfo(graph), speculationLog, suites, lirSuites, compilationResult, CompilationResultBuilderFactory.Default); } catch (Throwable e) { throw Debug.handle(e); }