test/hotspot/jtreg/compiler/rtm/locking/TestRTMTotalCountIncrRate.java
changeset 55087 82fe7292ca5c
parent 51753 763aa4d1d596
equal deleted inserted replaced
55086:dcda4663a926 55087:82fe7292ca5c
     1 /*
     1 /*
     2  * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    31  *          java.management
    31  *          java.management
    32  * @requires vm.rtm.cpu & vm.rtm.compiler
    32  * @requires vm.rtm.cpu & vm.rtm.compiler
    33  * @build sun.hotspot.WhiteBox
    33  * @build sun.hotspot.WhiteBox
    34  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
    34  * @run driver ClassFileInstaller sun.hotspot.WhiteBox
    35  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
    35  *                                sun.hotspot.WhiteBox$WhiteBoxPermission
    36  * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
    36  * @run main/othervm/native -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
    37  *                   -XX:+WhiteBoxAPI
    37  *                          -XX:+WhiteBoxAPI
    38  *                   compiler.rtm.locking.TestRTMTotalCountIncrRate
    38  *                          compiler.rtm.locking.TestRTMTotalCountIncrRate
    39  */
    39  */
    40 
    40 
    41 package compiler.rtm.locking;
    41 package compiler.rtm.locking;
    42 
    42 
    43 import compiler.testlibrary.rtm.AbortProvoker;
    43 import compiler.testlibrary.rtm.AbortProvoker;
       
    44 import compiler.testlibrary.rtm.XAbortProvoker;
    44 import compiler.testlibrary.rtm.CompilableTest;
    45 import compiler.testlibrary.rtm.CompilableTest;
    45 import compiler.testlibrary.rtm.RTMLockingStatistics;
    46 import compiler.testlibrary.rtm.RTMLockingStatistics;
    46 import compiler.testlibrary.rtm.RTMTestBase;
    47 import compiler.testlibrary.rtm.RTMTestBase;
    47 import jdk.internal.misc.Unsafe;
       
    48 import jdk.test.lib.Asserts;
    48 import jdk.test.lib.Asserts;
    49 import jdk.test.lib.process.OutputAnalyzer;
    49 import jdk.test.lib.process.OutputAnalyzer;
    50 import jdk.test.lib.cli.CommandLineOptionTest;
    50 import jdk.test.lib.cli.CommandLineOptionTest;
    51 
    51 
    52 import java.util.List;
    52 import java.util.List;
   102         }
   102         }
   103     }
   103     }
   104 
   104 
   105     public static class Test implements CompilableTest {
   105     public static class Test implements CompilableTest {
   106         private static final long TOTAL_ITERATIONS = 10000L;
   106         private static final long TOTAL_ITERATIONS = 10000L;
   107         private static final Unsafe UNSAFE = Unsafe.getUnsafe();
   107         private final XAbortProvoker xabort = new XAbortProvoker();
   108         private final Object monitor = new Object();
   108         private final Object monitor = new Object();
   109         // Following field have to be static in order to avoid escape analysis.
   109         // Following field have to be static in order to avoid escape analysis.
   110         @SuppressWarnings("UnsuedDeclaration")
   110         @SuppressWarnings("UnsuedDeclaration")
   111         private static int field = 0;
   111         private static int field = 0;
   112 
   112 
   115             return this.getClass().getName() + "::lock";
   115             return this.getClass().getName() + "::lock";
   116         }
   116         }
   117 
   117 
   118         @Override
   118         @Override
   119         public String[] getMethodsToCompileNames() {
   119         public String[] getMethodsToCompileNames() {
   120             return new String[] { getMethodWithLockName() };
   120             return new String[] { getMethodWithLockName(), "*.doAbort" };
   121         }
   121         }
   122 
   122 
   123         public void lock(boolean forceAbort) {
   123         public void lock(boolean forceAbort) {
   124             synchronized(monitor) {
   124             synchronized(monitor) {
   125                 if (forceAbort) {
   125                 if (forceAbort) {
   127                     // abort. It's done by explicit xabort call emitted
   127                     // abort. It's done by explicit xabort call emitted
   128                     // in SharedRuntime::generate_native_wrapper.
   128                     // in SharedRuntime::generate_native_wrapper.
   129                     // If an actual JNI call will be replaced by
   129                     // If an actual JNI call will be replaced by
   130                     // intrinsic - we'll be in trouble, since xabort
   130                     // intrinsic - we'll be in trouble, since xabort
   131                     // will be no longer called and test may fail.
   131                     // will be no longer called and test may fail.
   132                     UNSAFE.pageSize();
   132                     xabort.doAbort();
   133                 }
   133                 }
   134                 Test.field++;
   134                 Test.field++;
   135             }
   135             }
   136         }
   136         }
   137 
   137