# HG changeset patch # User Josef Eisl # Date 1394010755 -3600 # Node ID 89bbedfe0ad3233fcdc5567517419096220c6a2c # Parent 4c2bfd3e602163f3d624f3ab6e6afbb9980ee24e Direct LIR generation: refactoring alternative compilation path in GraalCompilerTest. diff -r 4c2bfd3e6021 -r 89bbedfe0ad3 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 Wed Mar 05 10:11:21 2014 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Wed Mar 05 10:12:35 2014 +0100 @@ -39,12 +39,14 @@ import com.oracle.graal.api.code.CallingConvention.Type; import com.oracle.graal.api.meta.*; import com.oracle.graal.api.runtime.*; +import com.oracle.graal.compiler.gen.*; import com.oracle.graal.compiler.target.*; import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.Scope; import com.oracle.graal.graph.*; import com.oracle.graal.graph.Node.Verbosity; import com.oracle.graal.java.*; +import com.oracle.graal.lir.*; import com.oracle.graal.lir.asm.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.cfg.*; @@ -496,17 +498,42 @@ return installedCode; } - protected CompilationResult compileBaseline(ResolvedJavaMethod javaMethod) { + private CompilationResult compileBaseline(ResolvedJavaMethod javaMethod) { try (Scope bds = Debug.scope("compileBaseline")) { - StructuredGraph graph = new StructuredGraph(javaMethod); - PhaseSuite graphBuilderSuite = getCustomLIRBuilderSuite(GraphBuilderConfiguration.getDefault()); - graphBuilderSuite.apply(graph, new HighTierContext(providers, null, null, graphBuilderSuite, OptimisticOptimizations.ALL)); + Assumptions assumptions = new Assumptions(OptAssumptions.getValue()); + LIRGenerator lirGen = compileBytecodeToLIR(javaMethod, assumptions); + CompilationResult compilationResult = new CompilationResult(); + try (Scope s = Debug.scope("CodeGen", lirGen)) { + // there will be no more GraphIds so we can pass an empty array... + // ...they are not use (yet?) anyway + emitCode(getBackend(), new long[0], assumptions, lirGen, compilationResult, javaMethod, CompilationResultBuilderFactory.Default); + } catch (Throwable e) { + throw Debug.handle(e); + } + return compilationResult; + } catch (Throwable e) { + throw Debug.handle(e); + } + } - Debug.dump(graph, "after bytecode parsing"); + private LIRGenerator compileBytecodeToLIR(ResolvedJavaMethod javaMethod, Assumptions assumptions) { + StructuredGraph graph = new StructuredGraph(javaMethod); + PhaseSuite graphBuilderSuite = getCustomLIRBuilderSuite(GraphBuilderConfiguration.getDefault()); + graphBuilderSuite.apply(graph, new HighTierContext(providers, null, null, graphBuilderSuite, OptimisticOptimizations.ALL)); + + Debug.dump(graph, "after bytecode parsing"); - CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); - return compileGraph(graph, cc, javaMethod, getProviders(), getBackend(), getCodeCache().getTarget(), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL, - getProfilingInfo(graph), getSpeculationLog(), getSuites(), true, new CompilationResult(), CompilationResultBuilderFactory.Default); + CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); + TargetDescription target = getCodeCache().getTarget(); + assert !graph.isFrozen(); + LIR lir = null; + try (Scope s = Debug.scope("FrontEnd")) { + lir = emitHIR(getProviders(), target, graph, assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL, getProfilingInfo(graph), getSpeculationLog(), getSuites()); + } catch (Throwable e) { + throw Debug.handle(e); + } + try (Scope s = Debug.scope("BackEnd", lir)) { + return emitLIR(getBackend(), target, lir, graph, cc); } catch (Throwable e) { throw Debug.handle(e); }