< prev index next >

test/compiler/rtm/locking/TestRTMAbortRatio.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 RTMAbortRatio affects amount of aborts before
  28  *          deoptimization.
  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.TestRTMAbortRatio
  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 method will be deoptimized on high abort ratio
  59  * as soon as abort ratio reaches RTMAbortRatio's value.
  60  */
  61 public class TestRTMAbortRatio extends CommandLineOptionTest {
  62     private TestRTMAbortRatio() {
  63         super(new AndPredicate(new SupportedCPU(), new SupportedOS(), new SupportedVM()));
  64     }
  65 
  66     @Override
  67     protected void runTestCases() throws Throwable {
  68         verifyAbortRatio(0, false);
  69         verifyAbortRatio(10, false);
  70         verifyAbortRatio(50, false);
  71         verifyAbortRatio(100, false);
  72 
  73         verifyAbortRatio(0, true);
  74         verifyAbortRatio(10, true);
  75         verifyAbortRatio(50, true);
  76         verifyAbortRatio(100, true);
  77     }
  78 
  79     private void verifyAbortRatio(int abortRatio, boolean useStackLock)
  80             throws Throwable {
  81         CompilableTest test = new Test();
  82 
  83         OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
  84                 test,
  85                 CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks",
  86                         useStackLock),


 150 
 151         /**
 152          * Usage:
 153          * Test &lt;inflate monitor&gt;
 154          */
 155         public static void main(String args[]) throws Throwable {
 156             Asserts.assertGTE(args.length, 1, "One argument required.");
 157             Test t = new Test();
 158             boolean shouldBeInflated = Boolean.valueOf(args[0]);
 159             if (shouldBeInflated) {
 160                 AbortProvoker.inflateMonitor(t.monitor);
 161             }
 162             for (int i = 0; i < Test.TOTAL_ITERATIONS; i++) {
 163                 AbortProvoker.verifyMonitorState(t.monitor, shouldBeInflated);
 164                 t.lock(i >= Test.WARMUP_ITERATIONS);
 165             }
 166         }
 167     }
 168 
 169     public static void main(String args[]) throws Throwable {
 170         new TestRTMAbortRatio().test();
 171     }
 172 }
 173 


  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 RTMAbortRatio affects amount of aborts before
  28  *          deoptimization.
  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.TestRTMAbortRatio
  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 method will be deoptimized on high abort ratio
  56  * as soon as abort ratio reaches RTMAbortRatio's value.
  57  */
  58 public class TestRTMAbortRatio {



  59 

  60     protected void runTestCases() throws Throwable {
  61         verifyAbortRatio(0, false);
  62         verifyAbortRatio(10, false);
  63         verifyAbortRatio(50, false);
  64         verifyAbortRatio(100, false);
  65 
  66         verifyAbortRatio(0, true);
  67         verifyAbortRatio(10, true);
  68         verifyAbortRatio(50, true);
  69         verifyAbortRatio(100, true);
  70     }
  71 
  72     private void verifyAbortRatio(int abortRatio, boolean useStackLock)
  73             throws Throwable {
  74         CompilableTest test = new Test();
  75 
  76         OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
  77                 test,
  78                 CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks",
  79                         useStackLock),


 143 
 144         /**
 145          * Usage:
 146          * Test &lt;inflate monitor&gt;
 147          */
 148         public static void main(String args[]) throws Throwable {
 149             Asserts.assertGTE(args.length, 1, "One argument required.");
 150             Test t = new Test();
 151             boolean shouldBeInflated = Boolean.valueOf(args[0]);
 152             if (shouldBeInflated) {
 153                 AbortProvoker.inflateMonitor(t.monitor);
 154             }
 155             for (int i = 0; i < Test.TOTAL_ITERATIONS; i++) {
 156                 AbortProvoker.verifyMonitorState(t.monitor, shouldBeInflated);
 157                 t.lock(i >= Test.WARMUP_ITERATIONS);
 158             }
 159         }
 160     }
 161 
 162     public static void main(String args[]) throws Throwable {
 163         new TestRTMAbortRatio().runTestCases();
 164     }
 165 }
 166 
< prev index next >