# HG changeset patch # User Doug Simon # Date 1413583699 -7200 # Node ID 86ec7f6f71b3725bbc2dc11b22a467ead969b3df # Parent 6997fce99fa38e9de8fa3c2831d24744626fd672 refactored GraalCompilerTest API to be in terms of ResolvedJavaMethod instead of Method diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BasicHSAILTest.java --- a/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BasicHSAILTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.compiler.hsail.test/src/com/oracle/graal/compiler/hsail/test/BasicHSAILTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -24,10 +24,9 @@ import static com.oracle.graal.debug.DelegatingDebugConfig.Feature.*; -import java.lang.reflect.*; - import org.junit.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.target.*; import com.oracle.graal.compiler.test.*; import com.oracle.graal.debug.*; @@ -347,8 +346,8 @@ private void test(final String snippet) { try (DebugConfigScope dcs = Debug.setConfig(new DelegatingDebugConfig().disable(INTERCEPT))) { try (Scope s = Debug.scope("HSAILCodeGen")) { - Method method = getMethod(snippet); - ExternalCompilationResult hsailCode = getBackend().compileKernel(getMetaAccess().lookupJavaMethod(method), false); + ResolvedJavaMethod method = getResolvedJavaMethod(snippet); + ExternalCompilationResult hsailCode = getBackend().compileKernel(method, false); Debug.log("HSAIL code generated for %s:%n%s", snippet, hsailCode.getCodeString()); } catch (Throwable e) { throw Debug.handle(e); diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXTest.java --- a/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.compiler.ptx.test/src/com/oracle/graal/compiler/ptx/test/PTXTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -55,7 +55,7 @@ } protected ExternalCompilationResult compileKernel(String test) { - return compileKernel(getMetaAccess().lookupJavaMethod(getMethod(test))); + return compileKernel(getResolvedJavaMethod(test)); } protected HotSpotNmethod installKernel(ResolvedJavaMethod method, ExternalCompilationResult ptxCode) { diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CommonedConstantsTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CommonedConstantsTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/CommonedConstantsTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -54,7 +54,7 @@ @Test public void test0() { // Ensure the exception path is profiled - ResolvedJavaMethod javaMethod = getMetaAccess().lookupJavaMethod(getMethod("test0Snippet")); + ResolvedJavaMethod javaMethod = getResolvedJavaMethod("test0Snippet"); javaMethod.reprofile(); test0Snippet(array, array.length); diff -r 6997fce99fa3 -r 86ec7f6f71b3 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 Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -357,8 +357,8 @@ } } - protected Object referenceInvoke(Method method, Object receiver, Object... args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { - return method.invoke(receiver, args); + protected Object referenceInvoke(ResolvedJavaMethod method, Object receiver, Object... args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { + return invoke(method, receiver, args); } protected static class Result { @@ -380,7 +380,7 @@ /** * Called before a test is executed. */ - protected void before(@SuppressWarnings("unused") Method method) { + protected void before(@SuppressWarnings("unused") ResolvedJavaMethod method) { } /** @@ -389,7 +389,7 @@ protected void after() { } - protected Result executeExpected(Method method, Object receiver, Object... args) { + protected Result executeExpected(ResolvedJavaMethod method, Object receiver, Object... args) { before(method); try { // This gives us both the expected return value as well as ensuring that the method to @@ -404,18 +404,17 @@ } } - protected Result executeActual(Method method, Object receiver, Object... args) { + protected Result executeActual(ResolvedJavaMethod method, Object receiver, Object... args) { before(method); Object[] executeArgs = argsWithReceiver(receiver, args); - ResolvedJavaMethod javaMethod = getMetaAccess().lookupJavaMethod(method); - checkArgs(javaMethod, executeArgs); + checkArgs(method, executeArgs); InstalledCode compiledMethod = null; if (UseBaselineCompiler.getValue()) { - compiledMethod = getCodeBaseline(javaMethod, method); + compiledMethod = getCodeBaseline(method); } else { - compiledMethod = getCode(javaMethod, parseEager(method)); + compiledMethod = getCode(method, parseEager(method)); } try { return new Result(compiledMethod.executeVarargs(executeArgs), null); @@ -426,12 +425,12 @@ } } - protected InstalledCode getCodeBaseline(ResolvedJavaMethod javaMethod, Method method) { - return getCodeBaseline(javaMethod, method, false); + protected InstalledCode getCodeBaseline(ResolvedJavaMethod javaMethod) { + return getCodeBaseline(javaMethod, false); } - protected InstalledCode getCodeBaseline(ResolvedJavaMethod javaMethod, Method method, boolean forceCompile) { - assert method.getAnnotation(Test.class) == null : "shouldn't parse method with @Test annotation: " + method; + protected InstalledCode getCodeBaseline(ResolvedJavaMethod javaMethod, boolean forceCompile) { + assert javaMethod.getAnnotation(Test.class) == null : "shouldn't parse method with @Test annotation: " + javaMethod; try (Scope bds = Debug.scope("Baseline")) { Debug.log("getCodeBaseline()"); @@ -533,8 +532,8 @@ protected void test(String name, Object... args) { try { - Method method = getMethod(name); - Object receiver = Modifier.isStatic(method.getModifiers()) ? null : this; + ResolvedJavaMethod method = getResolvedJavaMethod(name); + Object receiver = method.isStatic() ? null : this; test(method, receiver, args); } catch (AssumptionViolatedException e) { // Suppress so that subsequent calls to this method within the @@ -542,7 +541,7 @@ } } - protected void test(Method method, Object receiver, Object... args) { + protected void test(ResolvedJavaMethod method, Object receiver, Object... args) { Result expect = executeExpected(method, receiver, args); if (getCodeCache() == null) { return; @@ -550,19 +549,18 @@ testAgainstExpected(method, expect, receiver, args); } - protected void testAgainstExpected(Method method, Result expect, Object receiver, Object... args) { + protected void testAgainstExpected(ResolvedJavaMethod method, Result expect, Object receiver, Object... args) { testAgainstExpected(method, expect, Collections. emptySet(), receiver, args); } - protected Result executeActualCheckDeopt(Method method, Set shouldNotDeopt, Object receiver, Object... args) { + protected Result executeActualCheckDeopt(ResolvedJavaMethod method, Set shouldNotDeopt, Object receiver, Object... args) { Map deoptCounts = new EnumMap<>(DeoptimizationReason.class); - ResolvedJavaMethod javaMethod = getMetaAccess().lookupJavaMethod(method); - ProfilingInfo profile = javaMethod.getProfilingInfo(); + ProfilingInfo profile = method.getProfilingInfo(); for (DeoptimizationReason reason : shouldNotDeopt) { deoptCounts.put(reason, profile.getDeoptimizationCount(reason)); } Result actual = executeActual(method, receiver, args); - profile = javaMethod.getProfilingInfo(); // profile can change after execution + profile = method.getProfilingInfo(); // profile can change after execution for (DeoptimizationReason reason : shouldNotDeopt) { Assert.assertEquals((int) deoptCounts.get(reason), profile.getDeoptimizationCount(reason)); } @@ -583,7 +581,7 @@ } } - protected void testAgainstExpected(Method method, Result expect, Set shouldNotDeopt, Object receiver, Object... args) { + protected void testAgainstExpected(ResolvedJavaMethod method, Result expect, Set shouldNotDeopt, Object receiver, Object... args) { Result actual = executeActualCheckDeopt(method, shouldNotDeopt, receiver, args); assertEquals(expect, actual); } @@ -659,6 +657,46 @@ return getCodeCache().addMethod(method, compResult, null, null); } + private final Map methodMap = new HashMap<>(); + + /** + * Converts a reflection {@link Method} to a {@link ResolvedJavaMethod}. + */ + protected ResolvedJavaMethod asResolvedJavaMethod(Method method) { + ResolvedJavaMethod javaMethod = getMetaAccess().lookupJavaMethod(method); + methodMap.put(javaMethod, method); + return javaMethod; + } + + protected ResolvedJavaMethod getResolvedJavaMethod(String methodName) { + return asResolvedJavaMethod(getMethod(methodName)); + } + + protected ResolvedJavaMethod getResolvedJavaMethod(Class clazz, String methodName) { + return asResolvedJavaMethod(getMethod(clazz, methodName)); + } + + protected ResolvedJavaMethod getResolvedJavaMethod(Class clazz, String methodName, Class... parameterTypes) { + return asResolvedJavaMethod(getMethod(clazz, methodName, parameterTypes)); + } + + /** + * Gets the reflection {@link Method} from which a given {@link ResolvedJavaMethod} was created + * or null if {@code javaMethod} does not correspond to a reflection method. + */ + protected Method lookupMethod(ResolvedJavaMethod javaMethod) { + return methodMap.get(javaMethod); + } + + protected Object invoke(ResolvedJavaMethod javaMethod, Object receiver, Object... args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { + Method method = lookupMethod(javaMethod); + Assert.assertTrue(method != null); + if (!method.isAccessible()) { + method.setAccessible(true); + } + return method.invoke(receiver, args); + } + /** * Parses a Java method in {@linkplain GraphBuilderConfiguration#getDefault() default} mode to * produce a graph. @@ -666,15 +704,15 @@ * @param methodName the name of the method in {@code this.getClass()} to be parsed */ protected StructuredGraph parseProfiled(String methodName) { - return parseProfiled(getMethod(methodName)); + return parseProfiled(getResolvedJavaMethod(methodName)); } /** * Parses a Java method in {@linkplain GraphBuilderConfiguration#getDefault() default} mode to * produce a graph. */ - protected StructuredGraph parseProfiled(Method m) { - return parse0(m, getDefaultGraphBuilderSuite()); + protected StructuredGraph parseProfiled(ResolvedJavaMethod m) { + return parse1(m, getDefaultGraphBuilderSuite()); } /** @@ -684,28 +722,27 @@ * @param methodName the name of the method in {@code this.getClass()} to be parsed */ protected StructuredGraph parseEager(String methodName) { - return parseEager(getMethod(methodName)); + return parseEager(getResolvedJavaMethod(methodName)); } /** * Parses a Java method in {@linkplain GraphBuilderConfiguration#getEagerDefault() eager} mode * to produce a graph. */ - protected StructuredGraph parseEager(Method m) { - return parse0(m, getCustomGraphBuilderSuite(GraphBuilderConfiguration.getEagerDefault())); + protected StructuredGraph parseEager(ResolvedJavaMethod m) { + return parse1(m, getCustomGraphBuilderSuite(GraphBuilderConfiguration.getEagerDefault())); } /** * Parses a Java method in {@linkplain GraphBuilderConfiguration#getFullDebugDefault() full * debug} mode to produce a graph. */ - protected StructuredGraph parseDebug(Method m) { - return parse0(m, getCustomGraphBuilderSuite(GraphBuilderConfiguration.getFullDebugDefault())); + protected StructuredGraph parseDebug(ResolvedJavaMethod m) { + return parse1(m, getCustomGraphBuilderSuite(GraphBuilderConfiguration.getFullDebugDefault())); } - private StructuredGraph parse0(Method m, PhaseSuite graphBuilderSuite) { - assert m.getAnnotation(Test.class) == null : "shouldn't parse method with @Test annotation: " + m; - ResolvedJavaMethod javaMethod = getMetaAccess().lookupJavaMethod(m); + private StructuredGraph parse1(ResolvedJavaMethod javaMethod, PhaseSuite graphBuilderSuite) { + assert javaMethod.getAnnotation(Test.class) == null : "shouldn't parse method with @Test annotation: " + javaMethod; try (Scope ds = Debug.scope("Parsing", javaMethod)) { StructuredGraph graph = new StructuredGraph(javaMethod); graphBuilderSuite.apply(graph, new HighTierContext(providers, null, null, graphBuilderSuite, OptimisticOptimizations.ALL)); diff -r 6997fce99fa3 -r 86ec7f6f71b3 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 Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/InfopointReasonTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -26,14 +26,13 @@ import static com.oracle.graal.compiler.GraalCompiler.*; import static org.junit.Assert.*; -import java.lang.reflect.*; - import org.junit.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.code.CallingConvention.Type; import com.oracle.graal.api.code.CompilationResult.Call; import com.oracle.graal.api.code.CompilationResult.Infopoint; +import com.oracle.graal.api.meta.*; import com.oracle.graal.java.*; import com.oracle.graal.lir.asm.*; import com.oracle.graal.nodes.*; @@ -58,7 +57,7 @@ @Test public void callInfopoints() { - final Method method = getMethod("testMethod"); + final ResolvedJavaMethod method = getResolvedJavaMethod("testMethod"); final StructuredGraph graph = parseEager(method); CallingConvention cc = getCallingConvention(getCodeCache(), Type.JavaCallee, graph.method(), false); final CompilationResult cr = compileGraph(graph, null, cc, graph.method(), getProviders(), getBackend(), getCodeCache().getTarget(), null, getDefaultGraphBuilderSuite(), @@ -73,7 +72,7 @@ @Test public void lineInfopoints() { - final Method method = getMethod("testMethod"); + final ResolvedJavaMethod method = getResolvedJavaMethod("testMethod"); final StructuredGraph graph = parseDebug(method); int graphLineSPs = 0; for (FullInfopointNode ipn : graph.getNodes().filter(FullInfopointNode.class)) { diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/LockEliminationTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/LockEliminationTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/LockEliminationTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -22,11 +22,10 @@ */ package com.oracle.graal.compiler.test; -import java.lang.reflect.*; - import org.junit.*; import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.java.*; import com.oracle.graal.nodes.spi.*; @@ -88,7 +87,7 @@ } private StructuredGraph getGraph(String snippet) { - Method method = getMethod(snippet); + ResolvedJavaMethod method = getResolvedJavaMethod(snippet); StructuredGraph graph = parseEager(method); Assumptions assumptions = new Assumptions(true); HighTierContext context = new HighTierContext(getProviders(), assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL); diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryArithmeticTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryArithmeticTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/MemoryArithmeticTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -22,8 +22,6 @@ */ package com.oracle.graal.compiler.test; -import java.lang.reflect.*; - import org.junit.*; import com.oracle.graal.api.code.*; @@ -41,9 +39,9 @@ * Called before a test is executed. */ @Override - protected void before(Method method) { + protected void before(ResolvedJavaMethod method) { // don't let any null exception tracking change the generated code. - getMetaAccess().lookupJavaMethod(method).reprofile(); + method.reprofile(); } /** diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ProfilingInfoTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ProfilingInfoTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ProfilingInfoTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -23,7 +23,6 @@ package com.oracle.graal.compiler.test; import java.io.*; -import java.lang.reflect.*; import org.junit.*; @@ -307,17 +306,15 @@ } private ProfilingInfo profile(boolean resetProfile, int executions, String methodName, Object... args) { - Method method = getMethod(methodName); - Assert.assertTrue(Modifier.isStatic(method.getModifiers())); - - ResolvedJavaMethod javaMethod = getMetaAccess().lookupJavaMethod(method); + ResolvedJavaMethod javaMethod = getResolvedJavaMethod(methodName); + Assert.assertTrue(javaMethod.isStatic()); if (resetProfile) { javaMethod.reprofile(); } for (int i = 0; i < executions; ++i) { try { - method.invoke(null, args); + invoke(javaMethod, null, args); } catch (Throwable e) { Assert.fail("method should not throw an exception: " + e.toString()); } @@ -330,7 +327,7 @@ } private void resetProfile(String methodName) { - ResolvedJavaMethod javaMethod = getMetaAccess().lookupJavaMethod(getMethod(methodName)); + ResolvedJavaMethod javaMethod = getResolvedJavaMethod(methodName); javaMethod.reprofile(); } } diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ShortCircuitNodeTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ShortCircuitNodeTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ShortCircuitNodeTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -31,7 +31,7 @@ @Test public void test1() { // only executeActual, to avoid creating profiling information - executeActual(getMethod("test1Snippet"), 1, 2); + executeActual(getResolvedJavaMethod("test1Snippet"), 1, 2); } public static final TestClassInt field = null; diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/deopt/CompiledMethodTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/deopt/CompiledMethodTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/deopt/CompiledMethodTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -22,8 +22,6 @@ */ package com.oracle.graal.compiler.test.deopt; -import java.lang.reflect.*; - import org.junit.*; import com.oracle.graal.api.code.*; @@ -52,8 +50,8 @@ @Test public void test1() { - Method method = getMethod("testMethod"); - final StructuredGraph graph = parseEager(method); + final ResolvedJavaMethod javaMethod = getResolvedJavaMethod("testMethod"); + final StructuredGraph graph = parseEager(javaMethod); new CanonicalizerPhase(true).apply(graph, new PhaseContext(getProviders(), new Assumptions(false))); new DeadCodeEliminationPhase().apply(graph); @@ -63,7 +61,6 @@ } } - final ResolvedJavaMethod javaMethod = getMetaAccess().lookupJavaMethod(method); InstalledCode compiledMethod = getCode(javaMethod, graph); try { Object result = compiledMethod.executeVarargs("1", "2", "3"); @@ -75,9 +72,8 @@ @Test public void test3() { - Method method = getMethod("testMethod"); - final StructuredGraph graph = parseEager(method); - final ResolvedJavaMethod javaMethod = getMetaAccess().lookupJavaMethod(method); + final ResolvedJavaMethod javaMethod = getResolvedJavaMethod("testMethod"); + final StructuredGraph graph = parseEager(javaMethod); InstalledCode compiledMethod = getCode(javaMethod, graph); try { Object result = compiledMethod.executeVarargs("1", "2", "3"); @@ -89,9 +85,8 @@ @Test public void test4() { - Method method = getMethod("testMethodVirtual"); - final StructuredGraph graph = parseEager(method); - final ResolvedJavaMethod javaMethod = getMetaAccess().lookupJavaMethod(method); + final ResolvedJavaMethod javaMethod = getResolvedJavaMethod("testMethodVirtual"); + final StructuredGraph graph = parseEager(javaMethod); InstalledCode compiledMethod = getCode(javaMethod, graph); try { f1 = "0"; diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/deopt/MonitorDeoptTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/deopt/MonitorDeoptTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/deopt/MonitorDeoptTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -24,8 +24,6 @@ */ package com.oracle.graal.compiler.test.deopt; -import java.lang.reflect.*; - import org.junit.*; import com.oracle.graal.api.code.*; @@ -134,12 +132,11 @@ @Test public void run0() throws Throwable { - Method method = getMethod("test"); + ResolvedJavaMethod javaMethod = getResolvedJavaMethod("test"); - StructuredGraph graph = parseEager(method); + StructuredGraph graph = parseEager(javaMethod); removeLoopSafepoint(graph); - ResolvedJavaMethod javaMethod = getMetaAccess().lookupJavaMethod(method); CompilationResult compilationResult = compile(javaMethod, graph); final InstalledCode installedCode = getProviders().getCodeCache().setDefaultMethod(javaMethod, compilationResult); diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EATestBase.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EATestBase.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/ea/EATestBase.java Sat Oct 18 00:08:19 2014 +0200 @@ -148,7 +148,7 @@ } protected void prepareGraph(String snippet, final boolean iterativeEscapeAnalysis) { - ResolvedJavaMethod method = getMetaAccess().lookupJavaMethod(getMethod(snippet)); + ResolvedJavaMethod method = getResolvedJavaMethod(snippet); graph = new StructuredGraph(method); try (Scope s = Debug.scope(getClass(), graph, method, getCodeCache())) { new GraphBuilderPhase.Instance(getMetaAccess(), GraphBuilderConfiguration.getEagerDefault(), OptimisticOptimizations.ALL).apply(graph); diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/inlining/InliningTest.java --- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/inlining/InliningTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/inlining/InliningTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -24,11 +24,10 @@ import static org.junit.Assert.*; -import java.lang.reflect.*; - import org.junit.*; import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.test.*; import com.oracle.graal.debug.*; import com.oracle.graal.debug.Debug.Scope; @@ -231,7 +230,7 @@ private StructuredGraph getGraph(final String snippet, final boolean eagerInfopointMode) { try (Scope s = Debug.scope("InliningTest", new DebugDumpScope(snippet))) { - Method method = getMethod(snippet); + ResolvedJavaMethod method = getResolvedJavaMethod(snippet); StructuredGraph graph = eagerInfopointMode ? parseDebug(method) : parseEager(method); PhaseSuite graphBuilderSuite = eagerInfopointMode ? getCustomGraphBuilderSuite(GraphBuilderConfiguration.getFullDebugDefault()) : getDefaultGraphBuilderSuite(); Assumptions assumptions = new Assumptions(true); diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.hotspot.amd64.test/src/com/oracle/graal/hotspot/amd64/test/AMD64HotSpotFrameOmissionTest.java --- a/graal/com.oracle.graal.hotspot.amd64.test/src/com/oracle/graal/hotspot/amd64/test/AMD64HotSpotFrameOmissionTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.amd64.test/src/com/oracle/graal/hotspot/amd64/test/AMD64HotSpotFrameOmissionTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -24,7 +24,6 @@ import static com.oracle.graal.amd64.AMD64.*; -import java.lang.reflect.*; import java.util.*; import org.junit.*; @@ -102,9 +101,8 @@ } private void testHelper(String name, CodeGenerator gen) { - Method method = getMethod(name); - ResolvedJavaMethod javaMethod = getMetaAccess().lookupJavaMethod(method); - InstalledCode installedCode = getCode(javaMethod, parseEager(method)); + ResolvedJavaMethod javaMethod = getResolvedJavaMethod(name); + InstalledCode installedCode = getCode(javaMethod, parseEager(javaMethod)); TargetDescription target = getCodeCache().getTarget(); RegisterConfig registerConfig = getCodeCache().getRegisterConfig(); diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/CompressedOopTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/CompressedOopTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/CompressedOopTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -23,17 +23,14 @@ package com.oracle.graal.hotspot.test; -import java.lang.reflect.*; import java.util.*; import java.util.concurrent.atomic.*; import org.junit.*; import com.oracle.graal.api.meta.*; -import com.oracle.graal.api.runtime.*; import com.oracle.graal.compiler.test.*; import com.oracle.graal.hotspot.meta.*; -import com.oracle.graal.runtime.*; /** * The following tests perform object/array equality and assignments in various ways. The selected @@ -41,16 +38,9 @@ */ public class CompressedOopTest extends GraalCompilerTest { - private final MetaAccessProvider metaAccess; - - public CompressedOopTest() { - this.metaAccess = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders().getMetaAccess(); - } - private HotSpotInstalledCode getInstalledCode(String name, Class... parameterTypes) throws Exception { - final Method method = CompressedOopTest.class.getMethod(name, parameterTypes); - final HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaMethod(method); - final HotSpotInstalledCode installedBenchmarkCode = (HotSpotInstalledCode) getCode(javaMethod, parseEager(method)); + final ResolvedJavaMethod javaMethod = getResolvedJavaMethod(getClass(), name, parameterTypes); + final HotSpotInstalledCode installedBenchmarkCode = (HotSpotInstalledCode) getCode(javaMethod, parseEager(javaMethod)); return installedBenchmarkCode; } diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotNmethodTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotNmethodTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/HotSpotNmethodTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -36,7 +36,7 @@ @Test public void testInstallCodeInvalidation() { - final ResolvedJavaMethod testJavaMethod = getMetaAccess().lookupJavaMethod(getMethod("foo")); + final ResolvedJavaMethod testJavaMethod = getResolvedJavaMethod("foo"); final StructuredGraph graph = parseEager("otherFoo"); final HotSpotNmethod nmethod = (HotSpotNmethod) getCode(testJavaMethod, graph); Assert.assertTrue(nmethod.isValid()); @@ -60,7 +60,7 @@ @Test public void testInstallCodeInvalidationWhileRunning() { - final ResolvedJavaMethod testJavaMethod = getMetaAccess().lookupJavaMethod(getMethod("foo")); + final ResolvedJavaMethod testJavaMethod = getResolvedJavaMethod("foo"); final StructuredGraph graph = parseEager("otherFoo"); final HotSpotNmethod nmethod = (HotSpotNmethod) getCode(testJavaMethod, graph); Object result; @@ -75,7 +75,7 @@ @Test public void testInstalledCodeCalledFromCompiledCode() { - final ResolvedJavaMethod testJavaMethod = getMetaAccess().lookupJavaMethod(getMethod("foo")); + final ResolvedJavaMethod testJavaMethod = getResolvedJavaMethod("foo"); final StructuredGraph graph = parseEager("otherFoo"); final HotSpotNmethod nmethod = (HotSpotNmethod) getCode(testJavaMethod, graph); Assert.assertTrue(nmethod.isValid()); diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/InstalledCodeExecuteHelperTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/InstalledCodeExecuteHelperTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/InstalledCodeExecuteHelperTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -24,39 +24,28 @@ import static java.lang.reflect.Modifier.*; -import java.lang.reflect.*; - import org.junit.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; -import com.oracle.graal.api.runtime.*; import com.oracle.graal.compiler.test.*; import com.oracle.graal.hotspot.meta.*; import com.oracle.graal.nodes.*; -import com.oracle.graal.runtime.*; public class InstalledCodeExecuteHelperTest extends GraalCompilerTest { private static final int ITERATIONS = 100000; - private final MetaAccessProvider metaAccess; Object[] argsToBind; - public InstalledCodeExecuteHelperTest() { - this.metaAccess = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders().getMetaAccess(); - } - @Test - public void test1() throws NoSuchMethodException, SecurityException, InvalidInstalledCodeException { - final Method fooMethod = InstalledCodeExecuteHelperTest.class.getMethod("foo"); - final HotSpotResolvedJavaMethod fooJavaMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaMethod(fooMethod); - final HotSpotInstalledCode fooCode = (HotSpotInstalledCode) getCode(fooJavaMethod, parseEager(fooMethod)); + public void test1() throws InvalidInstalledCodeException { + final ResolvedJavaMethod fooMethod = getResolvedJavaMethod("foo"); + final HotSpotInstalledCode fooCode = (HotSpotInstalledCode) getCode(fooMethod, parseEager(fooMethod)); argsToBind = new Object[]{fooCode}; - final Method benchmarkMethod = InstalledCodeExecuteHelperTest.class.getMethod("benchmark", HotSpotInstalledCode.class); - final ResolvedJavaMethod benchmarkJavaMethod = metaAccess.lookupJavaMethod(benchmarkMethod); - final HotSpotInstalledCode installedBenchmarkCode = (HotSpotInstalledCode) getCode(benchmarkJavaMethod, parseEager(benchmarkMethod)); + final ResolvedJavaMethod benchmarkMethod = getResolvedJavaMethod("benchmark"); + final HotSpotInstalledCode installedBenchmarkCode = (HotSpotInstalledCode) getCode(benchmarkMethod, parseEager(benchmarkMethod)); Assert.assertEquals(Integer.valueOf(42), benchmark(fooCode)); @@ -79,12 +68,12 @@ } @Override - protected StructuredGraph parseEager(Method m) { + protected StructuredGraph parseEager(ResolvedJavaMethod m) { StructuredGraph graph = super.parseEager(m); if (argsToBind != null) { Object receiver = isStatic(m.getModifiers()) ? null : this; Object[] args = argsWithReceiver(receiver, argsToBind); - JavaType[] parameterTypes = getMetaAccess().lookupJavaMethod(m).toParameterTypes(); + JavaType[] parameterTypes = m.toParameterTypes(); assert parameterTypes.length == args.length; for (int i = 0; i < argsToBind.length; i++) { ParameterNode param = graph.getParameter(i); diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/MemoryUsageBenchmark.java Sat Oct 18 00:08:19 2014 +0200 @@ -128,7 +128,7 @@ } private void doCompilation(String methodName, String label) { - HotSpotResolvedJavaMethod method = (HotSpotResolvedJavaMethod) getMetaAccess().lookupJavaMethod(getMethod(methodName)); + HotSpotResolvedJavaMethod method = (HotSpotResolvedJavaMethod) getResolvedJavaMethod(methodName); HotSpotBackend backend = runtime().getHostBackend(); // invalidate any existing compiled code @@ -145,7 +145,7 @@ private void allocSpyCompilation(String methodName) { if (AllocSpy.isEnabled()) { - HotSpotResolvedJavaMethod method = (HotSpotResolvedJavaMethod) getMetaAccess().lookupJavaMethod(getMethod(methodName)); + HotSpotResolvedJavaMethod method = (HotSpotResolvedJavaMethod) getResolvedJavaMethod(methodName); HotSpotBackend backend = runtime().getHostBackend(); // invalidate any existing compiled code diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java --- a/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/WriteBarrierAdditionTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -25,15 +25,11 @@ import static com.oracle.graal.hotspot.replacements.HotSpotReplacementsUtil.*; import java.lang.ref.*; -import java.lang.reflect.*; - -import com.oracle.graal.phases.common.inlining.policy.InlineEverythingPolicy; import org.junit.*; import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; -import com.oracle.graal.api.runtime.*; import com.oracle.graal.compiler.common.*; import com.oracle.graal.compiler.test.*; import com.oracle.graal.debug.*; @@ -48,8 +44,8 @@ import com.oracle.graal.phases.*; import com.oracle.graal.phases.common.*; import com.oracle.graal.phases.common.inlining.*; +import com.oracle.graal.phases.common.inlining.policy.*; import com.oracle.graal.phases.tiers.*; -import com.oracle.graal.runtime.*; /** * The following unit tests assert the presence of write barriers for both Serial and G1 GCs. @@ -62,12 +58,6 @@ */ public class WriteBarrierAdditionTest extends GraalCompilerTest { - private final MetaAccessProvider metaAccess; - - public WriteBarrierAdditionTest() { - this.metaAccess = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders().getMetaAccess(); - } - public static class Container { public Container a; @@ -242,9 +232,8 @@ } private HotSpotInstalledCode getInstalledCode(String name) throws Exception { - final Method method = WriteBarrierAdditionTest.class.getMethod(name, Object.class, Object.class, Object.class); - final HotSpotResolvedJavaMethod javaMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaMethod(method); - final HotSpotInstalledCode installedBenchmarkCode = (HotSpotInstalledCode) getCode(javaMethod, parseEager(method)); + final ResolvedJavaMethod javaMethod = getResolvedJavaMethod(WriteBarrierAdditionTest.class, name, Object.class, Object.class, Object.class); + final HotSpotInstalledCode installedBenchmarkCode = (HotSpotInstalledCode) getCode(javaMethod, parseEager(javaMethod)); return installedBenchmarkCode; } diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/JTTTest.java --- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/JTTTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/JTTTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -24,7 +24,6 @@ import static java.lang.reflect.Modifier.*; -import java.lang.reflect.*; import java.util.*; import org.junit.*; @@ -57,12 +56,12 @@ } @Override - protected StructuredGraph parseEager(Method m) { + protected StructuredGraph parseEager(ResolvedJavaMethod m) { StructuredGraph graph = super.parseEager(m); if (argsToBind != null) { Object receiver = isStatic(m.getModifiers()) ? null : this; Object[] args = argsWithReceiver(receiver, argsToBind); - JavaType[] parameterTypes = getMetaAccess().lookupJavaMethod(m).toParameterTypes(); + JavaType[] parameterTypes = m.toParameterTypes(); assert parameterTypes.length == args.length; for (int i = 0; i < args.length; i++) { ParameterNode param = graph.getParameter(i); @@ -109,19 +108,19 @@ } protected void runTest(Set shouldNotDeopt, boolean bind, boolean noProfile, String name, Object... args) { - Method method = getMethod(name); - Object receiver = Modifier.isStatic(method.getModifiers()) ? null : this; + ResolvedJavaMethod method = getResolvedJavaMethod(name); + Object receiver = method.isStatic() ? null : this; Result expect = executeExpected(method, receiver, args); if (noProfile) { - getMetaAccess().lookupJavaMethod(method).reprofile(); + method.reprofile(); } testAgainstExpected(method, expect, shouldNotDeopt, receiver, args); if (args.length > 0 && bind) { if (noProfile) { - getMetaAccess().lookupJavaMethod(method).reprofile(); + method.reprofile(); } this.argsToBind = args; diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_field01.java --- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_field01.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_field01.java Sat Oct 18 00:08:19 2014 +0200 @@ -23,10 +23,9 @@ // Checkstyle: stop package com.oracle.graal.jtt.hotpath; -import java.lang.reflect.*; - import org.junit.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.jtt.*; /* @@ -51,7 +50,7 @@ } @Override - public void before(Method m) { + public void before(ResolvedJavaMethod m) { a = 0; b = 0; c = 0; diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_field03.java --- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_field03.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_field03.java Sat Oct 18 00:08:19 2014 +0200 @@ -23,10 +23,9 @@ // Checkstyle: stop package com.oracle.graal.jtt.hotpath; -import java.lang.reflect.*; - import org.junit.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.jtt.*; /* @@ -55,7 +54,7 @@ } @Override - public void before(Method m) { + public void before(ResolvedJavaMethod m) { b = 0; c = 0; s = 0; diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/Unsafe_compareAndSwap.java --- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/Unsafe_compareAndSwap.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/Unsafe_compareAndSwap.java Sat Oct 18 00:08:19 2014 +0200 @@ -22,12 +22,11 @@ */ package com.oracle.graal.jtt.jdk; -import java.lang.reflect.*; - import org.junit.*; import sun.misc.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.jtt.*; public class Unsafe_compareAndSwap extends JTTTest { @@ -56,7 +55,7 @@ private static final Unsafe_compareAndSwap instance = new Unsafe_compareAndSwap(); @Override - protected void before(Method m) { + protected void before(ResolvedJavaMethod m) { instance.value = "a"; } diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/LambdaEagerTest.java --- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/LambdaEagerTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/lang/LambdaEagerTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -62,19 +62,19 @@ @Test public void testEagerResolveNonCapturing01() { Result expected = new Result(3, null); - testAgainstExpected(getMethod("nonCapturing"), expected, UNRESOLVED_UNREACHED, 1, 2); + testAgainstExpected(getResolvedJavaMethod("nonCapturing"), expected, UNRESOLVED_UNREACHED, 1, 2); } @Test public void testEagerResolveNonCapturing02() { Result expected = new Result(3, null); - testAgainstExpected(getMethod("nonCapturing2"), expected, UNRESOLVED_UNREACHED, 1, 2); + testAgainstExpected(getResolvedJavaMethod("nonCapturing2"), expected, UNRESOLVED_UNREACHED, 1, 2); } @Test public void testEagerResolveCapturing() { Result expected = new Result(0, null); - testAgainstExpected(getMethod("capturing"), expected, UNRESOLVED_UNREACHED, 1, 2, 3); + testAgainstExpected(getResolvedJavaMethod("capturing"), expected, UNRESOLVED_UNREACHED, 1, 2, 3); } @Override diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopNewInstance.java --- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopNewInstance.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopNewInstance.java Sat Oct 18 00:08:19 2014 +0200 @@ -22,10 +22,9 @@ */ package com.oracle.graal.jtt.loop; -import java.lang.reflect.*; - import org.junit.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.jtt.*; /* @@ -57,7 +56,7 @@ } @Override - protected void before(Method m) { + protected void before(ResolvedJavaMethod m) { count = 0; } diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ConditionalElimination01.java --- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ConditionalElimination01.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ConditionalElimination01.java Sat Oct 18 00:08:19 2014 +0200 @@ -22,10 +22,9 @@ */ package com.oracle.graal.jtt.optimize; -import java.lang.reflect.*; - import org.junit.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.jtt.*; public class ConditionalElimination01 extends JTTTest { @@ -43,7 +42,7 @@ } @Override - protected void before(Method method) { + protected void before(ResolvedJavaMethod method) { super.before(method); x = 0; } diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/ArraysSubstitutionsTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/ArraysSubstitutionsTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/ArraysSubstitutionsTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -22,7 +22,6 @@ */ package com.oracle.graal.replacements.test; -import java.lang.reflect.*; import java.util.*; import org.junit.*; @@ -42,49 +41,6 @@ */ public class ArraysSubstitutionsTest extends MethodSubstitutionTest { - private static Object executeVarargsSafe(InstalledCode code, Object... args) { - try { - return code.executeVarargs(args); - } catch (InvalidInstalledCodeException e) { - throw new RuntimeException(e); - } - } - - private static Object invokeSafe(Method method, Object receiver, Object... args) { - method.setAccessible(true); - try { - Object result = method.invoke(receiver, args); - return result; - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - throw new RuntimeException(e); - } - } - - public void testSubstitution(String testMethodName, Class intrinsicClass, Class holder, String methodName, Class[] parameterTypes, boolean optional, Object[] args1, Object[] args2) { - Method realMethod = getMethod(holder, methodName, parameterTypes); - Method testMethod = getMethod(testMethodName); - StructuredGraph graph = test(testMethodName); - - // Check to see if the resulting graph contains the expected node - StructuredGraph replacement = getReplacements().getMethodSubstitution(getMetaAccess().lookupJavaMethod(realMethod)); - if (replacement == null && !optional) { - assertInGraph(graph, intrinsicClass); - } - - // Force compilation - InstalledCode code = getCode(getMetaAccess().lookupJavaMethod(testMethod), parseEager(testMethod)); - assert optional || code != null; - - for (int i = 0; i < args1.length; i++) { - Object arg1 = args1[i]; - Object arg2 = args2[i]; - // Verify that the original method and the substitution produce the same value - assertDeepEquals(invokeSafe(testMethod, null, arg1, arg2), invokeSafe(realMethod, null, arg1, arg2)); - // Verify that the generated code and the original produce the same value - assertDeepEquals(executeVarargsSafe(code, arg1, arg2), invokeSafe(realMethod, null, arg1, arg2)); - } - } - private static final int N = 10; @Test diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/CompiledExceptionHandlerTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/CompiledExceptionHandlerTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/CompiledExceptionHandlerTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -22,10 +22,9 @@ */ package com.oracle.graal.replacements.test; -import java.lang.reflect.*; - import org.junit.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.test.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.java.*; @@ -41,7 +40,7 @@ } @Override - protected StructuredGraph parseEager(Method m) { + protected StructuredGraph parseEager(ResolvedJavaMethod m) { StructuredGraph graph = super.parseEager(m); int handlers = graph.getNodes().filter(ExceptionObjectNode.class).count(); Assert.assertEquals(1, handlers); diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/DynamicNewArrayTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/DynamicNewArrayTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/DynamicNewArrayTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -26,6 +26,7 @@ import org.junit.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.test.*; /** @@ -73,7 +74,7 @@ @Test public void testStub() { - Method method = getMethod("dynamic"); + ResolvedJavaMethod method = getResolvedJavaMethod("dynamic"); // this will use the stub call because Element[] is not loaded Result actual1 = executeActual(method, null, Element.class, 7); // this call will use the fast path diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/EdgesTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/EdgesTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/EdgesTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -27,6 +27,7 @@ import org.junit.*; import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.test.*; import com.oracle.graal.graph.*; import com.oracle.graal.graph.Edges.Type; @@ -114,7 +115,8 @@ throw new RuntimeException(e); } - StructuredGraph g = parseProfiled(method); + ResolvedJavaMethod javaMethod = getMetaAccess().lookupJavaMethod(method); + StructuredGraph g = parseProfiled(javaMethod); Assumptions assumptions = new Assumptions(false); HighTierContext context = new HighTierContext(getProviders(), assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL); new InliningPhase(new CanonicalizerPhase(true)).apply(g, context); diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/MethodSubstitutionTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/MethodSubstitutionTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/MethodSubstitutionTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -23,7 +23,11 @@ package com.oracle.graal.replacements.test; import static org.junit.Assert.*; + +import java.lang.reflect.*; + import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.api.replacements.*; import com.oracle.graal.compiler.test.*; import com.oracle.graal.debug.*; @@ -43,7 +47,7 @@ public abstract class MethodSubstitutionTest extends GraalCompilerTest { protected StructuredGraph test(final String snippet) { - try (Scope s = Debug.scope("MethodSubstitutionTest", getMetaAccess().lookupJavaMethod(getMethod(snippet)))) { + try (Scope s = Debug.scope("MethodSubstitutionTest", getResolvedJavaMethod(snippet))) { StructuredGraph graph = parseEager(snippet); Assumptions assumptions = new Assumptions(true); HighTierContext context = new HighTierContext(getProviders(), assumptions, null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.ALL); @@ -69,6 +73,32 @@ return graph; } + protected void testSubstitution(String testMethodName, Class intrinsicClass, Class holder, String methodName, Class[] parameterTypes, boolean optional, Object[] args1, Object[] args2) { + ResolvedJavaMethod realMethod = getResolvedJavaMethod(holder, methodName, parameterTypes); + ResolvedJavaMethod testMethod = getResolvedJavaMethod(testMethodName); + StructuredGraph graph = test(testMethodName); + + // Check to see if the resulting graph contains the expected node + StructuredGraph replacement = getReplacements().getMethodSubstitution(realMethod); + if (replacement == null && !optional) { + assertInGraph(graph, intrinsicClass); + } + + // Force compilation + InstalledCode code = getCode(testMethod, parseEager(testMethod)); + assert optional || code != null; + + for (int i = 0; i < args1.length; i++) { + Object arg1 = args1[i]; + Object arg2 = args2[i]; + Object expected = invokeSafe(realMethod, null, arg1, arg2); + // Verify that the original method and the substitution produce the same value + assertDeepEquals(expected, invokeSafe(testMethod, null, arg1, arg2)); + // Verify that the generated code and the original produce the same value + assertDeepEquals(expected, executeVarargsSafe(code, arg1, arg2)); + } + } + protected static StructuredGraph assertInGraph(StructuredGraph graph, Class clazz) { for (Node node : graph.getNodes()) { if (clazz.isInstance(node)) { @@ -78,4 +108,21 @@ fail("Graph does not contain a node of class " + clazz.getName()); return graph; } + + protected static Object executeVarargsSafe(InstalledCode code, Object... args) { + try { + return code.executeVarargs(args); + } catch (InvalidInstalledCodeException e) { + throw new RuntimeException(e); + } + } + + protected Object invokeSafe(ResolvedJavaMethod method, Object receiver, Object... args) { + try { + return invoke(method, receiver, args); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + throw new RuntimeException(e); + } + } + } diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/NewMultiArrayTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/NewMultiArrayTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/NewMultiArrayTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -71,7 +71,7 @@ } @Override - protected Object referenceInvoke(Method method, Object receiver, Object... args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { + protected Object referenceInvoke(ResolvedJavaMethod method, Object receiver, Object... args) throws IllegalAccessException, IllegalArgumentException, InvocationTargetException { if (bottomType != null) { try { return Array.newInstance(bottomClass, dimensions); diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/ObjectAccessTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/ObjectAccessTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/ObjectAccessTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -22,8 +22,6 @@ */ package com.oracle.graal.replacements.test; -import java.lang.reflect.*; - import org.junit.*; import com.oracle.graal.api.code.*; @@ -53,9 +51,8 @@ private static final ThreadLocal inliningPolicy = new ThreadLocal<>(); @Override - protected StructuredGraph parseEager(Method m) { - ResolvedJavaMethod resolvedMethod = getMetaAccess().lookupJavaMethod(m); - return installer.makeGraph(resolvedMethod, null, inliningPolicy.get(), FrameStateProcessing.CollapseFrameForSingleSideEffect); + protected StructuredGraph parseEager(ResolvedJavaMethod m) { + return installer.makeGraph(m, null, inliningPolicy.get(), FrameStateProcessing.CollapseFrameForSingleSideEffect); } @Test diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/PointerTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/PointerTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/PointerTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -22,8 +22,6 @@ */ package com.oracle.graal.replacements.test; -import java.lang.reflect.*; - import org.junit.*; import com.oracle.graal.api.code.*; @@ -59,9 +57,8 @@ private static final ThreadLocal inliningPolicy = new ThreadLocal<>(); @Override - protected StructuredGraph parseEager(Method m) { - ResolvedJavaMethod resolvedMethod = getMetaAccess().lookupJavaMethod(m); - return installer.makeGraph(resolvedMethod, null, inliningPolicy.get(), FrameStateProcessing.CollapseFrameForSingleSideEffect); + protected StructuredGraph parseEager(ResolvedJavaMethod m) { + return installer.makeGraph(m, null, inliningPolicy.get(), FrameStateProcessing.CollapseFrameForSingleSideEffect); } @Test diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/StandardMethodSubstitutionsTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/StandardMethodSubstitutionsTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/StandardMethodSubstitutionsTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -22,11 +22,10 @@ */ package com.oracle.graal.replacements.test; -import java.lang.reflect.*; - import org.junit.*; import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.api.replacements.*; import com.oracle.graal.nodes.*; import com.oracle.graal.nodes.calc.*; @@ -64,43 +63,26 @@ // Math.pow(value, 13); } - private static Object executeVarargsSafe(InstalledCode code, Object... args) { - try { - return code.executeVarargs(args); - } catch (InvalidInstalledCodeException e) { - throw new RuntimeException(e); - } - } - - private static Object invokeSafe(Method method, Object... args) { - method.setAccessible(true); - try { - Object result = method.invoke(null, args); - return result; - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - throw new RuntimeException(e); - } - } - public void testSubstitution(String testMethodName, Class intrinsicClass, Class holder, String methodName, boolean optional, Object... args) { - Method realMethod = getMethod(holder, methodName); - Method testMethod = getMethod(testMethodName); + ResolvedJavaMethod realJavaMethod = getResolvedJavaMethod(holder, methodName); + ResolvedJavaMethod testJavaMethod = getResolvedJavaMethod(testMethodName); StructuredGraph graph = test(testMethodName); // Check to see if the resulting graph contains the expected node - StructuredGraph replacement = getReplacements().getMethodSubstitution(getMetaAccess().lookupJavaMethod(realMethod)); + StructuredGraph replacement = getReplacements().getMethodSubstitution(realJavaMethod); if (replacement == null && !optional) { assertInGraph(graph, intrinsicClass); } // Force compilation - InstalledCode code = getCode(getMetaAccess().lookupJavaMethod(testMethod), parseEager(testMethod)); + InstalledCode code = getCode(testJavaMethod, parseEager(testJavaMethod)); assert optional || code != null; for (Object l : args) { // Verify that the original method and the substitution produce the same value - assertDeepEquals(invokeSafe(testMethod, l), invokeSafe(realMethod, l)); + Object expected = invokeSafe(realJavaMethod, null, l); + assertDeepEquals(expected, invokeSafe(testJavaMethod, null, l)); // Verify that the generated code and the original produce the same value - assertDeepEquals(executeVarargsSafe(code, l), invokeSafe(realMethod, l)); + assertDeepEquals(expected, executeVarargsSafe(code, l)); } } diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/StringSubstitutionsTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/StringSubstitutionsTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/StringSubstitutionsTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -22,11 +22,10 @@ */ package com.oracle.graal.replacements.test; -import java.lang.reflect.*; - import org.junit.*; import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.nodes.*; import com.oracle.graal.replacements.*; import com.oracle.graal.replacements.nodes.*; @@ -36,46 +35,29 @@ */ public class StringSubstitutionsTest extends MethodSubstitutionTest { - private static Object executeVarargsSafe(InstalledCode code, Object... args) { - try { - return code.executeVarargs(args); - } catch (InvalidInstalledCodeException e) { - throw new RuntimeException(e); - } - } - - private static Object invokeSafe(Method method, Object receiver, Object... args) { - method.setAccessible(true); - try { - Object result = method.invoke(receiver, args); - return result; - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - throw new RuntimeException(e); - } - } - public void testSubstitution(String testMethodName, Class intrinsicClass, Class holder, String methodName, boolean optional, Object[] args1, Object[] args2) { - Method realMethod = getMethod(holder, methodName); - Method testMethod = getMethod(testMethodName); + ResolvedJavaMethod realMethod = getResolvedJavaMethod(holder, methodName); + ResolvedJavaMethod testMethod = getResolvedJavaMethod(testMethodName); StructuredGraph graph = test(testMethodName); // Check to see if the resulting graph contains the expected node - StructuredGraph replacement = getReplacements().getMethodSubstitution(getMetaAccess().lookupJavaMethod(realMethod)); + StructuredGraph replacement = getReplacements().getMethodSubstitution(realMethod); if (replacement == null && !optional) { assertInGraph(graph, intrinsicClass); } // Force compilation - InstalledCode code = getCode(getMetaAccess().lookupJavaMethod(testMethod), parseEager(testMethod)); + InstalledCode code = getCode(testMethod, parseEager(testMethod)); assert optional || code != null; for (int i = 0; i < args1.length; i++) { Object arg1 = args1[i]; Object arg2 = args2[i]; + Object expected = invokeSafe(realMethod, arg1, arg2); // Verify that the original method and the substitution produce the same value - assertDeepEquals(invokeSafe(testMethod, null, arg1, arg2), invokeSafe(realMethod, arg1, arg2)); + assertDeepEquals(expected, invokeSafe(testMethod, null, arg1, arg2)); // Verify that the generated code and the original produce the same value - assertDeepEquals(executeVarargsSafe(code, arg1, arg2), invokeSafe(realMethod, arg1, arg2)); + assertDeepEquals(expected, executeVarargsSafe(code, arg1, arg2)); } } diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/UnsafeSubstitutionsTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/UnsafeSubstitutionsTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/UnsafeSubstitutionsTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -33,6 +33,7 @@ import sun.misc.*; import com.oracle.graal.api.code.*; +import com.oracle.graal.api.meta.*; import com.oracle.graal.replacements.*; /** @@ -40,29 +41,12 @@ */ public class UnsafeSubstitutionsTest extends MethodSubstitutionTest { - private static Object executeVarargsSafe(InstalledCode code, Object... args) { - try { - return code.executeVarargs(args); - } catch (InvalidInstalledCodeException e) { - throw new RuntimeException(e); - } - } - - private static Object invokeSafe(Method method, Object receiver, Object... args) { - method.setAccessible(true); - try { - return method.invoke(receiver, args); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - throw new RuntimeException(e); - } - } - public void testSubstitution(String testMethodName, Class holder, String methodName, Class[] parameterTypes, Object receiver, Object[] args1, Object[] args2) { - Method originalMethod = getMethod(holder, methodName, parameterTypes); - Method testMethod = getMethod(testMethodName); + ResolvedJavaMethod testMethod = getResolvedJavaMethod(testMethodName); + ResolvedJavaMethod originalMethod = getResolvedJavaMethod(holder, methodName, parameterTypes); // Force compilation - InstalledCode code = getCode(getMetaAccess().lookupJavaMethod(testMethod), parseEager(testMethod)); + InstalledCode code = getCode(testMethod, parseEager(testMethod)); assert code != null; // Verify that the original method and the substitution produce the same value diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/WordTest.java --- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/WordTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/WordTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -22,8 +22,6 @@ */ package com.oracle.graal.replacements.test; -import java.lang.reflect.*; - import org.junit.*; import com.oracle.graal.api.code.*; @@ -49,9 +47,8 @@ private static final ThreadLocal inliningPolicy = new ThreadLocal<>(); @Override - protected StructuredGraph parseEager(Method m) { - ResolvedJavaMethod resolvedMethod = getMetaAccess().lookupJavaMethod(m); - return installer.makeGraph(resolvedMethod, null, inliningPolicy.get(), FrameStateProcessing.CollapseFrameForSingleSideEffect); + protected StructuredGraph parseEager(ResolvedJavaMethod m) { + return installer.makeGraph(m, null, inliningPolicy.get(), FrameStateProcessing.CollapseFrameForSingleSideEffect); } @Test diff -r 6997fce99fa3 -r 86ec7f6f71b3 graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalTest.java --- a/graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalTest.java Fri Oct 17 13:33:31 2014 +0200 +++ b/graal/com.oracle.graal.test/src/com/oracle/graal/test/GraalTest.java Sat Oct 18 00:08:19 2014 +0200 @@ -22,13 +22,14 @@ */ package com.oracle.graal.test; +import static org.junit.Assert.*; + import java.io.*; import java.lang.reflect.*; import java.util.*; import org.junit.*; import org.junit.internal.*; -import static org.junit.Assert.*; /** * Base class for Graal tests.