< 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,36 **** --- 22,38 ---- */ 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,65 **** import org.junit.Assert; import org.junit.Test; import jdk.vm.ci.meta.ResolvedJavaMethod; import org.junit.Assume; /** * Test on-stack-replacement with locks. */ public class GraalOSRLockTest extends GraalOSRTestBase { private static boolean TestInSeparateThread = false; ! public GraalOSRLockTest() { try { Class.forName("java.lang.management.ManagementFactory"); } catch (ClassNotFoundException ex) { Assume.assumeNoException("cannot check for monitors without java.management JDK9 module", ex); } } // testing only public static boolean isMonitorLockHeld(Object o) { return isMonitorLockHeldByThread(o, null); --- 44,83 ---- 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"; ! @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,470 **** } } } GraalDirectives.controlFlowAnchor(); if (!GraalDirectives.inCompiledCode()) { ! throw new Error("Must 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++) { GraalDirectives.blackhole(i); ! if (i % 1001 == 0) { ret = ReturnValue.SUCCESS; ! if (GraalDirectives.inCompiledCode() && i + 33 > (limit)) { GraalDirectives.blackhole(ret); System.gc(); } } } } GraalDirectives.controlFlowAnchor(); if (!GraalDirectives.inCompiledCode()) { ! throw new Error("Must part of compiled code"); } else { // lock 1 must be free if (isMonitorLockHeld(lock1)) { throw new Error("Lock 1 must have been released already"); } --- 454,488 ---- } } } GraalDirectives.controlFlowAnchor(); if (!GraalDirectives.inCompiledCode()) { ! 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 < 10 * limit; i++) { GraalDirectives.blackhole(i); ! if (i % 33 == 0) { ret = ReturnValue.SUCCESS; ! if (GraalDirectives.inCompiledCode() && i + 33 > (10 * limit)) { GraalDirectives.blackhole(ret); System.gc(); } } } } GraalDirectives.controlFlowAnchor(); if (!GraalDirectives.inCompiledCode()) { ! 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,527 **** } } } GraalDirectives.controlFlowAnchor(); if (!GraalDirectives.inCompiledCode()) { ! throw new Error("Must part of compiled code"); } return ret; } } --- 535,545 ---- } } } GraalDirectives.controlFlowAnchor(); if (!GraalDirectives.inCompiledCode()) { ! throw new Error("Must be part of compiled code"); } return ret; } }
*** 541,551 **** } } } GraalDirectives.controlFlowAnchor(); if (!GraalDirectives.inCompiledCode()) { ! throw new Error("Must part of compiled code"); } return ret; } } --- 559,569 ---- } } } GraalDirectives.controlFlowAnchor(); if (!GraalDirectives.inCompiledCode()) { ! throw new Error("Must be part of compiled code"); } return ret; } }
*** 566,576 **** } } } GraalDirectives.controlFlowAnchor(); if (!GraalDirectives.inCompiledCode()) { ! throw new Error("Must part of compiled code"); } return ret; } } --- 584,594 ---- } } } GraalDirectives.controlFlowAnchor(); if (!GraalDirectives.inCompiledCode()) { ! throw new Error("Must be part of compiled code"); } return ret; } }
*** 644,654 **** } } synchronized (monitor) { GraalDirectives.controlFlowAnchor(); if (!GraalDirectives.inCompiledCode()) { ! throw new Error("Must part of compiled code"); } } return ret; } --- 662,672 ---- } } synchronized (monitor) { GraalDirectives.controlFlowAnchor(); if (!GraalDirectives.inCompiledCode()) { ! throw new Error("Must be part of compiled code"); } } return ret; }
*** 668,678 **** } } } GraalDirectives.controlFlowAnchor(); if (!GraalDirectives.inCompiledCode()) { ! throw new Error("Must part of compiled code"); } return ret; } } --- 686,696 ---- } } } GraalDirectives.controlFlowAnchor(); if (!GraalDirectives.inCompiledCode()) { ! throw new Error("Must be part of compiled code"); } return ret; } }
< prev index next >