--- old/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/GraalOSRLockTest.java 2017-11-03 23:56:33.158852501 -0700 +++ new/src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/GraalOSRLockTest.java 2017-11-03 23:56:32.830837823 -0700 @@ -24,11 +24,13 @@ import java.lang.management.ManagementFactory; import java.lang.management.MonitorInfo; +import java.lang.management.RuntimeMXBean; import java.lang.management.ThreadInfo; import java.lang.management.ThreadMXBean; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import org.graalvm.compiler.api.directives.GraalDirectives; import org.graalvm.compiler.core.phases.HighTier; @@ -44,6 +46,7 @@ import jdk.vm.ci.meta.ResolvedJavaMethod; import org.junit.Assume; +import org.junit.BeforeClass; /** * Test on-stack-replacement with locks. @@ -51,13 +54,28 @@ public class GraalOSRLockTest extends GraalOSRTestBase { private static boolean TestInSeparateThread = false; + private static final String COMPILE_ONLY_FLAG = "-Xcomp"; - public GraalOSRLockTest() { + @BeforeClass + public static void checkVMArguments() { try { Class.forName("java.lang.management.ManagementFactory"); } catch (ClassNotFoundException ex) { Assume.assumeNoException("cannot check for monitors without java.management JDK9 module", ex); } + /* + * Note: The -Xcomp execution mode of the VM will stop most of the OSR test cases from + * working as every method is compiled at level3 (followed by level4 on the second + * invocation). The tests in this class are written in a way that they expect a method to be + * executed at the invocation BCI with the interpreter and then perform an OSR to an + * installed nmethod at a given BCI. + * + */ + RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean(); + List arguments = runtimeMxBean.getInputArguments(); + for (String arg : arguments) { + Assume.assumeFalse(arg.equals(COMPILE_ONLY_FLAG)); + } } // testing only @@ -438,7 +456,7 @@ } GraalDirectives.controlFlowAnchor(); if (!GraalDirectives.inCompiledCode()) { - throw new Error("Must part of compiled code"); + throw new Error("Must be part of compiled code"); } return ret; } @@ -449,11 +467,11 @@ ReturnValue ret = ReturnValue.FAILURE; synchronized (lock) { synchronized (lock1) { - for (int i = 1; i < limit; i++) { + for (int i = 1; i < 10 * limit; i++) { GraalDirectives.blackhole(i); - if (i % 1001 == 0) { + if (i % 33 == 0) { ret = ReturnValue.SUCCESS; - if (GraalDirectives.inCompiledCode() && i + 33 > (limit)) { + if (GraalDirectives.inCompiledCode() && i + 33 > (10 * limit)) { GraalDirectives.blackhole(ret); System.gc(); } @@ -462,7 +480,7 @@ } GraalDirectives.controlFlowAnchor(); if (!GraalDirectives.inCompiledCode()) { - throw new Error("Must part of compiled code"); + throw new Error("Must be part of compiled code already hereeeeee"); } else { // lock 1 must be free if (isMonitorLockHeld(lock1)) { @@ -519,7 +537,7 @@ } GraalDirectives.controlFlowAnchor(); if (!GraalDirectives.inCompiledCode()) { - throw new Error("Must part of compiled code"); + throw new Error("Must be part of compiled code"); } return ret; } @@ -543,7 +561,7 @@ } GraalDirectives.controlFlowAnchor(); if (!GraalDirectives.inCompiledCode()) { - throw new Error("Must part of compiled code"); + throw new Error("Must be part of compiled code"); } return ret; } @@ -568,7 +586,7 @@ } GraalDirectives.controlFlowAnchor(); if (!GraalDirectives.inCompiledCode()) { - throw new Error("Must part of compiled code"); + throw new Error("Must be part of compiled code"); } return ret; } @@ -646,7 +664,7 @@ synchronized (monitor) { GraalDirectives.controlFlowAnchor(); if (!GraalDirectives.inCompiledCode()) { - throw new Error("Must part of compiled code"); + throw new Error("Must be part of compiled code"); } } return ret; @@ -670,7 +688,7 @@ } GraalDirectives.controlFlowAnchor(); if (!GraalDirectives.inCompiledCode()) { - throw new Error("Must part of compiled code"); + throw new Error("Must be part of compiled code"); } return ret; }