author | alanb |
Tue, 03 May 2016 09:11:31 +0100 | |
changeset 37827 | 09fa0c82a5f7 |
parent 36851 | 03e2f4d0a421 |
child 38033 | 996ce936543f |
permissions | -rw-r--r-- |
28194
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
1 |
/* |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
29333
diff
changeset
|
2 |
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
28194
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
4 |
* |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
8 |
* |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
13 |
* accompanied this code). |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
14 |
* |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
18 |
* |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
21 |
* questions. |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
22 |
*/ |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
23 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
24 |
import java.lang.reflect.Executable; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
25 |
import java.lang.reflect.Method; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
26 |
import java.util.Objects; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
27 |
import java.util.concurrent.Callable; |
34155
8d9e0cbf93a2
8138689: use package for /compiler/whitebox common classes
dpochepk
parents:
29678
diff
changeset
|
28 |
import compiler.whitebox.CompilerWhiteBoxTest; |
8d9e0cbf93a2
8138689: use package for /compiler/whitebox common classes
dpochepk
parents:
29678
diff
changeset
|
29 |
import compiler.whitebox.SimpleTestCase; |
28194
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
30 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
31 |
/** |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
32 |
* @test LevelTransitionTest |
34185 | 33 |
* @library /testlibrary /test/lib /compiler/whitebox / |
36851 | 34 |
* @modules java.base/jdk.internal.misc |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
29333
diff
changeset
|
35 |
* java.management |
29333
de8c4e5034d8
8073499: quarantine compiler/tiered/LevelTransitionTest
iignatyev
parents:
28194
diff
changeset
|
36 |
* @ignore 8067651 |
28194
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
37 |
* @build TransitionsTestExecutor LevelTransitionTest |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
38 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
39 |
* @run main/othervm/timeout=240 -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
40 |
* -XX:+WhiteBoxAPI -XX:+TieredCompilation |
34155
8d9e0cbf93a2
8138689: use package for /compiler/whitebox common classes
dpochepk
parents:
29678
diff
changeset
|
41 |
* -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCase$Helper::* |
28194
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
42 |
* -XX:CompileCommand=compileonly,ExtendedTestCase$CompileMethodHolder::* |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
43 |
* TransitionsTestExecutor LevelTransitionTest |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
44 |
* @summary Test the correctness of compilation level transitions for different methods |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
45 |
*/ |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
46 |
public class LevelTransitionTest extends TieredLevelsTest { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
47 |
/** Shows if method was profiled by being executed on levels 2 or 3 */ |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
48 |
protected boolean isMethodProfiled; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
49 |
private int transitionCount; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
50 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
51 |
public static void main(String[] args) throws Throwable { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
52 |
assert (!CompilerWhiteBoxTest.skipOnTieredCompilation(false)); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
53 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
54 |
CompilerWhiteBoxTest.main(LevelTransitionTest::new, args); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
55 |
// run extended test cases |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
56 |
for (TestCase testCase : ExtendedTestCase.values()) { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
57 |
new LevelTransitionTest(testCase).runTest(); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
58 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
59 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
60 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
61 |
protected LevelTransitionTest(TestCase testCase) { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
62 |
super(testCase); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
63 |
isMethodProfiled = testCase.isOsr(); // OSR methods were already profiled by warmup |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
64 |
transitionCount = 0; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
65 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
66 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
67 |
@Override |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
68 |
protected void test() throws Exception { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
69 |
checkTransitions(); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
70 |
deoptimize(); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
71 |
printInfo(); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
72 |
if (testCase.isOsr()) { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
73 |
// deoptimization makes the following transitions be unstable |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
74 |
// methods go to level 3 before 4 because of uncommon_trap and reprofile |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
75 |
return; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
76 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
77 |
checkTransitions(); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
78 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
79 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
80 |
/** |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
81 |
* Makes and verifies transitions between compilation levels |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
82 |
*/ |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
83 |
protected void checkTransitions() { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
84 |
checkNotCompiled(); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
85 |
boolean finish = false; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
86 |
while (!finish) { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
87 |
System.out.printf("Level transition #%d%n", ++transitionCount); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
88 |
int newLevel; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
89 |
int current = getCompLevel(); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
90 |
int expected = getNextLevel(current); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
91 |
if (current == expected) { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
92 |
// if we are on expected level, just execute it more |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
93 |
// to ensure that the level won't change |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
94 |
System.out.printf("Method %s is already on expected level %d%n", method, expected); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
95 |
compile(); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
96 |
newLevel = getCompLevel(); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
97 |
finish = true; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
98 |
} else { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
99 |
newLevel = changeCompLevel(); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
100 |
finish = false; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
101 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
102 |
System.out.printf("Method %s is compiled on level %d. Expected level is %d%n", method, newLevel, expected); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
103 |
checkLevel(expected, newLevel); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
104 |
printInfo(); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
105 |
}; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
106 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
107 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
108 |
/** |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
109 |
* Gets next expected level for the test case on each transition. |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
110 |
* |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
111 |
* @param currentLevel a level the test case is compiled on |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
112 |
* @return expected compilation level |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
113 |
*/ |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
114 |
protected int getNextLevel(int currentLevel) { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
115 |
int nextLevel = currentLevel; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
116 |
switch (currentLevel) { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
117 |
case CompilerWhiteBoxTest.COMP_LEVEL_NONE: |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
118 |
nextLevel = isMethodProfiled ? CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
119 |
: CompilerWhiteBoxTest.COMP_LEVEL_FULL_PROFILE; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
120 |
break; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
121 |
case CompilerWhiteBoxTest.COMP_LEVEL_LIMITED_PROFILE: |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
122 |
case CompilerWhiteBoxTest.COMP_LEVEL_FULL_PROFILE: |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
123 |
nextLevel = CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
124 |
isMethodProfiled = true; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
125 |
break; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
126 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
127 |
nextLevel = isTrivial() ? CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE : nextLevel; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
128 |
return Math.min(nextLevel, CompilerWhiteBoxTest.TIERED_STOP_AT_LEVEL); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
129 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
130 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
131 |
/** |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
132 |
* Determines if tested method should be handled as trivial |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
133 |
* |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
134 |
* @return {@code true} for trivial methods, {@code false} otherwise |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
135 |
*/ |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
136 |
protected boolean isTrivial() { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
137 |
return testCase == ExtendedTestCase.ACCESSOR_TEST |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
138 |
|| testCase == SimpleTestCase.METHOD_TEST |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
139 |
|| testCase == SimpleTestCase.STATIC_TEST |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
140 |
|| (testCase == ExtendedTestCase.TRIVIAL_CODE_TEST && isMethodProfiled); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
141 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
142 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
143 |
/** |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
144 |
* Invokes {@linkplain #method} until its compilation level is changed. |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
145 |
* Note that if the level won't change, it will be an endless loop |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
146 |
* |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
147 |
* @return compilation level the {@linkplain #method} was compiled on |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
148 |
*/ |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
149 |
protected int changeCompLevel() { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
150 |
int currentLevel = getCompLevel(); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
151 |
int newLevel = currentLevel; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
152 |
int result = 0; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
153 |
while (currentLevel == newLevel) { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
154 |
result = compile(1); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
155 |
if (WHITE_BOX.isMethodCompiled(method, testCase.isOsr())) { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
156 |
newLevel = getCompLevel(); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
157 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
158 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
159 |
return newLevel; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
160 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
161 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
162 |
protected static class Helper { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
163 |
/** |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
164 |
* Gets method from a specified class using its name |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
165 |
* |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
166 |
* @param aClass type method belongs to |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
167 |
* @param name the name of the method |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
168 |
* @return {@link Method} that represents corresponding class method |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
169 |
*/ |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
170 |
public static Method getMethod(Class<?> aClass, String name) { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
171 |
Method method; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
172 |
try { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
173 |
method = aClass.getDeclaredMethod(name); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
174 |
} catch (NoSuchMethodException e) { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
175 |
throw new Error("TESTBUG: Unable to get method " + name, e); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
176 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
177 |
return method; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
178 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
179 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
180 |
/** |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
181 |
* Gets {@link Callable} that invokes given method from the given object |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
182 |
* |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
183 |
* @param object the object the specified method is invoked from |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
184 |
* @param name the name of the method |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
185 |
*/ |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
186 |
public static Callable<Integer> getCallable(Object object, String name) { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
187 |
Method method = getMethod(object.getClass(), name); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
188 |
return () -> { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
189 |
try { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
190 |
return Objects.hashCode(method.invoke(object)); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
191 |
} catch (ReflectiveOperationException e) { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
192 |
throw new Error("TESTBUG: Invocation failure", e); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
193 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
194 |
}; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
195 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
196 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
197 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
198 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
199 |
enum ExtendedTestCase implements CompilerWhiteBoxTest.TestCase { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
200 |
ACCESSOR_TEST("accessor"), |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
201 |
NONTRIVIAL_METHOD_TEST("nonTrivialMethod"), |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
202 |
TRIVIAL_CODE_TEST("trivialCode"); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
203 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
204 |
private final Executable executable; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
205 |
private final Callable<Integer> callable; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
206 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
207 |
@Override |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
208 |
public Executable getExecutable() { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
209 |
return executable; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
210 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
211 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
212 |
@Override |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
213 |
public Callable<Integer> getCallable() { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
214 |
return callable; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
215 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
216 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
217 |
@Override |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
218 |
public boolean isOsr() { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
219 |
return false; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
220 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
221 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
222 |
private ExtendedTestCase(String methodName) { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
223 |
this.executable = LevelTransitionTest.Helper.getMethod(CompileMethodHolder.class, methodName); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
224 |
this.callable = LevelTransitionTest.Helper.getCallable(new CompileMethodHolder(), methodName); |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
225 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
226 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
227 |
private static class CompileMethodHolder { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
228 |
private final int iter = 10; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
229 |
private int field = 42; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
230 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
231 |
/** Non-trivial method for threshold policy: contains loops */ |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
232 |
public int nonTrivialMethod() { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
233 |
int acc = 0; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
234 |
for (int i = 0; i < iter; i++) { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
235 |
acc += i; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
236 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
237 |
return acc; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
238 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
239 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
240 |
/** Field accessor method */ |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
241 |
public int accessor() { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
242 |
return field; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
243 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
244 |
|
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
245 |
/** Method considered as trivial by amount of code */ |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
246 |
public int trivialCode() { |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
247 |
int var = 0xBAAD_C0DE; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
248 |
var *= field; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
249 |
return var; |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
250 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
251 |
} |
8c6c124a108b
8059575: JEP-JDK-8043304: Test task: Tiered Compilation level transition tests
ppunegov
parents:
diff
changeset
|
252 |
} |