test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java

Print this page




  99         } else {
 100             Asserts.assertGT(lock.getTotalLocks(), 0L, "RTM statistics "
 101                     + "should contain information for at least on lock.");
 102         }
 103     }
 104 
 105     public static class Test implements CompilableTest {
 106         private static final long TOTAL_ITERATIONS = 10000L;
 107         private final Object monitor = new Object();
 108         // Following field have to be static in order to avoid escape analysis.
 109         @SuppressWarnings("UnsuedDeclaration")
 110         private static int field = 0;
 111 
 112         @Override
 113         public String getMethodWithLockName() {
 114             return this.getClass().getName() + "::lock";
 115         }
 116 
 117         @Override
 118         public String[] getMethodsToCompileNames() {
 119             return new String[] {
 120                 getMethodWithLockName()
 121             };
 122         }
 123 
 124         public void lock() {
 125             synchronized(monitor) {
 126                 Test.field++;
 127             }
 128         }
 129 
 130         /**
 131          * Usage:
 132          * Test <inflate monitor>
 133          */
 134         public static void main(String args[]) throws Throwable {
 135             Asserts.assertGTE(args.length, 1, "One argument required.");
 136             Test test = new Test();
 137 
 138             if (Boolean.valueOf(args[0])) {
 139                 AbortProvoker.inflateMonitor(test.monitor);
 140             }
 141             for (long i = 0L; i < Test.TOTAL_ITERATIONS; i++) {


 142                 test.lock();
 143             }
 144         }
 145     }
 146 
 147     public static void main(String args[]) throws Throwable {
 148         new TestRTMTotalCountIncrRate().test();
 149     }
 150 }


  99         } else {
 100             Asserts.assertGT(lock.getTotalLocks(), 0L, "RTM statistics "
 101                     + "should contain information for at least on lock.");
 102         }
 103     }
 104 
 105     public static class Test implements CompilableTest {
 106         private static final long TOTAL_ITERATIONS = 10000L;
 107         private final Object monitor = new Object();
 108         // Following field have to be static in order to avoid escape analysis.
 109         @SuppressWarnings("UnsuedDeclaration")
 110         private static int field = 0;
 111 
 112         @Override
 113         public String getMethodWithLockName() {
 114             return this.getClass().getName() + "::lock";
 115         }
 116 
 117         @Override
 118         public String[] getMethodsToCompileNames() {
 119             return new String[] { getMethodWithLockName() };


 120         }
 121 
 122         public void lock() {
 123             synchronized(monitor) {
 124                 Test.field++;
 125             }
 126         }
 127 
 128         /**
 129          * Usage:
 130          * Test &lt;inflate monitor&gt;
 131          */
 132         public static void main(String args[]) throws Throwable {
 133             Asserts.assertGTE(args.length, 1, "One argument required.");
 134             Test test = new Test();
 135             boolean shouldBeInflated = Boolean.valueOf(args[0]);
 136             if (shouldBeInflated) {
 137                 AbortProvoker.inflateMonitor(test.monitor);
 138             }
 139             for (long i = 0L; i < Test.TOTAL_ITERATIONS; i++) {
 140                 AbortProvoker.verifyMonitorState(test.monitor,
 141                         shouldBeInflated);
 142                 test.lock();
 143             }
 144         }
 145     }
 146 
 147     public static void main(String args[]) throws Throwable {
 148         new TestRTMTotalCountIncrRate().test();
 149     }
 150 }