changeset 8233:9484e7602276

GraalCompilerTest should assert that parameters passed to executeActual have the right type.
author Gilles Duboscq <duboscq@ssw.jku.at>
date Wed, 13 Mar 2013 17:39:27 +0100
parents ab374f69e4e8
children 0e008317f8ed
files graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/JTTTest.java
diffstat 2 files changed, 24 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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()));
                 }
--- 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.*;
 
 /**