changeset 9689:120b2ac480b7

Merge
author Lukas Stadler <lukas.stadler@jku.at>
date Tue, 14 May 2013 16:21:04 +0200
parents 0d0645267c32 (current diff) aee2685c8d07 (diff)
children a7f10828c4ff 83dcd76c27f1
files
diffstat 9 files changed, 56 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Tue May 14 15:56:56 2013 +0200
+++ b/graal/com.oracle.graal.compiler.test/src/com/oracle/graal/compiler/test/GraalCompilerTest.java	Tue May 14 16:21:04 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.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java	Tue May 14 15:56:56 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java	Tue May 14 16:21:04 2013 +0200
@@ -73,7 +73,7 @@
         if (logging()) {
             printf("handling exception %p (", Word.fromObject(exception).rawValue());
             decipher(Word.fromObject(exception).rawValue());
-            printf(") at %p (", Word.fromObject(exception).rawValue(), exceptionPc.rawValue());
+            printf(") at %p (", exceptionPc.rawValue());
             decipher(exceptionPc.rawValue());
             printf(")\n");
         }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UnwindExceptionToCallerStub.java	Tue May 14 15:56:56 2013 +0200
+++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UnwindExceptionToCallerStub.java	Tue May 14 16:21:04 2013 +0200
@@ -66,7 +66,7 @@
         if (logging()) {
             printf("unwinding exception %p (", exceptionOop.rawValue());
             decipher(exceptionOop.rawValue());
-            printf(") at %p (", exceptionOop.rawValue(), returnAddress.rawValue());
+            printf(") at %p (", returnAddress.rawValue());
             decipher(returnAddress.rawValue());
             printf(")\n");
         }
--- a/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/JTTTest.java	Tue May 14 15:56:56 2013 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/JTTTest.java	Tue May 14 16:21:04 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 15:56:56 2013 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_field01.java	Tue May 14 16:21:04 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 15:56:56 2013 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/hotpath/HP_field03.java	Tue May 14 16:21:04 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 15:56:56 2013 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/Unsafe_compareAndSwap.java	Tue May 14 16:21:04 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 15:56:56 2013 +0200
+++ b/graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/loop/LoopNewInstance.java	Tue May 14 16:21:04 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;
     }
 
--- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java	Tue May 14 15:56:56 2013 +0200
+++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java	Tue May 14 16:21:04 2013 +0200
@@ -33,6 +33,7 @@
 import com.oracle.graal.api.meta.ResolvedJavaType.Representation;
 import com.oracle.graal.debug.*;
 import com.oracle.graal.graph.*;
+import com.oracle.graal.graph.Node.*;
 import com.oracle.graal.nodes.*;
 import com.oracle.graal.nodes.calc.*;
 import com.oracle.graal.nodes.extended.*;
@@ -1267,6 +1268,8 @@
                     monitor.setLockDepth(monitor.getLockDepth() + callerLockDepth);
                 }
             }
+        } else {
+            assert checkContainsOnlyInvalidOrAfterFrameState(duplicates);
         }
         Node returnValue = null;
         if (returnNode != null) {
@@ -1289,6 +1292,16 @@
         return duplicates;
     }
 
+    private static boolean checkContainsOnlyInvalidOrAfterFrameState(Map<Node, Node> duplicates) {
+        for (Node node : duplicates.values()) {
+            if (node instanceof FrameState) {
+                FrameState frameState = (FrameState) node;
+                assert frameState.bci == FrameState.AFTER_BCI || frameState.bci == FrameState.INVALID_FRAMESTATE_BCI : node.toString(Verbosity.Debugger);
+            }
+        }
+        return true;
+    }
+
     public static void receiverNullCheck(Invoke invoke) {
         MethodCallTargetNode callTarget = (MethodCallTargetNode) invoke.callTarget();
         StructuredGraph graph = callTarget.graph();