changeset 9685:aee2685c8d07

Merge.
author Doug Simon <doug.simon@oracle.com>
date Tue, 14 May 2013 15:45:55 +0200
parents 35212baf46e5 (current diff) 86d24f120b78 (diff)
children 120b2ac480b7
files
diffstat 7 files changed, 42 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java	Tue May 14 11:19:35 2013 +0200
+++ b/graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java	Tue May 14 15:45:55 2013 +0200
@@ -366,9 +366,7 @@
     @Override
     public void emitNullCheck(ValueNode v, DeoptimizingNode deoping) {
         assert v.kind() == Kind.Object;
-        Variable obj = newVariable(Kind.Object);
-        emitMove(obj, operand(v));
-        append(new AMD64Move.NullCheckOp(obj, state(deoping)));
+        append(new AMD64Move.NullCheckOp(load(operand(v)), state(deoping)));
     }
 
     @Override
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Tue May 14 11:19:35 2013 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Tue May 14 15:45:55 2013 +0200
@@ -77,8 +77,8 @@
     protected final Backend backend;
 
     public GraalCompilerTest() {
+        this.replacements = Graal.getRequiredCapability(Replacements.class);
         this.runtime = Graal.getRequiredCapability(GraalCodeCacheProvider.class);
-        this.replacements = Graal.getRequiredCapability(Replacements.class);
         this.backend = Graal.getRequiredCapability(Backend.class);
     }
 
@@ -247,12 +247,17 @@
             this.returnValue = returnValue;
             this.exception = exception;
         }
+
+        @Override
+        public String toString() {
+            return exception == null ? returnValue == null ? "null" : returnValue.toString() : "!" + exception;
+        }
     }
 
     /**
      * Called before a test is executed.
      */
-    protected void before() {
+    protected void before(@SuppressWarnings("unused") Method method) {
     }
 
     /**
@@ -262,7 +267,7 @@
     }
 
     protected Result executeExpected(Method method, Object receiver, Object... args) {
-        before();
+        before(method);
         try {
             // This gives us both the expected return value as well as ensuring that the method to
             // be compiled is fully resolved
@@ -277,7 +282,7 @@
     }
 
     protected Result executeActual(Method method, Object receiver, Object... args) {
-        before();
+        before(method);
         Object[] executeArgs = argsWithReceiver(receiver, args);
 
         ResolvedJavaMethod javaMethod = runtime.lookupJavaMethod(method);
@@ -347,11 +352,24 @@
     }
 
     protected void test(Method method, Result expect, Object receiver, Object... args) {
+        test(method, expect, Collections.<DeoptimizationReason> emptySet(), receiver, args);
+    }
+
+    protected void test(Method method, Result expect, Set<DeoptimizationReason> shouldNotDeopt, Object receiver, Object... args) {
+        Map<DeoptimizationReason, Integer> deoptCounts = new EnumMap<>(DeoptimizationReason.class);
+        ProfilingInfo profile = runtime.lookupJavaMethod(method).getProfilingInfo();
+        for (DeoptimizationReason reason : shouldNotDeopt) {
+            deoptCounts.put(reason, profile.getDeoptimizationCount(reason));
+        }
         Result actual = executeActual(method, receiver, args);
+        for (DeoptimizationReason reason : shouldNotDeopt) {
+            Assert.assertEquals((int) deoptCounts.get(reason), profile.getDeoptimizationCount(reason));
+        }
 
         if (expect.exception != null) {
             Assert.assertTrue("expected " + expect.exception, actual.exception != null);
             Assert.assertEquals(expect.exception.getClass(), actual.exception.getClass());
+            Assert.assertEquals(expect.exception.getMessage(), actual.exception.getMessage());
         } else {
             if (actual.exception != null) {
                 actual.exception.printStackTrace();
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/JTTTest.java	Tue May 14 11:19:35 2013 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/JTTTest.java	Tue May 14 15:45:55 2013 +0200
@@ -26,6 +26,7 @@
 import static java.lang.reflect.Modifier.*;
 
 import java.lang.reflect.*;
+import java.util.*;
 
 import org.junit.*;
 
@@ -93,15 +94,19 @@
     }
 
     protected void runTest(String name, Object... args) {
+        runTest(Collections.<DeoptimizationReason> emptySet(), name, args);
+    }
+
+    protected void runTest(Set<DeoptimizationReason> shoutNotDeopt, String name, Object... args) {
         Method method = getMethod(name);
         Object receiver = Modifier.isStatic(method.getModifiers()) ? null : this;
 
         Result expect = executeExpected(method, receiver, args);
 
-        test(method, expect, receiver, args);
+        test(method, expect, shoutNotDeopt, receiver, args);
         if (args.length > 0) {
             this.argsToBind = args;
-            test(method, expect, receiver, args);
+            test(method, expect, shoutNotDeopt, receiver, args);
             this.argsToBind = null;
         }
     }
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_field01.java	Tue May 14 11:19:35 2013 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_field01.java	Tue May 14 15:45:55 2013 +0200
@@ -23,6 +23,8 @@
 // Checkstyle: stop
 package com.oracle.graal.jtt.hotpath;
 
+import java.lang.reflect.*;
+
 import com.oracle.graal.jtt.*;
 import org.junit.*;
 
@@ -48,7 +50,7 @@
     }
 
     @Override
-    public void before() {
+    public void before(Method m) {
         a = 0;
         b = 0;
         c = 0;
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_field03.java	Tue May 14 11:19:35 2013 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_field03.java	Tue May 14 15:45:55 2013 +0200
@@ -23,6 +23,8 @@
 // Checkstyle: stop
 package com.oracle.graal.jtt.hotpath;
 
+import java.lang.reflect.*;
+
 import com.oracle.graal.jtt.*;
 import org.junit.*;
 
@@ -52,7 +54,7 @@
     }
 
     @Override
-    public void before() {
+    public void before(Method m) {
         b = 0;
         c = 0;
         s = 0;
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/Unsafe_compareAndSwap.java	Tue May 14 11:19:35 2013 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/Unsafe_compareAndSwap.java	Tue May 14 15:45:55 2013 +0200
@@ -22,6 +22,8 @@
  */
 package com.oracle.graal.jtt.jdk;
 
+import java.lang.reflect.*;
+
 import org.junit.*;
 
 import com.oracle.graal.jtt.*;
@@ -54,7 +56,7 @@
     private static final Unsafe_compareAndSwap instance = new Unsafe_compareAndSwap();
 
     @Override
-    protected void before() {
+    protected void before(Method m) {
         instance.value = "a";
     }
 
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopNewInstance.java	Tue May 14 11:19:35 2013 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopNewInstance.java	Tue May 14 15:45:55 2013 +0200
@@ -22,6 +22,8 @@
  */
 package com.oracle.graal.jtt.loop;
 
+import java.lang.reflect.*;
+
 import com.oracle.graal.jtt.*;
 import org.junit.*;
 
@@ -54,7 +56,7 @@
     }
 
     @Override
-    protected void before() {
+    protected void before(Method m) {
         count = 0;
     }