112 statisticsBeforeDeopt = s; 113 } 114 } 115 116 Asserts.assertNotNull(statisticsBeforeDeopt, 117 "After LockThreshold was reached, method should be recompiled " 118 + "with rtm lock eliding."); 119 } 120 121 public static class Test implements CompilableTest { 122 private static final Unsafe UNSAFE = Utils.getUnsafe(); 123 private final Object monitor = new Object(); 124 125 @Override 126 public String getMethodWithLockName() { 127 return this.getClass().getName() + "::forceAbort"; 128 } 129 130 @Override 131 public String[] getMethodsToCompileNames() { 132 return new String[] { 133 getMethodWithLockName(), 134 sun.misc.Unsafe.class.getName() + "::addressSize" 135 }; 136 } 137 138 public void forceAbort(boolean abort) { 139 synchronized(monitor) { 140 if (abort) { 141 Test.UNSAFE.addressSize(); 142 } 143 } 144 } 145 146 /** 147 * Usage: 148 * Test <inflate monitor> 149 */ 150 public static void main(String args[]) throws Throwable { 151 Asserts.assertGTE(args.length, 1, "One argument required."); 152 Test t = new Test(); 153 154 if (Boolean.valueOf(args[0])) { 155 AbortProvoker.inflateMonitor(t.monitor); 156 } 157 for (int i = 0; i < AbortProvoker.DEFAULT_ITERATIONS; i++) { 158 t.forceAbort( 159 i == TestRTMDeoptOnLowAbortRatio.LOCKING_THRESHOLD); 160 } 161 } 162 } 163 164 public static void main(String args[]) throws Throwable { 165 new TestRTMDeoptOnLowAbortRatio().test(); 166 } 167 } | 112 statisticsBeforeDeopt = s; 113 } 114 } 115 116 Asserts.assertNotNull(statisticsBeforeDeopt, 117 "After LockThreshold was reached, method should be recompiled " 118 + "with rtm lock eliding."); 119 } 120 121 public static class Test implements CompilableTest { 122 private static final Unsafe UNSAFE = Utils.getUnsafe(); 123 private final Object monitor = new Object(); 124 125 @Override 126 public String getMethodWithLockName() { 127 return this.getClass().getName() + "::forceAbort"; 128 } 129 130 @Override 131 public String[] getMethodsToCompileNames() { 132 return new String[] { getMethodWithLockName() }; 133 } 134 135 public void forceAbort(boolean abort) { 136 synchronized(monitor) { 137 if (abort) { 138 Test.UNSAFE.addressSize(); 139 } 140 } 141 } 142 143 /** 144 * Usage: 145 * Test <inflate monitor> 146 */ 147 public static void main(String args[]) throws Throwable { 148 Asserts.assertGTE(args.length, 1, "One argument required."); 149 Test t = new Test(); 150 boolean shouldBeInflated = Boolean.valueOf(args[0]); 151 if (shouldBeInflated) { 152 AbortProvoker.inflateMonitor(t.monitor); 153 } 154 for (int i = 0; i < AbortProvoker.DEFAULT_ITERATIONS; i++) { 155 AbortProvoker.verifyMonitorState(t.monitor, shouldBeInflated); 156 t.forceAbort( 157 i == TestRTMDeoptOnLowAbortRatio.LOCKING_THRESHOLD); 158 } 159 } 160 } 161 162 public static void main(String args[]) throws Throwable { 163 new TestRTMDeoptOnLowAbortRatio().test(); 164 } 165 } |