author | iignatyev |
Wed, 13 Nov 2019 11:34:31 -0800 | |
changeset 59064 | f1a5d48d0471 |
parent 55206 | 2fe2063fe567 |
permissions | -rw-r--r-- |
55206 | 1 |
/* |
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
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 |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
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 OSRFailureLevel4Test |
|
26 |
* @summary check that not compilable OSR level 4 results in falling back to level 1 |
|
27 |
* @library /test/lib / |
|
28 |
* @modules java.base/jdk.internal.misc |
|
29 |
* java.management |
|
59064
f1a5d48d0471
8226795: compiler/tiered/Level2RecompilationTest.java fails when XX:TieredStopAtLevel=1/2/3 is set
iignatyev
parents:
55206
diff
changeset
|
30 |
* |
f1a5d48d0471
8226795: compiler/tiered/Level2RecompilationTest.java fails when XX:TieredStopAtLevel=1/2/3 is set
iignatyev
parents:
55206
diff
changeset
|
31 |
* @comment the test can't be run w/ TieredStopAtLevel < 4 |
f1a5d48d0471
8226795: compiler/tiered/Level2RecompilationTest.java fails when XX:TieredStopAtLevel=1/2/3 is set
iignatyev
parents:
55206
diff
changeset
|
32 |
* @requires vm.flavor == "server" & (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel == 4) |
f1a5d48d0471
8226795: compiler/tiered/Level2RecompilationTest.java fails when XX:TieredStopAtLevel=1/2/3 is set
iignatyev
parents:
55206
diff
changeset
|
33 |
* |
55206 | 34 |
* @build sun.hotspot.WhiteBox |
35 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
|
36 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
|
37 |
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions |
|
38 |
* -XX:+WhiteBoxAPI -XX:+TieredCompilation compiler.whitebox.OSRFailureLevel4Test |
|
39 |
*/ |
|
40 |
||
41 |
package compiler.whitebox; |
|
42 |
||
43 |
import sun.hotspot.WhiteBox; |
|
44 |
import java.lang.reflect.Executable; |
|
45 |
import java.lang.reflect.Method; |
|
46 |
||
47 |
public class OSRFailureLevel4Test extends Thread { |
|
48 |
private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); |
|
49 |
private static final long BACKEDGE_THRESHOLD = 150000; |
|
50 |
private Method method; |
|
51 |
||
52 |
public static void main(String[] args) throws Exception { |
|
53 |
OSRFailureLevel4Test test = new OSRFailureLevel4Test(); |
|
54 |
test.test(); |
|
55 |
} |
|
56 |
||
57 |
/** |
|
58 |
* Triggers two different OSR compilations for the same method and |
|
59 |
* checks if WhiteBox.deoptimizeMethod() deoptimizes both. |
|
60 |
* |
|
61 |
* @throws Exception |
|
62 |
*/ |
|
63 |
public void test() throws Exception { |
|
64 |
method = OSRFailureLevel4Test.class.getDeclaredMethod("run"); |
|
65 |
WHITE_BOX.makeMethodNotCompilable(method, 4, true); |
|
66 |
||
67 |
Thread t = new OSRFailureLevel4Test(); |
|
68 |
t.setDaemon(true); |
|
69 |
t.start(); |
|
70 |
||
71 |
int currentLevel = 0; |
|
72 |
int loops = 0; |
|
73 |
while (true) { |
|
74 |
int level = WHITE_BOX.getMethodCompilationLevel(method, true); |
|
75 |
if (level == 1) { |
|
76 |
System.err.println("success"); |
|
77 |
running = false; |
|
78 |
return; |
|
79 |
} |
|
80 |
if (level == currentLevel) { |
|
81 |
Thread.sleep(1000); |
|
82 |
loops++; |
|
83 |
if (loops > 100) { |
|
84 |
running = false; |
|
85 |
throw new AssertionError("Never reached level 1"); |
|
86 |
} |
|
87 |
continue; |
|
88 |
} |
|
89 |
currentLevel = level; |
|
90 |
System.err.println("Current level = " + currentLevel); |
|
91 |
} |
|
92 |
||
93 |
} |
|
94 |
||
95 |
static volatile int counter = 0; |
|
96 |
static boolean running = true; |
|
97 |
||
98 |
public void run() { |
|
99 |
while (running) { |
|
100 |
counter++; |
|
101 |
} |
|
102 |
} |
|
103 |
} |