Mercurial > hg > truffle
diff graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/GraalCompilerTest.java @ 5780:64257cbef60c
removed compile method from GraalCodeCacheProvider interface
added hook for Graal tests to modify the phase plan used during compilation
renamed of variables to reflect types: compiler -> graalRuntime, targetMethod -> compResult
rename: InvokeTest -> InvokeHintsTest
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 06 Jul 2012 14:52:42 +0200 |
parents | 46ad94a0574a |
children | 92bc58dc5b5e |
line wrap: on
line diff
--- a/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/GraalCompilerTest.java Fri Jul 06 09:48:14 2012 +0200 +++ b/graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/GraalCompilerTest.java Fri Jul 06 14:52:42 2012 +0200 @@ -53,7 +53,7 @@ * <li>Assert that the transformed graph is equal to an expected graph.</li> * </ol> * <p> - * See {@link InvokeTest} as an example. + * See {@link InvokeHintsTest} as an example. * <p> * The tests can be run in Eclipse with the "Compiler Unit Test" Eclipse * launch configuration found in the top level of this project or by @@ -62,10 +62,12 @@ public abstract class GraalCompilerTest { protected final GraalCodeCacheProvider runtime; + protected final GraalCompiler graalCompiler; public GraalCompilerTest() { Debug.enable(); this.runtime = Graal.getRuntime().getCapability(GraalCodeCacheProvider.class); + this.graalCompiler = Graal.getRuntime().getCapability(GraalCompiler.class); } protected void assertEquals(StructuredGraph expected, StructuredGraph graph) { @@ -198,6 +200,16 @@ } /** + * Can be overridden to modify the compilation phases applied for a test. + * + * @param method the method being compiled + * @param graph the graph being compiled + * @param phasePlan the phase plan to be edited + */ + protected void editPhasePlan(ResolvedJavaMethod method, StructuredGraph graph, PhasePlan phasePlan) { + } + + /** * Gets installed code for a given method and graph, compiling it first if necessary. * * @param forceCompile specifies whether to ignore any previous code cached for the (method, key) pair @@ -211,24 +223,27 @@ } InstalledCode installedCode = Debug.scope("Compiling", new DebugDumpScope(String.valueOf(compilationId++), true), new Callable<InstalledCode>() { public InstalledCode call() throws Exception { - CompilationResult targetMethod = runtime.compile(method, graph); - return addMethod(method, targetMethod); + PhasePlan phasePlan = new PhasePlan(); + GraphBuilderPhase graphBuilderPhase = new GraphBuilderPhase(runtime, GraphBuilderConfiguration.getDefault(), OptimisticOptimizations.ALL); + phasePlan.addPhase(PhasePosition.AFTER_PARSING, graphBuilderPhase); + editPhasePlan(method, graph, phasePlan); + CompilationResult compResult = graalCompiler.compileMethod(method, graph, -1, null, phasePlan, OptimisticOptimizations.ALL); + return addMethod(method, compResult); } }); cache.put(method, installedCode); return installedCode; } - protected InstalledCode addMethod(final ResolvedJavaMethod method, final CompilationResult tm) { - GraalCompiler graalCompiler = Graal.getRuntime().getCapability(GraalCompiler.class); + protected InstalledCode addMethod(final ResolvedJavaMethod method, final CompilationResult compResult) { assert graalCompiler != null; return Debug.scope("CodeInstall", new Object[] {graalCompiler, method}, new Callable<InstalledCode>() { @Override public InstalledCode call() throws Exception { final CodeInfo[] info = Debug.isDumpEnabled() ? new CodeInfo[1] : null; - InstalledCode installedMethod = runtime.addMethod(method, tm, info); + InstalledCode installedMethod = runtime.addMethod(method, compResult, info); if (info != null) { - Debug.dump(new Object[] {tm, info[0]}, "After code installation"); + Debug.dump(new Object[] {compResult, info[0]}, "After code installation"); } return installedMethod; }