Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.graal.compiler/src/com/oracle/graal/compiler/GraalCompiler.java @ 7836:a202f72872a4
Remove usage of left-over fields in GraalCompiler.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Thu, 21 Feb 2013 13:42:30 -0800 |
parents | 72971ec0d7ae |
children | 46005f68fc6c |
comparison
equal
deleted
inserted
replaced
7835:72971ec0d7ae | 7836:a202f72872a4 |
---|---|
45 import com.oracle.graal.phases.schedule.*; | 45 import com.oracle.graal.phases.schedule.*; |
46 import com.oracle.graal.virtual.phases.ea.*; | 46 import com.oracle.graal.virtual.phases.ea.*; |
47 | 47 |
48 public class GraalCompiler { | 48 public class GraalCompiler { |
49 | 49 |
50 /** | 50 public CompilationResult compileMethod(final GraalCodeCacheProvider runtime, final Backend backend, final TargetDescription target, final ResolvedJavaMethod method, final StructuredGraph graph, |
51 * The runtime that this compiler has been configured for. | 51 final GraphCache cache, final PhasePlan plan, final OptimisticOptimizations optimisticOpts) { |
52 */ | |
53 public final GraalCodeCacheProvider runtime; | |
54 | |
55 /** | |
56 * The backend that this compiler has been configured for. | |
57 */ | |
58 public final Backend backend; | |
59 | |
60 public GraalCompiler(GraalCodeCacheProvider runtime, Backend backend) { | |
61 this.runtime = runtime; | |
62 this.backend = backend; | |
63 } | |
64 | |
65 public CompilationResult compileMethod(final TargetDescription target, final ResolvedJavaMethod method, final StructuredGraph graph, final GraphCache cache, final PhasePlan plan, | |
66 final OptimisticOptimizations optimisticOpts) { | |
67 assert (method.getModifiers() & Modifier.NATIVE) == 0 : "compiling native methods is not supported"; | 52 assert (method.getModifiers() & Modifier.NATIVE) == 0 : "compiling native methods is not supported"; |
68 | 53 |
69 return Debug.scope("GraalCompiler", new Object[]{graph, method, this}, new Callable<CompilationResult>() { | 54 return Debug.scope("GraalCompiler", new Object[]{graph, method, this}, new Callable<CompilationResult>() { |
70 | 55 |
71 public CompilationResult call() { | 56 public CompilationResult call() { |
72 final Assumptions assumptions = new Assumptions(GraalOptions.OptAssumptions); | 57 final Assumptions assumptions = new Assumptions(GraalOptions.OptAssumptions); |
73 final LIR lir = Debug.scope("FrontEnd", new Callable<LIR>() { | 58 final LIR lir = Debug.scope("FrontEnd", new Callable<LIR>() { |
74 | 59 |
75 public LIR call() { | 60 public LIR call() { |
76 return emitHIR(target, graph, assumptions, cache, plan, optimisticOpts); | 61 return emitHIR(runtime, target, graph, assumptions, cache, plan, optimisticOpts); |
77 } | 62 } |
78 }); | 63 }); |
79 final FrameMap frameMap = Debug.scope("BackEnd", lir, new Callable<FrameMap>() { | 64 final FrameMap frameMap = Debug.scope("BackEnd", lir, new Callable<FrameMap>() { |
80 | 65 |
81 public FrameMap call() { | 66 public FrameMap call() { |
82 return emitLIR(lir, graph, method); | 67 return emitLIR(runtime, backend, target, lir, graph, method); |
83 } | 68 } |
84 }); | 69 }); |
85 return Debug.scope("CodeGen", frameMap, new Callable<CompilationResult>() { | 70 return Debug.scope("CodeGen", frameMap, new Callable<CompilationResult>() { |
86 | 71 |
87 public CompilationResult call() { | 72 public CompilationResult call() { |
88 return emitCode(getLeafGraphIdArray(graph), assumptions, method, lir, frameMap); | 73 return emitCode(backend, getLeafGraphIdArray(graph), assumptions, method, lir, frameMap); |
89 } | 74 } |
90 | 75 |
91 }); | 76 }); |
92 } | 77 } |
93 }); | 78 }); |
104 } | 89 } |
105 | 90 |
106 /** | 91 /** |
107 * Builds the graph, optimizes it. | 92 * Builds the graph, optimizes it. |
108 * | 93 * |
94 * @param runtime | |
95 * | |
109 * @param target | 96 * @param target |
110 */ | 97 */ |
111 public LIR emitHIR(TargetDescription target, StructuredGraph graph, Assumptions assumptions, GraphCache cache, PhasePlan plan, OptimisticOptimizations optimisticOpts) { | 98 public LIR emitHIR(GraalCodeCacheProvider runtime, TargetDescription target, StructuredGraph graph, Assumptions assumptions, GraphCache cache, PhasePlan plan, |
99 OptimisticOptimizations optimisticOpts) { | |
112 | 100 |
113 if (graph.start().next() == null) { | 101 if (graph.start().next() == null) { |
114 plan.runPhases(PhasePosition.AFTER_PARSING, graph); | 102 plan.runPhases(PhasePosition.AFTER_PARSING, graph); |
115 new DeadCodeEliminationPhase().apply(graph); | 103 new DeadCodeEliminationPhase().apply(graph); |
116 } else { | 104 } else { |
235 } | 223 } |
236 }); | 224 }); |
237 | 225 |
238 } | 226 } |
239 | 227 |
240 public FrameMap emitLIR(final LIR lir, StructuredGraph graph, final ResolvedJavaMethod method) { | 228 public FrameMap emitLIR(GraalCodeCacheProvider runtime, Backend backend, final TargetDescription target, final LIR lir, StructuredGraph graph, final ResolvedJavaMethod method) { |
241 final FrameMap frameMap = backend.newFrameMap(runtime.lookupRegisterConfig(method)); | 229 final FrameMap frameMap = backend.newFrameMap(runtime.lookupRegisterConfig(method)); |
242 final LIRGenerator lirGenerator = backend.newLIRGenerator(graph, frameMap, method, lir); | 230 final LIRGenerator lirGenerator = backend.newLIRGenerator(graph, frameMap, method, lir); |
243 | 231 |
244 Debug.scope("LIRGen", lirGenerator, new Runnable() { | 232 Debug.scope("LIRGen", lirGenerator, new Runnable() { |
245 | 233 |
270 } | 258 } |
271 }); | 259 }); |
272 return frameMap; | 260 return frameMap; |
273 } | 261 } |
274 | 262 |
275 public CompilationResult emitCode(long[] leafGraphIds, Assumptions assumptions, ResolvedJavaMethod method, LIR lir, FrameMap frameMap) { | 263 public CompilationResult emitCode(Backend backend, long[] leafGraphIds, Assumptions assumptions, ResolvedJavaMethod method, LIR lir, FrameMap frameMap) { |
276 TargetMethodAssembler tasm = backend.newAssembler(frameMap, lir); | 264 TargetMethodAssembler tasm = backend.newAssembler(frameMap, lir); |
277 backend.emitCode(tasm, method, lir); | 265 backend.emitCode(tasm, method, lir); |
278 CompilationResult result = tasm.finishTargetMethod(method, false); | 266 CompilationResult result = tasm.finishTargetMethod(method, false); |
279 if (!assumptions.isEmpty()) { | 267 if (!assumptions.isEmpty()) { |
280 result.setAssumptions(assumptions); | 268 result.setAssumptions(assumptions); |