changeset 9054:bcec9de99535

8068269: RTM tests that assert on non-zero lock statistics are too strict in RTMTotalCountIncrRate > 1 cases Reviewed-by: kvn, iignatyev
author fzhinkin
date Wed, 14 Jan 2015 09:53:36 +0300
parents f2cf09a64a91
children 3d54343bdb9c
files test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java test/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java
diffstat 2 files changed, 18 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java	Wed Feb 27 10:23:05 2019 +0100
+++ b/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java	Wed Jan 14 09:53:36 2015 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,7 @@
  *                   -XX:+WhiteBoxAPI TestRTMTotalCountIncrRate
  */
 
+import sun.misc.Unsafe;
 import java.util.List;
 
 import com.oracle.java.testlibrary.*;
@@ -96,14 +97,12 @@
             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")
@@ -119,8 +118,17 @@
             return new String[] { getMethodWithLockName() };
         }
 
-        public void lock() {
+        public void lock(boolean 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 actual 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++;
             }
         }
@@ -139,7 +147,11 @@
             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);
             }
         }
     }
--- a/test/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java	Wed Feb 27 10:23:05 2019 +0100
+++ b/test/compiler/rtm/print/TestPrintPreciseRTMLockingStatistics.java	Wed Jan 14 09:53:36 2015 +0300
@@ -124,9 +124,6 @@
 
         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");