# HG changeset patch # User Gilles Duboscq # Date 1363192767 -3600 # Node ID 9484e7602276ccfcbfdc49937f1085161a518ab5 # Parent ab374f69e4e86214cb0b63d67259266184a60fb6 GraalCompilerTest should assert that parameters passed to executeActual have the right type. diff -r ab374f69e4e8 -r 9484e7602276 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 13 17:06:30 2013 +0100 +++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java Wed Mar 13 17:39:27 2013 +0100 @@ -263,7 +263,10 @@ before(); Object[] executeArgs = argsWithReceiver(receiver, args); - InstalledCode compiledMethod = getCode(runtime.lookupJavaMethod(method), parse(method)); + ResolvedJavaMethod javaMethod = runtime.lookupJavaMethod(method); + checkArgs(javaMethod, executeArgs); + + InstalledCode compiledMethod = getCode(javaMethod, parse(method)); try { return new Result(compiledMethod.executeVarargs(executeArgs), null); } catch (Throwable e) { @@ -273,6 +276,25 @@ } } + protected void checkArgs(ResolvedJavaMethod method, Object[] args) { + JavaType[] sig = MetaUtil.signatureToTypes(method); + Assert.assertEquals(sig.length, args.length); + for (int i = 0; i < args.length; i++) { + JavaType javaType = sig[i]; + Kind kind = javaType.getKind(); + Object arg = args[i]; + if (kind == Kind.Object) { + if (arg != null && javaType instanceof ResolvedJavaType) { + ResolvedJavaType resolvedJavaType = (ResolvedJavaType) javaType; + Assert.assertTrue(resolvedJavaType + " from " + runtime.lookupJavaType(arg.getClass()), resolvedJavaType.isAssignableFrom(runtime.lookupJavaType(arg.getClass()))); + } + } else { + Assert.assertNotNull(arg); + Assert.assertEquals(kind.toBoxedJavaClass(), arg.getClass()); + } + } + } + /** * Prepends a non-null receiver argument to a given list or args. * @@ -372,8 +394,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(), backend, runtime().getTarget(), method, graph, null, phasePlan, OptimisticOptimizations.ALL, - new SpeculationLog()); + CompilationResult compResult = GraalCompiler.compileMethod(runtime(), backend, runtime().getTarget(), method, graph, null, phasePlan, OptimisticOptimizations.ALL, new SpeculationLog()); if (printCompilation) { TTY.println(String.format("@%-6d Graal %-70s %-45s %-50s | %4dms %5dB", id, "", "", "", System.currentTimeMillis() - start, compResult.getTargetCodeSize())); } diff -r ab374f69e4e8 -r 9484e7602276 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 Wed Mar 13 17:06:30 2013 +0100 +++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/JTTTest.java Wed Mar 13 17:39:27 2013 +0100 @@ -32,7 +32,6 @@ import com.oracle.graal.api.code.*; import com.oracle.graal.api.meta.*; import com.oracle.graal.compiler.test.*; -import com.oracle.graal.compiler.test.GraalCompilerTest.*; import com.oracle.graal.nodes.*; /**