# HG changeset patch # User Lukas Stadler # Date 1368541264 -7200 # Node ID 120b2ac480b7a9b96fb51ed3fd0322ad13f9906b # Parent 0d0645267c32d3db2cc520ab9263f37f4a653fc6# Parent aee2685c8d07edddac737aa38ab4325dccb298f1 Merge diff -r 0d0645267c32 -r 120b2ac480b7 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 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. emptySet(), receiver, args); + } + + protected void test(Method method, Result expect, Set shouldNotDeopt, Object receiver, Object... args) { + Map 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(); diff -r 0d0645267c32 -r 120b2ac480b7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/ExceptionHandlerStub.java --- 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"); } diff -r 0d0645267c32 -r 120b2ac480b7 graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/stubs/UnwindExceptionToCallerStub.java --- 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"); } diff -r 0d0645267c32 -r 120b2ac480b7 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 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. emptySet(), name, args); + } + + protected void runTest(Set 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; } } diff -r 0d0645267c32 -r 120b2ac480b7 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 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; diff -r 0d0645267c32 -r 120b2ac480b7 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 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; diff -r 0d0645267c32 -r 120b2ac480b7 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 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"; } diff -r 0d0645267c32 -r 120b2ac480b7 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 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; } diff -r 0d0645267c32 -r 120b2ac480b7 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/InliningUtil.java --- 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 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();