author | bharadwaj |
Tue, 12 Apr 2016 14:17:42 -0400 | |
changeset 38033 | 996ce936543f |
parent 36851 | 03e2f4d0a421 |
parent 38025 | 5ed9ce1e4a2f |
child 40059 | c2304140ed64 |
permissions | -rw-r--r-- |
15621 | 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. |
15621 | 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 IsMethodCompilableTest |
|
19332 | 26 |
* @bug 8007270 8006683 8007288 8022832 |
34185 | 27 |
* @library /testlibrary /test/lib / |
36851 | 28 |
* @modules java.base/jdk.internal.misc |
29678
dd2f3932c21e
8075586: Add @modules as needed to the open hotspot tests
ykantser
parents:
28190
diff
changeset
|
29 |
* java.management |
38025
5ed9ce1e4a2f
8151880: EnqueueMethodForCompilationTest.java still fails to compile method
neliasso
parents:
34185
diff
changeset
|
30 |
* @build jdk.test.lib.* |
5ed9ce1e4a2f
8151880: EnqueueMethodForCompilationTest.java still fails to compile method
neliasso
parents:
34185
diff
changeset
|
31 |
* sun.hotspot.WhiteBox |
15793
4867678e3517
8006753: fix failed for JDK-8002415 White box testing API for HotSpot
mgerdin
parents:
15621
diff
changeset
|
32 |
* @build IsMethodCompilableTest |
38025
5ed9ce1e4a2f
8151880: EnqueueMethodForCompilationTest.java still fails to compile method
neliasso
parents:
34185
diff
changeset
|
33 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
5ed9ce1e4a2f
8151880: EnqueueMethodForCompilationTest.java still fails to compile method
neliasso
parents:
34185
diff
changeset
|
34 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
5ed9ce1e4a2f
8151880: EnqueueMethodForCompilationTest.java still fails to compile method
neliasso
parents:
34185
diff
changeset
|
35 |
* jdk.test.lib.Platform |
5ed9ce1e4a2f
8151880: EnqueueMethodForCompilationTest.java still fails to compile method
neliasso
parents:
34185
diff
changeset
|
36 |
* @run main/othervm/timeout=2400 -Xbootclasspath/a:. -Xmixed -XX:-TieredCompilation -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:PerMethodRecompilationCutoff=3 -XX:-UseCounterDecay -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCaseHelper::* IsMethodCompilableTest |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
37 |
* @summary testing of WB::isMethodCompilable() |
15621 | 38 |
* @author igor.ignatyev@oracle.com |
39 |
*/ |
|
23188
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
40 |
|
30604
b8d532cb6420
8067013: Rename the com.oracle.java.testlibary package
ykantser
parents:
29678
diff
changeset
|
41 |
import jdk.test.lib.Platform; |
34155
8d9e0cbf93a2
8138689: use package for /compiler/whitebox common classes
dpochepk
parents:
30604
diff
changeset
|
42 |
import compiler.whitebox.CompilerWhiteBoxTest; |
23188
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
43 |
|
15621 | 44 |
public class IsMethodCompilableTest extends CompilerWhiteBoxTest { |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
45 |
/** |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
46 |
* Value of {@code -XX:PerMethodRecompilationCutoff} |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
47 |
*/ |
15621 | 48 |
protected static final long PER_METHOD_RECOMPILATION_CUTOFF; |
49 |
||
50 |
static { |
|
51 |
long tmp = Long.parseLong( |
|
52 |
getVMOption("PerMethodRecompilationCutoff", "400")); |
|
53 |
if (tmp == -1) { |
|
54 |
PER_METHOD_RECOMPILATION_CUTOFF = -1 /* Inf */; |
|
55 |
} else { |
|
23188
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
56 |
PER_METHOD_RECOMPILATION_CUTOFF = (0xFFFFFFFFL & tmp); |
15621 | 57 |
} |
58 |
} |
|
59 |
||
60 |
public static void main(String[] args) throws Exception { |
|
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
20294
diff
changeset
|
61 |
CompilerWhiteBoxTest.main(IsMethodCompilableTest::new, args); |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
62 |
} |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
63 |
|
22214
c551021e75b2
8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul
iignatyev
parents:
20294
diff
changeset
|
64 |
private IsMethodCompilableTest(TestCase testCase) { |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
65 |
super(testCase); |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
66 |
// to prevent inlining of #method |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
67 |
WHITE_BOX.testSetDontInlineMethod(method, true); |
15621 | 68 |
} |
69 |
||
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
70 |
/** |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
71 |
* Tests {@code WB::isMethodCompilable()} by recompilation of tested method |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
72 |
* 'PerMethodRecompilationCutoff' times and checks compilation status. Also |
23188
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
73 |
* checks that WB::clearMethodState() clears no-compilable flags. Only |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
74 |
* applicable to c2 compiled methods. |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
75 |
* |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
76 |
* @throws Exception if one of the checks fails. |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
77 |
*/ |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
78 |
@Override |
15621 | 79 |
protected void test() throws Exception { |
23188
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
80 |
|
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
81 |
// Only c2 compilations can be disabled through PerMethodRecompilationCutoff |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
82 |
if (!Platform.isServer()) { |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
83 |
return; |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
84 |
} |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
85 |
|
23207
fc39038d37dc
8027124: [TESTBUG] NonTieredLevelsTest: java.lang.RuntimeException: private TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
23188
diff
changeset
|
86 |
if (skipXcompOSR()) { |
23188
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
87 |
return; |
20294
af95d17f2e04
8023452: TestCase$Helper(java.lang.Object) must be osr_compiled
iignatyev
parents:
19332
diff
changeset
|
88 |
} |
23188
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
89 |
if (!isCompilable(COMP_LEVEL_FULL_OPTIMIZATION)) { |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
90 |
throw new RuntimeException(method + " must be compilable"); |
15621 | 91 |
} |
92 |
System.out.println("PerMethodRecompilationCutoff = " |
|
93 |
+ PER_METHOD_RECOMPILATION_CUTOFF); |
|
94 |
if (PER_METHOD_RECOMPILATION_CUTOFF == -1) { |
|
95 |
System.err.println( |
|
96 |
"Warning: test is not applicable if PerMethodRecompilationCutoff == Inf"); |
|
97 |
return; |
|
98 |
} |
|
16689
efce070b8d42
8007288: Additional WB API for compiler's testing
iignatyev
parents:
16367
diff
changeset
|
99 |
|
23188
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
100 |
// deoptimize 'PerMethodRecompilationCutoff' times |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
101 |
for (long attempts = 0, successes = 0; |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
102 |
(successes < PER_METHOD_RECOMPILATION_CUTOFF) && |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
103 |
(attempts < PER_METHOD_RECOMPILATION_CUTOFF*2) && |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
104 |
isCompilable(COMP_LEVEL_FULL_OPTIMIZATION); attempts++) { |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
105 |
if (compileAndDeoptimize() == COMP_LEVEL_FULL_OPTIMIZATION) { |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
106 |
successes++; |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
107 |
} |
16689
efce070b8d42
8007288: Additional WB API for compiler's testing
iignatyev
parents:
16367
diff
changeset
|
108 |
} |
23188
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
109 |
|
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
110 |
if (!testCase.isOsr() && !isCompilable(COMP_LEVEL_FULL_OPTIMIZATION)) { |
19332 | 111 |
// in osr test case count of deopt maybe more than iterations |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
112 |
throw new RuntimeException(method + " is not compilable after " |
23188
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
113 |
+ PER_METHOD_RECOMPILATION_CUTOFF + " iterations"); |
16689
efce070b8d42
8007288: Additional WB API for compiler's testing
iignatyev
parents:
16367
diff
changeset
|
114 |
} |
15621 | 115 |
|
23188
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
116 |
// Now compile once more |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
117 |
compileAndDeoptimize(); |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
118 |
|
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
119 |
if (isCompilable(COMP_LEVEL_FULL_OPTIMIZATION)) { |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
120 |
throw new RuntimeException(method + " is still compilable after " |
15621 | 121 |
+ PER_METHOD_RECOMPILATION_CUTOFF + " iterations"); |
122 |
} |
|
23188
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
123 |
checkNotCompiled(); |
15621 | 124 |
compile(); |
23188
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
125 |
waitBackgroundCompilation(); |
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
126 |
checkNotCompiled(COMP_LEVEL_FULL_OPTIMIZATION); |
16689
efce070b8d42
8007288: Additional WB API for compiler's testing
iignatyev
parents:
16367
diff
changeset
|
127 |
|
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
128 |
// WB.clearMethodState() must reset no-compilable flags |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
129 |
WHITE_BOX.clearMethodState(method); |
23188
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
130 |
if (!isCompilable(COMP_LEVEL_FULL_OPTIMIZATION)) { |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
131 |
throw new RuntimeException(method |
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
132 |
+ " is not compilable after clearMethodState()"); |
15621 | 133 |
} |
16689
efce070b8d42
8007288: Additional WB API for compiler's testing
iignatyev
parents:
16367
diff
changeset
|
134 |
compile(); |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
135 |
checkCompiled(); |
16689
efce070b8d42
8007288: Additional WB API for compiler's testing
iignatyev
parents:
16367
diff
changeset
|
136 |
} |
efce070b8d42
8007288: Additional WB API for compiler's testing
iignatyev
parents:
16367
diff
changeset
|
137 |
|
23188
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
138 |
private int compileAndDeoptimize() throws Exception { |
16689
efce070b8d42
8007288: Additional WB API for compiler's testing
iignatyev
parents:
16367
diff
changeset
|
139 |
compile(); |
17015
92390f57e8b1
8011971: WB API doesn't accept j.l.reflect.Constructor
iignatyev
parents:
16689
diff
changeset
|
140 |
waitBackgroundCompilation(); |
23188
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
141 |
int compLevel = getCompLevel(); |
19332 | 142 |
deoptimize(); |
23188
21757c31b2c9
8007270: Make IsMethodCompilable test work with tiered
neliasso
parents:
22214
diff
changeset
|
143 |
return compLevel; |
15621 | 144 |
} |
145 |
} |