42650
|
1 |
/*
|
|
2 |
* Copyright (c) 2016, 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
|
|
26 |
* @library /test/lib /testlibrary /
|
|
27 |
* @requires vm.bits == "64" & os.arch == "amd64" & os.family == "linux"
|
|
28 |
* @modules java.base/jdk.internal.misc
|
|
29 |
* @build compiler.aot.RecompilationTest
|
|
30 |
* compiler.aot.AotCompiler
|
|
31 |
* @run main ClassFileInstaller sun.hotspot.WhiteBox
|
|
32 |
* sun.hotspot.WhiteBox$WhiteBoxPermission
|
|
33 |
* @run main compiler.aot.AotCompiler -libname libRecompilationTest.so
|
|
34 |
* -class compiler.whitebox.SimpleTestCaseHelper
|
|
35 |
* -extraopt -Dgraal.TieredAOT=true -extraopt -Dgraal.ProfileSimpleMethods=true
|
|
36 |
* -extraopt -XX:+UnlockDiagnosticVMOptions -extraopt -XX:+WhiteBoxAPI -extraopt -Xbootclasspath/a:.
|
|
37 |
* @run main/othervm -Xmixed -Xbatch -XX:+UseAOT -XX:+TieredCompilation -XX:-UseCounterDecay
|
|
38 |
* -XX:CompileCommand=dontinline,*.*
|
|
39 |
* -XX:AOTLibrary=./libRecompilationTest.so -Xbootclasspath/a:.
|
|
40 |
* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
|
|
41 |
* -Dcompiler.aot.RecompilationTest.check_level=1
|
|
42 |
* compiler.aot.RecompilationTest
|
|
43 |
* @run main compiler.aot.AotCompiler -libname libRecompilationTest.so
|
|
44 |
* -class compiler.whitebox.SimpleTestCaseHelper
|
|
45 |
* -extraopt -Dgraal.TieredAOT=false
|
|
46 |
* -extraopt -XX:+UnlockDiagnosticVMOptions -extraopt -XX:+WhiteBoxAPI -extraopt -Xbootclasspath/a:.
|
|
47 |
* @run main/othervm -Xmixed -Xbatch -XX:+UseAOT -XX:+TieredCompilation -XX:-UseCounterDecay
|
|
48 |
* -XX:CompileCommand=dontinline,*.*
|
|
49 |
* -XX:AOTLibrary=./libRecompilationTest.so -Xbootclasspath/a:.
|
|
50 |
* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
|
|
51 |
* -Dcompiler.aot.RecompilationTest.check_level=-1
|
|
52 |
* compiler.aot.RecompilationTest
|
|
53 |
* @run main/othervm -Xmixed -Xbatch -XX:+UseAOT -XX:-TieredCompilation -XX:-UseCounterDecay
|
|
54 |
* -XX:CompileCommand=dontinline,*.*
|
|
55 |
* -XX:AOTLibrary=./libRecompilationTest.so -Xbootclasspath/a:.
|
|
56 |
* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
|
|
57 |
* -Dcompiler.aot.RecompilationTest.check_level=-1
|
|
58 |
* compiler.aot.RecompilationTest
|
|
59 |
* @summary check if recompilation after aot goes fine
|
|
60 |
*/
|
|
61 |
|
|
62 |
/* having whitebox-related options for aot compiler is a temporary solution,
|
|
63 |
because of JDK-8146201
|
|
64 |
*/
|
|
65 |
|
|
66 |
package compiler.aot;
|
|
67 |
|
|
68 |
import compiler.whitebox.CompilerWhiteBoxTest;
|
|
69 |
import java.lang.reflect.Executable;
|
|
70 |
import jdk.test.lib.Asserts;
|
|
71 |
|
|
72 |
public final class RecompilationTest extends CompilerWhiteBoxTest {
|
|
73 |
private static final int CHECK_LEVEL = Integer.getInteger(
|
|
74 |
"compiler.aot.RecompilationTest.check_level");
|
|
75 |
|
|
76 |
public static void main(String args[]) {
|
|
77 |
CompilerWhiteBoxTest.main(RecompilationTest::new, args);
|
|
78 |
}
|
|
79 |
|
|
80 |
private RecompilationTest(TestCase testCase) {
|
|
81 |
super(testCase);
|
|
82 |
}
|
|
83 |
|
|
84 |
@Override
|
|
85 |
protected void test() throws Exception {
|
|
86 |
if (testCase.isOsr()) {
|
|
87 |
/* aot compiler is not using osr compilation */
|
|
88 |
System.out.println("Skipping OSR case");
|
|
89 |
return;
|
|
90 |
}
|
|
91 |
Executable e = testCase.getExecutable();
|
|
92 |
Asserts.assertTrue(WHITE_BOX.isMethodCompiled(e),
|
|
93 |
testCase.name() + ": an executable expected to be compiled");
|
|
94 |
Asserts.assertEQ(WHITE_BOX.getMethodCompilationLevel(e),
|
|
95 |
COMP_LEVEL_AOT,
|
|
96 |
String.format("%s: unexpected compilation level at start",
|
|
97 |
testCase.name()));
|
|
98 |
compile();
|
|
99 |
Asserts.assertTrue(WHITE_BOX.isMethodCompiled(e), testCase.name()
|
|
100 |
+ ": method expected to be compiled");
|
|
101 |
/* a case with AOT'ed code checks exact compilation level equality
|
|
102 |
while another case checks minimum level and if method compiled
|
|
103 |
because there might be different compilation level transitions */
|
|
104 |
if (CHECK_LEVEL != COMP_LEVEL_AOT) {
|
|
105 |
Asserts.assertGTE(WHITE_BOX.getMethodCompilationLevel(e),
|
|
106 |
CHECK_LEVEL,
|
|
107 |
String.format("%s: expected compilation level"
|
|
108 |
+ " after compilation to be no less than %d for %s",
|
|
109 |
testCase.name(), CHECK_LEVEL, testCase.name()));
|
|
110 |
} else {
|
|
111 |
Asserts.assertEQ(WHITE_BOX.getMethodCompilationLevel(e),
|
|
112 |
COMP_LEVEL_AOT, String.format("%s: expected compilation"
|
|
113 |
+ " level after compilation to be equal to %d for %s",
|
|
114 |
testCase.name(), COMP_LEVEL_AOT, testCase.name()));
|
|
115 |
}
|
|
116 |
}
|
|
117 |
}
|