author | epavlova |
Mon, 02 Oct 2017 14:31:34 -0700 | |
changeset 47576 | 7645833d326f |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
4580
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
1 |
/* |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
2 |
* Copyright 2009 D.E. Shaw. All Rights Reserved. |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
4 |
* |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
8 |
* |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
13 |
* accompanied this code). |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
14 |
* |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
18 |
* |
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4580
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4580
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4580
diff
changeset
|
21 |
* questions. |
4580
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
22 |
*/ |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
23 |
|
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
24 |
/** |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
25 |
* @test |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
26 |
* @bug 6912517 |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
27 |
* @summary JIT bug compiles out (and stops running) code that needs to be run. Causes NPE. |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
28 |
* |
40059 | 29 |
* @run main/othervm -Xbatch -XX:CompileThreshold=100 -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops |
30 |
* compiler.c2.Test6912517 |
|
4580
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
31 |
*/ |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
32 |
|
40059 | 33 |
package compiler.c2; |
34 |
||
4580
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
35 |
/** |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
36 |
* Highlights a bug with the JIT compiler. |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
37 |
* @author Matt Bruce m b r u c e __\at/__ g m a i l DOT c o m |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
38 |
*/ |
40059 | 39 |
public class Test6912517 implements Runnable |
4580
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
40 |
{ |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
41 |
private final Thread myThread; |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
42 |
private Thread myInitialThread; |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
43 |
private boolean myShouldCheckThreads; |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
44 |
|
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
45 |
/** |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
46 |
* Sets up the running thread, and starts it. |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
47 |
*/ |
40059 | 48 |
public Test6912517(int id) |
4580
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
49 |
{ |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
50 |
myThread = new Thread(this); |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
51 |
myThread.setName("Runner: " + id); |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
52 |
myThread.start(); |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
53 |
myShouldCheckThreads = false; |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
54 |
} |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
55 |
|
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
56 |
/** |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
57 |
* @param shouldCheckThreads the shouldCheckThreads to set |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
58 |
*/ |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
59 |
public void setShouldCheckThreads(boolean shouldCheckThreads) |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
60 |
{ |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
61 |
myShouldCheckThreads = shouldCheckThreads; |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
62 |
} |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
63 |
|
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
64 |
/** |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
65 |
* Starts up the two threads with enough delay between them for JIT to |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
66 |
* kick in. |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
67 |
* @param args |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
68 |
* @throws InterruptedException |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
69 |
*/ |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
70 |
public static void main(String[] args) throws InterruptedException |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
71 |
{ |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
72 |
// let this run for a bit, so the "run" below is JITTed. |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
73 |
for (int id = 0; id < 20; id++) { |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
74 |
System.out.println("Starting thread: " + id); |
40059 | 75 |
Test6912517 bug = new Test6912517(id); |
4580
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
76 |
bug.setShouldCheckThreads(true); |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
77 |
Thread.sleep(2500); |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
78 |
} |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
79 |
} |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
80 |
|
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
81 |
/** |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
82 |
* @see java.lang.Runnable#run() |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
83 |
*/ |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
84 |
public void run() |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
85 |
{ |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
86 |
long runNumber = 0; |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
87 |
while (true) { |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
88 |
// run hot for a little while, give JIT time to kick in to this loop. |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
89 |
// then run less hot. |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
90 |
if (runNumber > 15000) { |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
91 |
try { |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
92 |
Thread.sleep(5); |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
93 |
} |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
94 |
catch (InterruptedException e) { |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
95 |
e.printStackTrace(); |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
96 |
} |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
97 |
} |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
98 |
runNumber++; |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
99 |
ensureProperCallingThread(); |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
100 |
} |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
101 |
} |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
102 |
|
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
103 |
private void ensureProperCallingThread() |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
104 |
{ |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
105 |
// this should never be null. but with the JIT bug, it will be. |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
106 |
// JIT BUG IS HERE ==>>>>> |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
107 |
if (myShouldCheckThreads) { |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
108 |
if (myInitialThread == null) { |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
109 |
myInitialThread = Thread.currentThread(); |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
110 |
} |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
111 |
else if (myInitialThread != Thread.currentThread()) { |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
112 |
System.out.println("Not working: " + myInitialThread.getName()); |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
113 |
} |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
114 |
} |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
115 |
} |
db05951a970c
6912517: JIT bug compiles out (and stops running) code that needs to be run. Causes NPE.
kvn
parents:
diff
changeset
|
116 |
} |