diff --git a/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java b/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java index 7a3327606fdaffc646e23958defd4ed4dd4594cc..d27a87d8c2ea3e3b18435f978bc0724873396f10 100644 --- a/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java +++ b/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java @@ -35,6 +35,7 @@ * -XX:+WhiteBoxAPI TestRTMTotalCountIncrRate */ +import sun.misc.Unsafe; import java.util.List; import com.oracle.java.testlibrary.*; @@ -97,14 +98,12 @@ public class TestRTMTotalCountIncrRate extends CommandLineOptionTest { Asserts.assertEQ(lock.getTotalLocks(), Test.TOTAL_ITERATIONS, "Total locks should be exactly the same as amount of " + "iterations."); - } else { - Asserts.assertGT(lock.getTotalLocks(), 0L, "RTM statistics " - + "should contain information for at least on lock."); } } public static class Test implements CompilableTest { private static final long TOTAL_ITERATIONS = 10000L; + private static final Unsafe UNSAFE = Utils.getUnsafe(); private final Object monitor = new Object(); // Following field have to be static in order to avoid escape analysis. @SuppressWarnings("UnsuedDeclaration") @@ -120,8 +119,17 @@ public class TestRTMTotalCountIncrRate extends CommandLineOptionTest { return new String[] { getMethodWithLockName() }; } - public void lock() { + public void lock(booleab forceAbort) { synchronized(monitor) { + if (forceAbort) { + // We're calling native method in order to force + // abort. It's done by explicit xabort call emitted + // in SharedRuntime::generate_native_wrapper. + // If an actuall JNI call will be replaced by + // intrinsic - we'll be in trouble, since xabort + // will be no longer called and test may fail. + UNSAFE.addressSize(); + } Test.field++; } } @@ -140,7 +148,11 @@ public class TestRTMTotalCountIncrRate extends CommandLineOptionTest { for (long i = 0L; i < Test.TOTAL_ITERATIONS; i++) { AbortProvoker.verifyMonitorState(test.monitor, shouldBeInflated); - test.lock(); + // Force abort on first iteration to avoid rare case when + // there were no aborts and locks count was not incremented + // with RTMTotalCountIncrRate > 1 (in such case JVM won't + // print JVM locking statistics). + test.lock(i == 0); } } } diff --git a/hotspot/test/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java b/hotspot/test/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java index 80b412272b01e35d2fde7cba6c46cc5397a480f5..291d4cabef524a493b846affc6db1977d3ecde6a 100644 --- a/hotspot/test/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java +++ b/hotspot/test/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java @@ -125,9 +125,6 @@ public class TestPrintPreciseRTMLockingStatistics RTMLockingStatistics lock = statistics.get(0); - Asserts.assertGT(lock.getTotalLocks(), 0L, "RTM locking statistics " - + "should contain non zero total locks count"); - Asserts.assertGT(lock.getTotalAborts(), 0L, "RTM locking statistics should contain non zero total aborts " + "count");