# HG changeset patch # User Thomas Wuerthinger # Date 1361482950 28800 # Node ID a202f72872a477b6c4ff613a0ba65c0991adfadf # Parent 72971ec0d7aea0ad52ef72e4fcf7e7163395a9e2 Remove usage of left-over fields in GraalCompiler. diff -r 72971ec0d7ae -r a202f72872a4 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 Thu Feb 21 13:24:34 2013 -0800 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Thu Feb 21 13:42:30 2013 -0800 @@ -32,6 +32,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.api.runtime.*; import com.oracle.graal.compiler.*; +import com.oracle.graal.compiler.target.*; import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.Node.Verbosity; @@ -68,11 +69,13 @@ protected final GraalCodeCacheProvider runtime; protected final GraalCompiler graalCompiler; + protected final Backend backend; public GraalCompilerTest() { DebugEnvironment.initialize(System.out); this.runtime = Graal.getRequiredCapability(GraalCodeCacheProvider.class); this.graalCompiler = Graal.getRequiredCapability(GraalCompiler.class); + this.backend = Graal.getRequiredCapability(Backend.class); } protected void assertEquals(StructuredGraph expected, StructuredGraph graph) { @@ -359,7 +362,7 @@ GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL); phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); editPhasePlan(method, graph, phasePlan); - CompilationResult compResult = graalCompiler.compileMethod(runtime().getTarget(), method, graph, null, phasePlan, OptimisticOptimizations.ALL); + CompilationResult compResult = graalCompiler.compileMethod(runtime(), backend, runtime().getTarget(), method, graph, null, phasePlan, OptimisticOptimizations.ALL); if (printCompilation) { TTY.println(String.format("@%-6d Graal %-70s %-45s %-50s | %4dms %5dB", id, "", "", "", System.currentTimeMillis() - start, compResult.getTargetCodeSize())); } diff -r 72971ec0d7ae -r a202f72872a4 graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java --- a/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Thu Feb 21 13:24:34 2013 -0800 +++ b/graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java Thu Feb 21 13:42:30 2013 -0800 @@ -47,23 +47,8 @@ public class GraalCompiler { - /** - * The runtime that this compiler has been configured for. - */ - public final GraalCodeCacheProvider runtime; - - /** - * The backend that this compiler has been configured for. - */ - public final Backend backend; - - public GraalCompiler(GraalCodeCacheProvider runtime, Backend backend) { - this.runtime = runtime; - this.backend = backend; - } - - public CompilationResult compileMethod(final TargetDescription target, final ResolvedJavaMethod method, final StructuredGraph graph, final GraphCache cache, final PhasePlan plan, - final OptimisticOptimizations optimisticOpts) { + public CompilationResult compileMethod(final GraalCodeCacheProvider runtime, final Backend backend, final TargetDescription target, final ResolvedJavaMethod method, final StructuredGraph graph, + final GraphCache cache, final PhasePlan plan, final OptimisticOptimizations optimisticOpts) { assert (method.getModifiers() & Modifier.NATIVE) == 0 : "compiling native methods is not supported"; return Debug.scope("GraalCompiler", new Object[]{graph, method, this}, new Callable() { @@ -73,19 +58,19 @@ final LIR lir = Debug.scope("FrontEnd", new Callable() { public LIR call() { - return emitHIR(target, graph, assumptions, cache, plan, optimisticOpts); + return emitHIR(runtime, target, graph, assumptions, cache, plan, optimisticOpts); } }); final FrameMap frameMap = Debug.scope("BackEnd", lir, new Callable() { public FrameMap call() { - return emitLIR(lir, graph, method); + return emitLIR(runtime, backend, target, lir, graph, method); } }); return Debug.scope("CodeGen", frameMap, new Callable() { public CompilationResult call() { - return emitCode(getLeafGraphIdArray(graph), assumptions, method, lir, frameMap); + return emitCode(backend, getLeafGraphIdArray(graph), assumptions, method, lir, frameMap); } }); @@ -106,9 +91,12 @@ /** * Builds the graph, optimizes it. * + * @param runtime + * * @param target */ - public LIR emitHIR(TargetDescription target, StructuredGraph graph, Assumptions assumptions, GraphCache cache, PhasePlan plan, OptimisticOptimizations optimisticOpts) { + public LIR emitHIR(GraalCodeCacheProvider runtime, TargetDescription target, StructuredGraph graph, Assumptions assumptions, GraphCache cache, PhasePlan plan, + OptimisticOptimizations optimisticOpts) { if (graph.start().next() == null) { plan.runPhases(PhasePosition.AFTER_PARSING, graph); @@ -237,7 +225,7 @@ } - public FrameMap emitLIR(final LIR lir, StructuredGraph graph, final ResolvedJavaMethod method) { + public FrameMap emitLIR(GraalCodeCacheProvider runtime, Backend backend, final TargetDescription target, final LIR lir, StructuredGraph graph, final ResolvedJavaMethod method) { final FrameMap frameMap = backend.newFrameMap(runtime.lookupRegisterConfig(method)); final LIRGenerator lirGenerator = backend.newLIRGenerator(graph, frameMap, method, lir); @@ -272,7 +260,7 @@ return frameMap; } - public CompilationResult emitCode(long[] leafGraphIds, Assumptions assumptions, ResolvedJavaMethod method, LIR lir, FrameMap frameMap) { + public CompilationResult emitCode(Backend backend, long[] leafGraphIds, Assumptions assumptions, ResolvedJavaMethod method, LIR lir, FrameMap frameMap) { TargetMethodAssembler tasm = backend.newAssembler(frameMap, lir); backend.emitCode(tasm, method, lir); CompilationResult result = tasm.finishTargetMethod(method, false); diff -r 72971ec0d7ae -r a202f72872a4 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 Thu Feb 21 13:24:34 2013 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/CompilationTask.java Thu Feb 21 13:42:30 2013 -0800 @@ -143,10 +143,10 @@ } else { // Compiling an intrinsic graph - must clone the graph graph = graph.copy(); - // System.out.println("compiling intrinsic " + method); } InlinedBytecodes.add(method.getCodeSize()); - return graalRuntime.getCompiler().compileMethod(graalRuntime.getTarget(), method, graph, graalRuntime.getCache(), plan, optimisticOpts); + return graalRuntime.getCompiler().compileMethod(graalRuntime.getRuntime(), graalRuntime.getBackend(), graalRuntime.getTarget(), method, graph, graalRuntime.getCache(), plan, + optimisticOpts); } }); } finally { diff -r 72971ec0d7ae -r a202f72872a4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Thu Feb 21 13:24:34 2013 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/HotSpotGraalRuntime.java Thu Feb 21 13:42:30 2013 -0800 @@ -31,6 +31,7 @@ import com.oracle.graal.api.meta.*; import com.oracle.graal.api.runtime.*; import com.oracle.graal.compiler.*; +import com.oracle.graal.compiler.target.*; import com.oracle.graal.hotspot.bridge.*; import com.oracle.graal.hotspot.logging.*; import com.oracle.graal.hotspot.meta.*; @@ -116,6 +117,7 @@ private volatile HotSpotGraphCache cache; protected final HotSpotVMConfig config; + private final HotSpotBackend backend; protected HotSpotGraalRuntime() { CompilerToVM toVM = new CompilerToVMImpl(); @@ -139,9 +141,9 @@ runtime = createRuntime(); - HotSpotBackend backend = createBackend(); + backend = createBackend(); GraalOptions.StackShadowPages = config.stackShadowPages; - compiler = new GraalCompiler(getRuntime(), backend); + compiler = new GraalCompiler(); if (GraalOptions.CacheGraphs) { cache = new HotSpotGraphCache(); } @@ -268,6 +270,13 @@ if (clazz == GraalCompiler.class) { return (T) getCompiler(); } + if (clazz == Backend.class) { + return (T) getBackend(); + } return null; } + + public HotSpotBackend getBackend() { + return backend; + } } diff -r 72971ec0d7ae -r a202f72872a4 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java --- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Thu Feb 21 13:24:34 2013 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/VMToCompilerImpl.java Thu Feb 21 13:42:30 2013 -0800 @@ -153,7 +153,7 @@ Assumptions assumptions = new Assumptions(false); SnippetInstaller installer = new HotSpotSnippetInstaller(runtime, assumptions, runtime.getGraalRuntime().getTarget()); GraalIntrinsics.installIntrinsics(installer); - runtime.installSnippets(installer, assumptions); + runtime.installSnippets(graalRuntime.getBackend(), installer, assumptions); } }); diff -r 72971ec0d7ae -r a202f72872a4 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 Thu Feb 21 13:24:34 2013 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Thu Feb 21 13:42:30 2013 -0800 @@ -51,6 +51,7 @@ import com.oracle.graal.api.code.Register.RegisterFlag; import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor; import com.oracle.graal.api.meta.*; +import com.oracle.graal.compiler.target.*; import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.*; import com.oracle.graal.hotspot.bridge.*; @@ -328,7 +329,7 @@ protected abstract RegisterConfig createRegisterConfig(boolean globalStubConfig); - public void installSnippets(SnippetInstaller installer, Assumptions assumptions) { + public void installSnippets(Backend backend, SnippetInstaller installer, Assumptions assumptions) { if (GraalOptions.IntrinsifyObjectMethods) { installer.installSubstitutions(ObjectSubstitutions.class); } @@ -370,8 +371,8 @@ newInstanceStub = new NewInstanceStub(this, assumptions, graalRuntime.getTarget()); newArrayStub = new NewArrayStub(this, assumptions, graalRuntime.getTarget()); - newInstanceStub.install(graalRuntime.getCompiler()); - newArrayStub.install(graalRuntime.getCompiler()); + newInstanceStub.install(backend, graalRuntime.getCompiler()); + newArrayStub.install(backend, graalRuntime.getCompiler()); } public HotSpotGraalRuntime getGraalRuntime() { diff -r 72971ec0d7ae -r a202f72872a4 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 Thu Feb 21 13:24:34 2013 -0800 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/Stub.java Thu Feb 21 13:42:30 2013 -0800 @@ -31,6 +31,7 @@ import com.oracle.graal.api.code.RuntimeCallTarget.Descriptor; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.*; +import com.oracle.graal.compiler.target.*; import com.oracle.graal.debug.*; import com.oracle.graal.graph.*; import com.oracle.graal.hotspot.*; @@ -70,7 +71,7 @@ /** * Creates a new stub container. The new stub still needs to be - * {@linkplain #install(GraalCompiler) installed}. + * {@linkplain #install(Backend, GraalCompiler) installed}. * * @param descriptor linkage details for a call to the stub */ @@ -106,7 +107,7 @@ * Compiles the code for this stub, installs it and initializes the address used for calls to * it. */ - public void install(GraalCompiler compiler) { + public void install(Backend backend, GraalCompiler compiler) { StructuredGraph graph = (StructuredGraph) stubMethod.getCompilerStorage().get(Graph.class); Key key = new Key(stubMethod); @@ -117,7 +118,7 @@ PhasePlan phasePlan = new PhasePlan(); GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL); phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); - final CompilationResult compResult = compiler.compileMethod(runtime().getTarget(), stubMethod, graph, null, phasePlan, OptimisticOptimizations.ALL); + final CompilationResult compResult = compiler.compileMethod(runtime(), backend, runtime().getTarget(), stubMethod, graph, null, phasePlan, OptimisticOptimizations.ALL); final CodeInfo[] info = new CodeInfo[1]; stubCode = Debug.scope("CodeInstall", new Object[]{compiler, stubMethod}, new Callable() { diff -r 72971ec0d7ae -r a202f72872a4 graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/SnippetProvider.java --- a/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/SnippetProvider.java Thu Feb 21 13:24:34 2013 -0800 +++ b/graal/com.oracle.graal.snippets/src/com/oracle/graal/snippets/SnippetProvider.java Thu Feb 21 13:42:30 2013 -0800 @@ -23,8 +23,9 @@ package com.oracle.graal.snippets; import com.oracle.graal.api.code.*; +import com.oracle.graal.compiler.target.*; public interface SnippetProvider { - void installSnippets(SnippetInstaller installer, Assumptions assumptions); + void installSnippets(Backend backend, SnippetInstaller installer, Assumptions assumptions); }