1 /* |
1 /* |
2 * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
33 * java.management |
33 * java.management |
34 * @requires vm.rtm.cpu & vm.rtm.compiler |
34 * @requires vm.rtm.cpu & vm.rtm.compiler |
35 * @build sun.hotspot.WhiteBox |
35 * @build sun.hotspot.WhiteBox |
36 * @run driver ClassFileInstaller sun.hotspot.WhiteBox |
36 * @run driver ClassFileInstaller sun.hotspot.WhiteBox |
37 * sun.hotspot.WhiteBox$WhiteBoxPermission |
37 * sun.hotspot.WhiteBox$WhiteBoxPermission |
38 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions |
38 * @run main/othervm/native -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions |
39 * -XX:+WhiteBoxAPI |
39 * -XX:+WhiteBoxAPI |
40 * compiler.rtm.locking.TestRTMAfterNonRTMDeopt |
40 * compiler.rtm.locking.TestRTMAfterNonRTMDeopt |
41 */ |
41 */ |
42 |
42 |
43 package compiler.rtm.locking; |
43 package compiler.rtm.locking; |
44 |
44 |
45 import compiler.testlibrary.rtm.AbortProvoker; |
45 import compiler.testlibrary.rtm.AbortProvoker; |
|
46 import compiler.testlibrary.rtm.XAbortProvoker; |
46 import compiler.testlibrary.rtm.CompilableTest; |
47 import compiler.testlibrary.rtm.CompilableTest; |
47 import compiler.testlibrary.rtm.RTMLockingStatistics; |
48 import compiler.testlibrary.rtm.RTMLockingStatistics; |
48 import compiler.testlibrary.rtm.RTMTestBase; |
49 import compiler.testlibrary.rtm.RTMTestBase; |
49 import jdk.internal.misc.Unsafe; |
|
50 import jdk.test.lib.Asserts; |
50 import jdk.test.lib.Asserts; |
51 import jdk.test.lib.process.OutputAnalyzer; |
51 import jdk.test.lib.process.OutputAnalyzer; |
52 import jdk.test.lib.cli.CommandLineOptionTest; |
52 import jdk.test.lib.cli.CommandLineOptionTest; |
53 |
53 |
54 import java.util.List; |
54 import java.util.List; |
147 // Following field have to be static in order to avoid escape analysis. |
147 // Following field have to be static in order to avoid escape analysis. |
148 @SuppressWarnings("UnsuedDeclaration") |
148 @SuppressWarnings("UnsuedDeclaration") |
149 private static int field = 0; |
149 private static int field = 0; |
150 private static final int ITERATIONS = 10000; |
150 private static final int ITERATIONS = 10000; |
151 private static final int RANGE_CHECK_AT = ITERATIONS / 2; |
151 private static final int RANGE_CHECK_AT = ITERATIONS / 2; |
152 private static final Unsafe UNSAFE = Unsafe.getUnsafe(); |
152 private final XAbortProvoker xabort = new XAbortProvoker(); |
153 private final Object monitor = new Object(); |
153 private final Object monitor = new Object(); |
154 |
154 |
155 @Override |
155 @Override |
156 public String getMethodWithLockName() { |
156 public String getMethodWithLockName() { |
157 return this.getClass().getName() + "::forceAbort"; |
157 return this.getClass().getName() + "::forceAbort"; |
158 } |
158 } |
159 |
159 |
160 @Override |
160 @Override |
161 public String[] getMethodsToCompileNames() { |
161 public String[] getMethodsToCompileNames() { |
162 return new String[] { getMethodWithLockName() }; |
162 return new String[] { getMethodWithLockName(), |
|
163 XAbortProvoker.class.getName() + "::doAbort()" }; |
163 } |
164 } |
164 |
165 |
165 public void forceAbort(int a[], boolean abort) { |
166 public void forceAbort(int a[], boolean abort) { |
166 try { |
167 try { |
167 synchronized(monitor) { |
168 synchronized(monitor) { |
168 a[0]++; |
169 a[0]++; |
169 if (abort) { |
170 if (abort) { |
170 Test.field = Test.UNSAFE.pageSize(); |
171 Test.field = xabort.doAbort(); |
171 } |
172 } |
172 } |
173 } |
173 } catch (Throwable t) { |
174 } catch (Throwable t) { |
174 // suppress any throwables |
175 // suppress any throwables |
175 } |
176 } |