139 String.format("VM output should contain %d RTM locking " 140 + "statistics entries.", expectedStatEntries)); 141 } 142 143 public static class Test implements CompilableTest { 144 // Following field have to be static in order to avoid escape analysis. 145 @SuppressWarnings("UnsuedDeclaration") 146 private static int field = 0; 147 private static final int ITERATIONS = 10000; 148 private static final int RANGE_CHECK_AT = ITERATIONS / 2; 149 private static final Unsafe UNSAFE = Utils.getUnsafe(); 150 private final Object monitor = new Object(); 151 152 @Override 153 public String getMethodWithLockName() { 154 return this.getClass().getName() + "::forceAbort"; 155 } 156 157 @Override 158 public String[] getMethodsToCompileNames() { 159 return new String[] { 160 getMethodWithLockName(), 161 sun.misc.Unsafe.class.getName() + "::forceAbort" 162 }; 163 } 164 165 public void forceAbort(int a[], boolean abort) { 166 try { 167 synchronized(monitor) { 168 a[0]++; 169 if (abort) { 170 Test.field = Test.UNSAFE.addressSize(); 171 } 172 } 173 } catch (Throwable t) { 174 // suppress any throwables 175 } 176 } 177 178 /** 179 * Usage: 180 * Test <inflate monitor> 181 */ 182 public static void main(String args[]) throws Throwable { 183 Test t = new Test(); 184 185 if (Boolean.valueOf(args[0])) { 186 AbortProvoker.inflateMonitor(t.monitor); 187 } 188 189 int tmp[] = new int[1]; 190 191 for (int i = 0; i < Test.ITERATIONS; i++ ) { 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 | 139 String.format("VM output should contain %d RTM locking " 140 + "statistics entries.", expectedStatEntries)); 141 } 142 143 public static class Test implements CompilableTest { 144 // Following field have to be static in order to avoid escape analysis. 145 @SuppressWarnings("UnsuedDeclaration") 146 private static int field = 0; 147 private static final int ITERATIONS = 10000; 148 private static final int RANGE_CHECK_AT = ITERATIONS / 2; 149 private static final Unsafe UNSAFE = Utils.getUnsafe(); 150 private final Object monitor = new Object(); 151 152 @Override 153 public String getMethodWithLockName() { 154 return this.getClass().getName() + "::forceAbort"; 155 } 156 157 @Override 158 public String[] getMethodsToCompileNames() { 159 return new String[] { getMethodWithLockName() }; 160 } 161 162 public void forceAbort(int a[], boolean abort) { 163 try { 164 synchronized(monitor) { 165 a[0]++; 166 if (abort) { 167 Test.field = Test.UNSAFE.addressSize(); 168 } 169 } 170 } catch (Throwable t) { 171 // suppress any throwables 172 } 173 } 174 175 /** 176 * Usage: 177 * Test <inflate monitor> 178 */ 179 public static void main(String args[]) throws Throwable { 180 Test t = new Test(); 181 182 boolean shouldBeInflated = Boolean.valueOf(args[0]); 183 if (shouldBeInflated) { 184 AbortProvoker.inflateMonitor(t.monitor); 185 } 186 187 int tmp[] = new int[1]; 188 189 for (int i = 0; i < Test.ITERATIONS; i++ ) { 190 AbortProvoker.verifyMonitorState(t.monitor, shouldBeInflated); 191 if (i == Test.RANGE_CHECK_AT) { 192 t.forceAbort(new int[0], false); 193 } else { 194 boolean isThreshold 195 = (i == TestRTMAfterNonRTMDeopt.ABORT_THRESHOLD); 196 boolean isThresholdPlusRange 197 = (i == TestRTMAfterNonRTMDeopt.ABORT_THRESHOLD 198 + Test.RANGE_CHECK_AT); 199 t.forceAbort(tmp, isThreshold || isThresholdPlusRange); 200 } 201 } 202 } 203 } 204 205 public static void main(String args[]) throws Throwable { 206 new TestRTMAfterNonRTMDeopt().test(); 207 } 208 } 209 |