< prev index next >

test/compiler/rtm/locking/TestRTMLockingThreshold.java

Print this page




  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /**
  25  * @test
  26  * @bug 8031320
  27  * @summary Verify that RTMLockingThreshold affects rtm state transition
  28  *          ProfileRTM => UseRTM.
  29  * @library /test/lib /
  30  * @modules java.base/jdk.internal.misc
  31  *          java.management

  32  * @build sun.hotspot.WhiteBox
  33  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  34  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
  35  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  36  *                   -XX:+WhiteBoxAPI
  37  *                   compiler.rtm.locking.TestRTMLockingThreshold
  38  */
  39 
  40 package compiler.rtm.locking;
  41 
  42 import compiler.testlibrary.rtm.AbortProvoker;
  43 import compiler.testlibrary.rtm.CompilableTest;
  44 import compiler.testlibrary.rtm.RTMLockingStatistics;
  45 import compiler.testlibrary.rtm.RTMTestBase;
  46 import compiler.testlibrary.rtm.predicate.SupportedCPU;
  47 import compiler.testlibrary.rtm.predicate.SupportedOS;
  48 import compiler.testlibrary.rtm.predicate.SupportedVM;
  49 import jdk.internal.misc.Unsafe;
  50 import jdk.test.lib.Asserts;
  51 import jdk.test.lib.process.OutputAnalyzer;
  52 import jdk.test.lib.cli.CommandLineOptionTest;
  53 import jdk.test.lib.cli.predicate.AndPredicate;
  54 
  55 import java.util.List;
  56 
  57 /**
  58  * Test verifies that RTMLockingThreshold option actually affects how soon
  59  * method will be deoptimized on low abort ratio.
  60  */
  61 public class TestRTMLockingThreshold extends CommandLineOptionTest {
  62     private TestRTMLockingThreshold() {
  63         super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
  64     }
  65 
  66     /**
  67      * We use non-zero abort threshold to avoid abort related to
  68      * interrupts, VMM calls, etc. during first lock attempt.
  69      *
  70      */
  71     private static final int MIN_ABORT_THRESHOLD = 10;
  72 
  73     @Override
  74     protected void runTestCases() throws Throwable {
  75         verifyLockingThreshold(0, false);
  76         verifyLockingThreshold(100, false);
  77         verifyLockingThreshold(1000, false);
  78 
  79         verifyLockingThreshold(0, true);
  80         verifyLockingThreshold(100, true);
  81         verifyLockingThreshold(1000, true);
  82     }
  83 
  84     private void verifyLockingThreshold(int lockingThreshold,
  85             boolean useStackLock) throws Throwable {
  86         CompilableTest test = new Test();
  87 
  88         int abortThreshold = Math.max(lockingThreshold / 2,
  89                 TestRTMLockingThreshold.MIN_ABORT_THRESHOLD);
  90 
  91         OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
  92                 test,
  93                 "-XX:CompileThreshold=1",


 166         /**
 167          * Usage:
 168          * Test &lt;inflate monitor&gt;
 169          */
 170         public static void main(String args[]) throws Throwable {
 171             Asserts.assertGTE(args.length, 2, "Two arguments required.");
 172             Test t = new Test();
 173             boolean shouldBeInflated = Boolean.valueOf(args[0]);
 174             int lockingThreshold = Integer.valueOf(args[1]);
 175             if (shouldBeInflated) {
 176                 AbortProvoker.inflateMonitor(t.monitor);
 177             }
 178             for (int i = 0; i < Test.TOTAL_ITERATIONS; i++) {
 179                 AbortProvoker.verifyMonitorState(t.monitor, shouldBeInflated);
 180                 t.lock(i >= lockingThreshold / 2);
 181             }
 182         }
 183     }
 184 
 185     public static void main(String args[]) throws Throwable {
 186         new TestRTMLockingThreshold().test();
 187     }
 188 }


  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /**
  25  * @test
  26  * @bug 8031320
  27  * @summary Verify that RTMLockingThreshold affects rtm state transition
  28  *          ProfileRTM => UseRTM.
  29  * @library /test/lib /
  30  * @modules java.base/jdk.internal.misc
  31  *          java.management
  32  * @requires vm.flavor == "server" & !vm.emulatedClient & vm.rtm.cpu & vm.rtm.os
  33  * @build sun.hotspot.WhiteBox
  34  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
  35  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
  36  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
  37  *                   -XX:+WhiteBoxAPI
  38  *                   compiler.rtm.locking.TestRTMLockingThreshold
  39  */
  40 
  41 package compiler.rtm.locking;
  42 
  43 import compiler.testlibrary.rtm.AbortProvoker;
  44 import compiler.testlibrary.rtm.CompilableTest;
  45 import compiler.testlibrary.rtm.RTMLockingStatistics;
  46 import compiler.testlibrary.rtm.RTMTestBase;



  47 import jdk.internal.misc.Unsafe;
  48 import jdk.test.lib.Asserts;
  49 import jdk.test.lib.process.OutputAnalyzer;
  50 import jdk.test.lib.cli.CommandLineOptionTest;

  51 
  52 import java.util.List;
  53 
  54 /**
  55  * Test verifies that RTMLockingThreshold option actually affects how soon
  56  * method will be deoptimized on low abort ratio.
  57  */
  58 public class TestRTMLockingThreshold {



  59 
  60     /**
  61      * We use non-zero abort threshold to avoid abort related to
  62      * interrupts, VMM calls, etc. during first lock attempt.
  63      *
  64      */
  65     private static final int MIN_ABORT_THRESHOLD = 10;
  66 

  67     protected void runTestCases() throws Throwable {
  68         verifyLockingThreshold(0, false);
  69         verifyLockingThreshold(100, false);
  70         verifyLockingThreshold(1000, false);
  71 
  72         verifyLockingThreshold(0, true);
  73         verifyLockingThreshold(100, true);
  74         verifyLockingThreshold(1000, true);
  75     }
  76 
  77     private void verifyLockingThreshold(int lockingThreshold,
  78             boolean useStackLock) throws Throwable {
  79         CompilableTest test = new Test();
  80 
  81         int abortThreshold = Math.max(lockingThreshold / 2,
  82                 TestRTMLockingThreshold.MIN_ABORT_THRESHOLD);
  83 
  84         OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
  85                 test,
  86                 "-XX:CompileThreshold=1",


 159         /**
 160          * Usage:
 161          * Test &lt;inflate monitor&gt;
 162          */
 163         public static void main(String args[]) throws Throwable {
 164             Asserts.assertGTE(args.length, 2, "Two arguments required.");
 165             Test t = new Test();
 166             boolean shouldBeInflated = Boolean.valueOf(args[0]);
 167             int lockingThreshold = Integer.valueOf(args[1]);
 168             if (shouldBeInflated) {
 169                 AbortProvoker.inflateMonitor(t.monitor);
 170             }
 171             for (int i = 0; i < Test.TOTAL_ITERATIONS; i++) {
 172                 AbortProvoker.verifyMonitorState(t.monitor, shouldBeInflated);
 173                 t.lock(i >= lockingThreshold / 2);
 174             }
 175         }
 176     }
 177 
 178     public static void main(String args[]) throws Throwable {
 179         new TestRTMLockingThreshold().runTestCases();
 180     }
 181 }
< prev index next >