author | fparain |
Fri, 11 Aug 2017 16:29:00 -0400 | |
changeset 46796 | ec791efbdecf |
parent 46349 | e12a4f6923c7 |
permissions | -rw-r--r-- |
35071
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
1 |
/* |
46349
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
2 |
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
35071
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
4 |
* |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
8 |
* |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
13 |
* accompanied this code). |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
14 |
* |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
18 |
* |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
21 |
* questions. |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
22 |
*/ |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
23 |
|
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
24 |
/* |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
25 |
* @test ReservedStackTest |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
38931
diff
changeset
|
26 |
* @library /test/lib |
38152
80e5da81fb2c
8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents:
36209
diff
changeset
|
27 |
* @modules java.base/jdk.internal.misc |
36209
8db2a78cbc29
8151156: [TESTBUG] Integrate trivial Hotspot test changes from Jake before Jigsaw M3
ctornqvi
parents:
35188
diff
changeset
|
28 |
* @modules java.base/jdk.internal.vm.annotation |
46796 | 29 |
* @run main/othervm -XX:MaxInlineLevel=2 -XX:CompileCommand=exclude,java/util/concurrent/locks/AbstractOwnableSynchronizer.setExclusiveOwnerThread ReservedStackTest |
35071
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
30 |
*/ |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
31 |
|
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
32 |
/* The exclusion of java.util.concurrent.locks.AbstractOwnableSynchronizer.setExclusiveOwnerThread() |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
33 |
* from the compilable methods is required to ensure that the test will be able |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
34 |
* to trigger a StackOverflowError on the right method. |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
35 |
*/ |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
36 |
|
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
37 |
|
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
38 |
/* |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
39 |
* Notes about this test: |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
40 |
* This test tries to reproduce a rare but nasty corruption bug that |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
41 |
* occurs when a StackOverflowError is thrown in some critical sections |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
42 |
* of the ReentrantLock implementation. |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
43 |
* |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
44 |
* Here's the critical section where a corruption could occur |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
45 |
* (from java.util.concurrent.ReentrantLock.java) |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
46 |
* |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
47 |
* final void lock() { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
48 |
* if (compareAndSetState(0, 1)) |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
49 |
* setExclusiveOwnerThread(Thread.currentThread()); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
50 |
* else |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
51 |
* acquire(1); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
52 |
* } |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
53 |
* |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
54 |
* The corruption occurs when the compareAndSetState(0, 1) |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
55 |
* successfully updates the status of the lock but the method |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
56 |
* fails to set the owner because of a stack overflow. |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
57 |
* HotSpot checks for stack overflow on method invocations. |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
58 |
* The test must trigger a stack overflow either when |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
59 |
* Thread.currentThread() or setExclusiveOwnerThread() is |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
60 |
* invoked. |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
61 |
* |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
62 |
* The test starts with a recursive invocation loop until a |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
63 |
* first StackOverflowError is thrown, the Error is caught |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
64 |
* and a few dozen frames are exited. Now the thread has |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
65 |
* little free space on its execution stack and will try |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
66 |
* to trigger a stack overflow in the critical section. |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
67 |
* The test has a huge array of ReentrantLocks instances. |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
68 |
* The thread invokes a recursive method which, at each |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
69 |
* of its invocations, tries to acquire the next lock |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
70 |
* in the array. The execution continues until a |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
71 |
* StackOverflowError is thrown or the end of the array |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
72 |
* is reached. |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
73 |
* If no StackOverflowError has been thrown, the test |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
74 |
* is non conclusive (recommendation: increase the size |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
75 |
* of the ReentrantLock array). |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
76 |
* The status of all Reentrant locks in the array is checked, |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
77 |
* if a corruption is detected, the test failed, otherwise |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
78 |
* the test passed. |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
79 |
* |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
80 |
* To have a chance that the stack overflow occurs on one |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
81 |
* of the two targeted method invocations, the test is |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
82 |
* repeated in different threads. Each Java thread has a |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
83 |
* random size area allocated at the beginning of its |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
84 |
* stack to prevent false sharing. The test relies on this |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
85 |
* to have different stack alignments when it hits the targeted |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
86 |
* methods (the test could have been written with a native |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
87 |
* method with alloca, but using different Java threads makes |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
88 |
* the test 100% Java). |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
89 |
* |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
90 |
* One additional trick is required to ensure that the stack |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
91 |
* overflow will occur on the Thread.currentThread() getter |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
92 |
* or the setExclusiveOwnerThread() setter. |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
93 |
* |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
94 |
* Potential stack overflows are detected by stack banging, |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
95 |
* at method invocation time. |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
96 |
* In interpreted code, the stack banging performed for the |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
97 |
* lock() method goes further than the stack banging performed |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
98 |
* for the getter or the setter method, so the potential stack |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
99 |
* overflow is detected before entering the critical section. |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
100 |
* In compiled code, the getter and the setter are in-lined, |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
101 |
* so the stack banging is only performed before entering the |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
102 |
* critical section. |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
103 |
* In order to have a stack banging that goes further for the |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
104 |
* getter/setter methods than for the lock() method, the test |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
105 |
* exploits the property that interpreter frames are (much) |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
106 |
* bigger than compiled code frames. When the test is run, |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
107 |
* a compiler option disables the compilation of the |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
108 |
* setExclusiveOwnerThread() method. |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
109 |
* |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
110 |
*/ |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
111 |
|
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
112 |
import java.util.concurrent.locks.ReentrantLock; |
35188
c058f99ad8fe
8145317: ReservedStackTest fails with ReentrantLock looks corrupted
fparain
parents:
35071
diff
changeset
|
113 |
import jdk.test.lib.Platform; |
46349
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
114 |
import jdk.test.lib.process.ProcessTools; |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
115 |
import jdk.test.lib.process.OutputAnalyzer; |
35071
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
116 |
|
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
117 |
public class ReservedStackTest { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
118 |
|
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
119 |
static class ReentrantLockTest { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
120 |
|
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
121 |
private ReentrantLock lockArray[]; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
122 |
// Frame sizes vary a lot between interpreted code and compiled code |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
123 |
// so the lock array has to be big enough to cover all cases. |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
124 |
// If test fails with message "Not conclusive test", try to increase |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
125 |
// LOCK_ARRAY_SIZE value |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
126 |
private static final int LOCK_ARRAY_SIZE = 8192; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
127 |
private boolean stackOverflowErrorReceived; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
128 |
StackOverflowError soe = null; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
129 |
private int index = -1; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
130 |
|
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
131 |
public void initialize() { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
132 |
lockArray = new ReentrantLock[LOCK_ARRAY_SIZE]; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
133 |
for (int i = 0; i < LOCK_ARRAY_SIZE; i++) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
134 |
lockArray[i] = new ReentrantLock(); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
135 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
136 |
stackOverflowErrorReceived = false; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
137 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
138 |
|
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
139 |
public String getResult() { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
140 |
if (!stackOverflowErrorReceived) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
141 |
return "ERROR: Not conclusive test: no StackOverflowError received"; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
142 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
143 |
for (int i = 0; i < LOCK_ARRAY_SIZE; i++) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
144 |
if (lockArray[i].isLocked()) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
145 |
if (!lockArray[i].isHeldByCurrentThread()) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
146 |
StringBuilder s = new StringBuilder(); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
147 |
s.append("FAILED: ReentrantLock "); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
148 |
s.append(i); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
149 |
s.append(" looks corrupted"); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
150 |
return s.toString(); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
151 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
152 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
153 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
154 |
return "PASSED"; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
155 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
156 |
|
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
157 |
public void run() { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
158 |
try { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
159 |
lockAndCall(0); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
160 |
} catch (StackOverflowError e) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
161 |
soe = e; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
162 |
stackOverflowErrorReceived = true; |
46796 | 163 |
throw e; |
35071
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
164 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
165 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
166 |
|
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
167 |
private void lockAndCall(int i) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
168 |
index = i; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
169 |
if (i < LOCK_ARRAY_SIZE) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
170 |
lockArray[i].lock(); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
171 |
lockAndCall(i + 1); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
172 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
173 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
174 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
175 |
|
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
176 |
static class RunWithSOEContext implements Runnable { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
177 |
|
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
178 |
int counter; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
179 |
int deframe; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
180 |
int decounter; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
181 |
int setupSOEFrame; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
182 |
int testStartFrame; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
183 |
ReentrantLockTest test; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
184 |
|
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
185 |
public RunWithSOEContext(ReentrantLockTest test, int deframe) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
186 |
this.test = test; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
187 |
this.deframe = deframe; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
188 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
189 |
|
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
190 |
@Override |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
191 |
@jdk.internal.vm.annotation.ReservedStackAccess |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
192 |
public void run() { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
193 |
counter = 0; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
194 |
decounter = deframe; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
195 |
test.initialize(); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
196 |
recursiveCall(); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
197 |
String result = test.getResult(); |
35188
c058f99ad8fe
8145317: ReservedStackTest fails with ReentrantLock looks corrupted
fparain
parents:
35071
diff
changeset
|
198 |
// The feature is not fully implemented on all platforms, |
38931
3cf28d630349
8156923: [ppc] Implement "JEP 270: Reserved Stack Areas for Critical Sections".
goetz
parents:
38152
diff
changeset
|
199 |
// corruptions are still possible. |
46349
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
200 |
if (isSupportedPlatform && !result.contains("PASSED")) { |
35188
c058f99ad8fe
8145317: ReservedStackTest fails with ReentrantLock looks corrupted
fparain
parents:
35071
diff
changeset
|
201 |
throw new Error(result); |
c058f99ad8fe
8145317: ReservedStackTest fails with ReentrantLock looks corrupted
fparain
parents:
35071
diff
changeset
|
202 |
} else { |
c058f99ad8fe
8145317: ReservedStackTest fails with ReentrantLock looks corrupted
fparain
parents:
35071
diff
changeset
|
203 |
// Either the test passed or this platform is not supported. |
c058f99ad8fe
8145317: ReservedStackTest fails with ReentrantLock looks corrupted
fparain
parents:
35071
diff
changeset
|
204 |
// On not supported platforms, we only expect the VM to |
c058f99ad8fe
8145317: ReservedStackTest fails with ReentrantLock looks corrupted
fparain
parents:
35071
diff
changeset
|
205 |
// not crash during the test. This is especially important |
c058f99ad8fe
8145317: ReservedStackTest fails with ReentrantLock looks corrupted
fparain
parents:
35071
diff
changeset
|
206 |
// on Windows where the detection of SOE in annotated |
c058f99ad8fe
8145317: ReservedStackTest fails with ReentrantLock looks corrupted
fparain
parents:
35071
diff
changeset
|
207 |
// sections is implemented but the reserved zone mechanism |
c058f99ad8fe
8145317: ReservedStackTest fails with ReentrantLock looks corrupted
fparain
parents:
35071
diff
changeset
|
208 |
// to avoid the corruption cannot be implemented yet |
c058f99ad8fe
8145317: ReservedStackTest fails with ReentrantLock looks corrupted
fparain
parents:
35071
diff
changeset
|
209 |
// because of JDK-8067946 |
c058f99ad8fe
8145317: ReservedStackTest fails with ReentrantLock looks corrupted
fparain
parents:
35071
diff
changeset
|
210 |
System.out.println("PASSED"); |
35071
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
211 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
212 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
213 |
|
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
214 |
void recursiveCall() { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
215 |
// Unused local variables to increase the frame size |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
216 |
long l1, l2, l3, l4, l5, l6, l7, l8, l9, l10, l11, l12, l13, l14, l15, l16, l17, l18, l19; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
217 |
long l20, l21, l22, l23, l24, l25, l26, l27, l28, l30, l31, l32, l33, l34, l35, l36, l37; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
218 |
counter++; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
219 |
try { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
220 |
recursiveCall(); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
221 |
} catch (StackOverflowError e) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
222 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
223 |
decounter--; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
224 |
if (decounter == 0) { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
225 |
setupSOEFrame = counter; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
226 |
testStartFrame = counter - deframe; |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
227 |
test.run(); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
228 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
229 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
230 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
231 |
|
46349
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
232 |
private static boolean isAlwaysSupportedPlatform() { |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
233 |
// Note: To date Aarch64 is the only platform that we don't statically |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
234 |
// know if it supports the reserved stack area. This is because the |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
235 |
// open Aarch64 port supports it and the Oracle arm64 port does not. |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
236 |
return Platform.isAix() || |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
237 |
(Platform.isLinux() && |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
238 |
(Platform.isPPC() || Platform.isS390x() || Platform.isX64() || |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
239 |
Platform.isX86())) || |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
240 |
Platform.isOSX() || |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
241 |
Platform.isSolaris(); |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
242 |
} |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
243 |
|
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
244 |
private static boolean isNeverSupportedPlatform() { |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
245 |
return !isAlwaysSupportedPlatform() && !Platform.isAArch64(); |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
246 |
} |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
247 |
|
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
248 |
private static boolean isSupportedPlatform; |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
249 |
|
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
250 |
private static void initIsSupportedPlatform() throws Exception { |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
251 |
// In order to dynamicaly determine if the platform supports the reserved |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
252 |
// stack area, run with -XX:StackReservedPages=1 and see if we get the |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
253 |
// expected warning message for platforms that don't support it. |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
254 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:StackReservedPages=1", "-version"); |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
255 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
256 |
System.out.println("StackReservedPages=1 log: [" + output.getOutput() + "]"); |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
257 |
if (output.getExitValue() != 0) { |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
258 |
String msg = "Could not launch with -XX:StackReservedPages=1: exit " + output.getExitValue(); |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
259 |
System.err.println("FAILED: " + msg); |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
260 |
throw new RuntimeException(msg); |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
261 |
} |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
262 |
|
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
263 |
isSupportedPlatform = true; |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
264 |
String matchStr = "Reserved Stack Area not supported on this platform"; |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
265 |
int match_idx = output.getOutput().indexOf(matchStr); |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
266 |
if (match_idx >= 0) { |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
267 |
isSupportedPlatform = false; |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
268 |
} |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
269 |
|
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
270 |
// Do a sanity check. Some platforms we know are always supported. Make sure |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
271 |
// we didn't determine that one of those platforms is not supported. |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
272 |
if (!isSupportedPlatform && isAlwaysSupportedPlatform()) { |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
273 |
String msg = "This platform should be supported: " + Platform.getOsArch(); |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
274 |
System.err.println("FAILED: " + msg); |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
275 |
throw new RuntimeException(msg); |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
276 |
} |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
277 |
|
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
278 |
// And some platforms we know are never supported. Make sure |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
279 |
// we didn't determine that one of those platforms is supported. |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
280 |
if (isSupportedPlatform && isNeverSupportedPlatform()) { |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
281 |
String msg = "This platform should not be supported: " + Platform.getOsArch(); |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
282 |
System.err.println("FAILED: " + msg); |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
283 |
throw new RuntimeException(msg); |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
284 |
} |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
285 |
} |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
286 |
|
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
287 |
public static void main(String[] args) throws Exception { |
e12a4f6923c7
8177055: [TESTBUG] test/runtime/ReservedStack/ReservedStackTest.java sometimes fails on Oracle arm64 port after being enabled for open aarch64 port
cjplummer
parents:
43439
diff
changeset
|
288 |
initIsSupportedPlatform(); |
46796 | 289 |
for (int i = 0; i < 100; i++) { |
35071
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
290 |
// Each iteration has to be executed by a new thread. The test |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
291 |
// relies on the random size area pushed by the VM at the beginning |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
292 |
// of the stack of each Java thread it creates. |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
293 |
Thread thread = new Thread(new RunWithSOEContext(new ReentrantLockTest(), 256)); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
294 |
thread.start(); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
295 |
try { |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
296 |
thread.join(); |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
297 |
} catch (InterruptedException ex) { } |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
298 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
299 |
} |
a0910b1d3e0d
8046936: JEP 270: Reserved Stack Areas for Critical Sections
fparain
parents:
diff
changeset
|
300 |
} |