< prev index next >

test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java

Print this page
rev 7600 : 8050486: compiler/rtm/ tests fail due to monitor deflation at safepoint synchronization
Reviewed-by:


 140                 String.format("VM output should contain %d RTM locking "
 141                         + "statistics entries.", expectedStatEntries));
 142     }
 143 
 144     public static class Test implements CompilableTest {
 145         // Following field have to be static in order to avoid escape analysis.
 146         @SuppressWarnings("UnsuedDeclaration")
 147         private static int field = 0;
 148         private static final int ITERATIONS = 10000;
 149         private static final int RANGE_CHECK_AT = ITERATIONS / 2;
 150         private static final Unsafe UNSAFE = Utils.getUnsafe();
 151         private final Object monitor = new Object();
 152 
 153         @Override
 154         public String getMethodWithLockName() {
 155             return this.getClass().getName() + "::forceAbort";
 156         }
 157 
 158         @Override
 159         public String[] getMethodsToCompileNames() {
 160             return new String[] {
 161                 getMethodWithLockName(),
 162                 sun.misc.Unsafe.class.getName() + "::forceAbort"
 163             };
 164         }
 165 
 166         public void forceAbort(int a[], boolean abort) {
 167             try {
 168                 synchronized(monitor) {
 169                     a[0]++;
 170                     if (abort) {
 171                         Test.field = Test.UNSAFE.addressSize();
 172                     }
 173                 }
 174             } catch (Throwable t) {
 175                 // suppress any throwables
 176             }
 177         }
 178 
 179         /**
 180          * Usage:
 181          * Test &lt;inflate monitor&gt;
 182          */
 183         public static void main(String args[]) throws Throwable {
 184             Test t = new Test();
 185 
 186             if (Boolean.valueOf(args[0])) {

 187                 AbortProvoker.inflateMonitor(t.monitor);
 188             }
 189 
 190             int tmp[] = new int[1];
 191 
 192             for (int i = 0; i < Test.ITERATIONS; i++ ) {

 193                 if (i == Test.RANGE_CHECK_AT) {
 194                     t.forceAbort(new int[0], false);
 195                 } else {
 196                     boolean isThreshold
 197                             = (i == TestRTMAfterNonRTMDeopt.ABORT_THRESHOLD);
 198                     boolean isThresholdPlusRange
 199                             = (i == TestRTMAfterNonRTMDeopt.ABORT_THRESHOLD
 200                             + Test.RANGE_CHECK_AT);
 201                     t.forceAbort(tmp, isThreshold || isThresholdPlusRange);
 202                 }
 203             }
 204         }
 205     }
 206 
 207     public static void main(String args[]) throws Throwable {
 208         new TestRTMAfterNonRTMDeopt().test();
 209     }
 210 }
 211 


 140                 String.format("VM output should contain %d RTM locking "
 141                         + "statistics entries.", expectedStatEntries));
 142     }
 143 
 144     public static class Test implements CompilableTest {
 145         // Following field have to be static in order to avoid escape analysis.
 146         @SuppressWarnings("UnsuedDeclaration")
 147         private static int field = 0;
 148         private static final int ITERATIONS = 10000;
 149         private static final int RANGE_CHECK_AT = ITERATIONS / 2;
 150         private static final Unsafe UNSAFE = Utils.getUnsafe();
 151         private final Object monitor = new Object();
 152 
 153         @Override
 154         public String getMethodWithLockName() {
 155             return this.getClass().getName() + "::forceAbort";
 156         }
 157 
 158         @Override
 159         public String[] getMethodsToCompileNames() {
 160             return new String[] { getMethodWithLockName() };



 161         }
 162 
 163         public void forceAbort(int a[], boolean abort) {
 164             try {
 165                 synchronized(monitor) {
 166                     a[0]++;
 167                     if (abort) {
 168                         Test.field = Test.UNSAFE.addressSize();
 169                     }
 170                 }
 171             } catch (Throwable t) {
 172                 // suppress any throwables
 173             }
 174         }
 175 
 176         /**
 177          * Usage:
 178          * Test &lt;inflate monitor&gt;
 179          */
 180         public static void main(String args[]) throws Throwable {
 181             Test t = new Test();
 182 
 183             boolean shouldBeInflated = Boolean.valueOf(args[0]);
 184             if (shouldBeInflated) {
 185                 AbortProvoker.inflateMonitor(t.monitor);
 186             }
 187 
 188             int tmp[] = new int[1];
 189 
 190             for (int i = 0; i < Test.ITERATIONS; i++ ) {
 191                 AbortProvoker.verifyMonitorState(t.monitor, shouldBeInflated);
 192                 if (i == Test.RANGE_CHECK_AT) {
 193                     t.forceAbort(new int[0], false);
 194                 } else {
 195                     boolean isThreshold
 196                             = (i == TestRTMAfterNonRTMDeopt.ABORT_THRESHOLD);
 197                     boolean isThresholdPlusRange
 198                             = (i == TestRTMAfterNonRTMDeopt.ABORT_THRESHOLD
 199                             + Test.RANGE_CHECK_AT);
 200                     t.forceAbort(tmp, isThreshold || isThresholdPlusRange);
 201                 }
 202             }
 203         }
 204     }
 205 
 206     public static void main(String args[]) throws Throwable {
 207         new TestRTMAfterNonRTMDeopt().test();
 208     }
 209 }
 210 
< prev index next >