# HG changeset patch # User Doug Simon # Date 1368539155 -7200 # Node ID aee2685c8d07edddac737aa38ab4325dccb298f1 # Parent 35212baf46e53c870d2fbd7de5abb3ab41c43a20# Parent 86d24f120b788bb01d91cb52b9a3003e6f14ec84 Merge. diff -r 35212baf46e5 -r aee2685c8d07 graal/com.oracle.graal.compiler.amd64/src/com/oracle/graal/compiler/amd64/AMD64LIRGenerator.java --- 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 diff -r 35212baf46e5 -r aee2685c8d07 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 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. 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 35212baf46e5 -r aee2685c8d07 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 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. 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 35212baf46e5 -r aee2685c8d07 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 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; diff -r 35212baf46e5 -r aee2685c8d07 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 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; diff -r 35212baf46e5 -r aee2685c8d07 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 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"; } diff -r 35212baf46e5 -r aee2685c8d07 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 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; }