author | chegar |
Tue, 22 Mar 2016 15:26:07 +0000 | |
changeset 36694 | 182a5e7a519e |
parent 34185 | ee71c590a456 |
child 38152 | 80e5da81fb2c |
permissions | -rw-r--r-- |
27434
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
1 |
/* |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
28190
diff
changeset
|
2 |
* Copyright (c) 2013, 2015, 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 |
import sun.hotspot.WhiteBox; |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
25 |
import java.lang.reflect.Executable; |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
26 |
import java.lang.reflect.Method; |
34155
8d9e0cbf93a2
8138689: use package for /compiler/whitebox common classes
dpochepk
parents:
29678
diff
changeset
|
27 |
import compiler.whitebox.CompilerWhiteBoxTest; |
27434
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
28 |
|
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
29 |
/* |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
30 |
* @test DeoptimizeMultipleOSRTest |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
31 |
* @bug 8061817 |
34185 | 32 |
* @library /testlibrary /test/lib / |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
28190
diff
changeset
|
33 |
* @modules java.management |
27434
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
34 |
* @build DeoptimizeMultipleOSRTest |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
35 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
36 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
37 |
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,DeoptimizeMultipleOSRTest::triggerOSR DeoptimizeMultipleOSRTest |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
38 |
* @summary testing of WB::deoptimizeMethod() |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
39 |
*/ |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
40 |
public class DeoptimizeMultipleOSRTest { |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
41 |
private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
42 |
private static final long BACKEDGE_THRESHOLD = 150000; |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
43 |
private Method method; |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
44 |
private int counter = 0; |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
45 |
|
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
46 |
public static void main(String[] args) throws Exception { |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
47 |
DeoptimizeMultipleOSRTest test = new DeoptimizeMultipleOSRTest(); |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
48 |
test.test(); |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
49 |
} |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
50 |
|
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 |
* 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
|
53 |
* checks if WhiteBox.deoptimizeMethod() deoptimizes both. |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
54 |
* |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
55 |
* @throws Exception |
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 |
public void test() throws Exception { |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
58 |
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
|
59 |
// Trigger two OSR compiled versions |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
60 |
triggerOSR(true, BACKEDGE_THRESHOLD); |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
61 |
triggerOSR(false, BACKEDGE_THRESHOLD); |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
62 |
// Wait for compilation |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
63 |
CompilerWhiteBoxTest.waitBackgroundCompilation(method); |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
64 |
// Deoptimize |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
65 |
WHITE_BOX.deoptimizeMethod(method, true); |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
66 |
if (WHITE_BOX.isMethodCompiled(method, true)) { |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
67 |
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
|
68 |
} |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
69 |
} |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
70 |
|
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
71 |
/** |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
72 |
* Triggers OSR compilations by executing loops. |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
73 |
* |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
74 |
* @param first Determines which loop to execute |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
75 |
* @param limit The number of loop iterations |
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 |
public void triggerOSR(boolean first, long limit) { |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
78 |
if (limit != 1) { |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
79 |
// Warmup method to avoid uncommon traps |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
80 |
for (int i = 0; i < limit; ++i) { |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
81 |
triggerOSR(first, 1); |
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 |
CompilerWhiteBoxTest.waitBackgroundCompilation(method); |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
84 |
} |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
85 |
if (first) { |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
86 |
// Trigger OSR compilation 1 |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
87 |
for (int i = 0; i < limit; ++i) { |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
88 |
counter++; |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
89 |
} |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
90 |
} else { |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
91 |
// Trigger OSR compilation 2 |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
92 |
for (int i = 0; i < limit; ++i) { |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
93 |
counter++; |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
94 |
} |
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 |
} |
b4b185d05bb5
8061817: Whitebox.deoptimizeMethod() does not deoptimize all OSR versions of method
thartmann
parents:
diff
changeset
|
97 |
} |