< prev index next >
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot.test/src/org/graalvm/compiler/hotspot/test/GraalOSRLockTest.java
Print this page
@@ -22,15 +22,17 @@
*/
package org.graalvm.compiler.hotspot.test;
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;
import org.graalvm.compiler.debug.DebugContext;
import org.graalvm.compiler.debug.GraalError;
@@ -42,24 +44,40 @@
import org.junit.Assert;
import org.junit.Test;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import org.junit.Assume;
+import org.junit.BeforeClass;
/**
* Test on-stack-replacement with locks.
*/
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<String> arguments = runtimeMxBean.getInputArguments();
+ for (String arg : arguments) {
+ Assume.assumeFalse(arg.equals(COMPILE_ONLY_FLAG));
+ }
}
// testing only
public static boolean isMonitorLockHeld(Object o) {
return isMonitorLockHeldByThread(o, null);
@@ -436,35 +454,35 @@
}
}
}
GraalDirectives.controlFlowAnchor();
if (!GraalDirectives.inCompiledCode()) {
- throw new Error("Must part of compiled code");
+ throw new Error("Must be part of compiled code");
}
return ret;
}
}
public static ReturnValue testOuterInnerLockDepth1CompileRestOfMethod() {
// testing the order of the lock releasing
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();
}
}
}
}
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)) {
throw new Error("Lock 1 must have been released already");
}
@@ -517,11 +535,11 @@
}
}
}
GraalDirectives.controlFlowAnchor();
if (!GraalDirectives.inCompiledCode()) {
- throw new Error("Must part of compiled code");
+ throw new Error("Must be part of compiled code");
}
return ret;
}
}
@@ -541,11 +559,11 @@
}
}
}
GraalDirectives.controlFlowAnchor();
if (!GraalDirectives.inCompiledCode()) {
- throw new Error("Must part of compiled code");
+ throw new Error("Must be part of compiled code");
}
return ret;
}
}
@@ -566,11 +584,11 @@
}
}
}
GraalDirectives.controlFlowAnchor();
if (!GraalDirectives.inCompiledCode()) {
- throw new Error("Must part of compiled code");
+ throw new Error("Must be part of compiled code");
}
return ret;
}
}
@@ -644,11 +662,11 @@
}
}
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;
}
@@ -668,11 +686,11 @@
}
}
}
GraalDirectives.controlFlowAnchor();
if (!GraalDirectives.inCompiledCode()) {
- throw new Error("Must part of compiled code");
+ throw new Error("Must be part of compiled code");
}
return ret;
}
}
< prev index next >