9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /**
25 * @test
26 * @bug 6589834
27 * @summary Safepoint placed between stack pointer increment and decrement leads
28 * to interpreter's stack corruption after deoptimization.
29 * @library /testlibrary /test/lib
30 * @modules java.base/jdk.internal.misc
31 * java.compiler
32 * java.management
33 * jdk.jvmstat/sun.jvmstat.monitor
34 * @build ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.*
35 * Test_ia32 InlinedArrayCloneTestCase
36 * @run main ClassFileInstaller sun.hotspot.WhiteBox
37 * sun.hotspot.WhiteBox$WhiteBoxPermission
38 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
39 * -XX:+WhiteBoxAPI -XX:CompileOnly=InlinedArrayCloneTestCase
40 * -XX:CompileCommand=dontinline,InlinedArrayCloneTestCase.invokeArrayClone
41 * -XX:CompileCommand=inline,InlinedArrayCloneTestCase.verifyArguments
42 * -XX:+IgnoreUnrecognizedVMOptions -XX:+VerifyStack Test_ia32
43 */
44
45 import java.lang.reflect.Method;
46
47 import jdk.test.lib.Asserts;
48 import sun.hotspot.WhiteBox;
49
50 public class Test_ia32 {
51 private static final int NUM_THREADS
52 = Math.min(100, 2 * Runtime.getRuntime().availableProcessors());
53 private static final int CLONE_LENGTH = 1000;
54
55 private static WhiteBox wb = WhiteBox.getWhiteBox();
56
57 private final LoadedClass[] ARRAY = new LoadedClass[Test_ia32.CLONE_LENGTH];
58 private volatile boolean doSpin = true;
59 private volatile boolean testFailed = false;
60
61 public boolean continueExecution() {
62 return doSpin;
63 }
64
65 public void stopExecution() {
66 doSpin = false;
67 }
68
69 public boolean isTestFailed() {
94 "Method " + method.getName() + " should be compilable.");
95
96 for (int i = 0; i < threads.length; i++) {
97 threads[i] = new Thread(new InlinedArrayCloneTestCase(this));
98 threads[i].start();
99 }
100
101 /*
102 * Wait until InlinedArrayCloneTestCase::invokeArrayClone is compiled.
103 */
104 while (!wb.isMethodCompiled(method)) {
105 Thread.yield();
106 }
107
108 /*
109 * Load NotLoadedClass to cause deoptimization of
110 * InlinedArrayCloneTestCase::invokeArrayClone due to invalidated
111 * dependency.
112 */
113 try {
114 Class.forName("NotLoadedClass");
115 } catch (ClassNotFoundException e) {
116 throw new Error("Unable to load class that invalidates "
117 + "CHA-dependency for method " + method.getName(), e);
118 }
119
120 stopExecution();
121
122 for (Thread thread : threads) {
123 try {
124 thread.join();
125 } catch (InterruptedException e) {
126 throw new Error("Fail to join thread " + thread, e);
127 }
128 }
129
130 Asserts.assertFalse(isTestFailed(), "Test failed.");
131 }
132
133 public static void main(String[] args) {
134 new Test_ia32().runTest();
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /**
25 * @test
26 * @bug 6589834
27 * @summary Safepoint placed between stack pointer increment and decrement leads
28 * to interpreter's stack corruption after deoptimization.
29 * @library /testlibrary /test/lib /
30 * @modules java.base/jdk.internal.misc
31 * java.compiler
32 * java.management
33 * jdk.jvmstat/sun.jvmstat.monitor
34 *
35 * @build ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.*
36 * compiler.c2.cr6589834.Test_ia32
37 * compiler.c2.cr6589834.InlinedArrayCloneTestCase
38 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
39 * sun.hotspot.WhiteBox$WhiteBoxPermission
40 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
41 * -XX:+WhiteBoxAPI -XX:+IgnoreUnrecognizedVMOptions -XX:+VerifyStack
42 * -XX:CompileCommand=compileonly,compiler.c2.cr6589834.InlinedArrayCloneTestCase::*
43 * -XX:CompileCommand=dontinline,compiler.c2.cr6589834.InlinedArrayCloneTestCase::invokeArrayClone
44 * -XX:CompileCommand=inline,compiler.c2.cr6589834.InlinedArrayCloneTestCase::verifyArguments
45 * compiler.c2.cr6589834.Test_ia32
46 */
47
48 package compiler.c2.cr6589834;
49
50 import jdk.test.lib.Asserts;
51 import sun.hotspot.WhiteBox;
52
53 import java.lang.reflect.Method;
54
55 public class Test_ia32 {
56 private static final int NUM_THREADS
57 = Math.min(100, 2 * Runtime.getRuntime().availableProcessors());
58 private static final int CLONE_LENGTH = 1000;
59
60 private static WhiteBox wb = WhiteBox.getWhiteBox();
61
62 private final LoadedClass[] ARRAY = new LoadedClass[Test_ia32.CLONE_LENGTH];
63 private volatile boolean doSpin = true;
64 private volatile boolean testFailed = false;
65
66 public boolean continueExecution() {
67 return doSpin;
68 }
69
70 public void stopExecution() {
71 doSpin = false;
72 }
73
74 public boolean isTestFailed() {
99 "Method " + method.getName() + " should be compilable.");
100
101 for (int i = 0; i < threads.length; i++) {
102 threads[i] = new Thread(new InlinedArrayCloneTestCase(this));
103 threads[i].start();
104 }
105
106 /*
107 * Wait until InlinedArrayCloneTestCase::invokeArrayClone is compiled.
108 */
109 while (!wb.isMethodCompiled(method)) {
110 Thread.yield();
111 }
112
113 /*
114 * Load NotLoadedClass to cause deoptimization of
115 * InlinedArrayCloneTestCase::invokeArrayClone due to invalidated
116 * dependency.
117 */
118 try {
119 Class.forName(Test_ia32.class.getPackage().getName() + ".NotLoadedClass");
120 } catch (ClassNotFoundException e) {
121 throw new Error("Unable to load class that invalidates "
122 + "CHA-dependency for method " + method.getName(), e);
123 }
124
125 stopExecution();
126
127 for (Thread thread : threads) {
128 try {
129 thread.join();
130 } catch (InterruptedException e) {
131 throw new Error("Fail to join thread " + thread, e);
132 }
133 }
134
135 Asserts.assertFalse(isTestFailed(), "Test failed.");
136 }
137
138 public static void main(String[] args) {
139 new Test_ia32().runTest();
|