author | jiangli |
Wed, 27 Sep 2017 17:55:20 -0400 | |
changeset 47548 | 664b9d44db74 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
27434
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
1 |
/* |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40059
diff
changeset
|
2 |
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. |
27434
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
4 |
* |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
8 |
* |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
13 |
* accompanied this code). |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
14 |
* |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
18 |
* |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
21 |
* questions. |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
22 |
*/ |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
23 |
|
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
24 |
|
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
25 |
/* |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
26 |
* @test DeoptimizeMultipleOSRTest |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
27 |
* @bug 8061817 |
40059 | 28 |
* @summary testing of WB::deoptimizeMethod() |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40059
diff
changeset
|
29 |
* @library /test/lib / |
38152
80e5da81fb2c
8154258: [TESTBUG] Various serviceability tests fail compilation
dsamersoff
parents:
34185
diff
changeset
|
30 |
* @modules java.base/jdk.internal.misc |
40059 | 31 |
* java.management |
40631
ed82623d7831
8157957: ClassNotFoundException: jdk.test.lib.JDKToolFinder
ctornqvi
parents:
40059
diff
changeset
|
32 |
* @build sun.hotspot.WhiteBox |
40059 | 33 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
34 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
|
35 |
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI |
|
36 |
* -XX:CompileCommand=compileonly,compiler.whitebox.DeoptimizeMultipleOSRTest::triggerOSR |
|
37 |
* compiler.whitebox.DeoptimizeMultipleOSRTest |
|
27434
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
38 |
*/ |
40059 | 39 |
|
40 |
package compiler.whitebox; |
|
41 |
||
42 |
import sun.hotspot.WhiteBox; |
|
43 |
||
44 |
import java.lang.reflect.Method; |
|
45 |
||
27434
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
46 |
public class DeoptimizeMultipleOSRTest { |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
47 |
private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
48 |
private static final long BACKEDGE_THRESHOLD = 150000; |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
49 |
private Method method; |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
50 |
private int counter = 0; |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
51 |
|
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
52 |
public static void main(String[] args) throws Exception { |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
53 |
DeoptimizeMultipleOSRTest test = new DeoptimizeMultipleOSRTest(); |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
54 |
test.test(); |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
55 |
} |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
56 |
|
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
57 |
/** |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
58 |
* Triggers two different OSR compilations for the same method and |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
59 |
* checks if WhiteBox.deoptimizeMethod() deoptimizes both. |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
60 |
* |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
61 |
* @throws Exception |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
62 |
*/ |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
63 |
public void test() throws Exception { |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
64 |
method = DeoptimizeMultipleOSRTest.class.getDeclaredMethod("triggerOSR", boolean.class, long.class); |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
65 |
// Trigger two OSR compiled versions |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
66 |
triggerOSR(true, BACKEDGE_THRESHOLD); |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
67 |
triggerOSR(false, BACKEDGE_THRESHOLD); |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
68 |
// Wait for compilation |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
69 |
CompilerWhiteBoxTest.waitBackgroundCompilation(method); |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
70 |
// Deoptimize |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
71 |
WHITE_BOX.deoptimizeMethod(method, true); |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
72 |
if (WHITE_BOX.isMethodCompiled(method, true)) { |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
73 |
throw new AssertionError("Not all OSR compiled versions were deoptimized"); |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
74 |
} |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
75 |
} |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
76 |
|
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
77 |
/** |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
78 |
* Triggers OSR compilations by executing loops. |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
79 |
* |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
80 |
* @param first Determines which loop to execute |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
81 |
* @param limit The number of loop iterations |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
82 |
*/ |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
83 |
public void triggerOSR(boolean first, long limit) { |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
84 |
if (limit != 1) { |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
85 |
// Warmup method to avoid uncommon traps |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
86 |
for (int i = 0; i < limit; ++i) { |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
87 |
triggerOSR(first, 1); |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
88 |
} |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
89 |
CompilerWhiteBoxTest.waitBackgroundCompilation(method); |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
90 |
} |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
91 |
if (first) { |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
92 |
// Trigger OSR compilation 1 |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
93 |
for (int i = 0; i < limit; ++i) { |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
94 |
counter++; |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
95 |
} |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
96 |
} else { |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
97 |
// Trigger OSR compilation 2 |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
98 |
for (int i = 0; i < limit; ++i) { |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
99 |
counter++; |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
100 |
} |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
101 |
} |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
102 |
} |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
103 |
} |