author | neliasso |
Fri, 29 Nov 2019 11:26:25 +0100 | |
changeset 59324 | 5e8f9713e343 |
parent 59064 | f1a5d48d0471 |
permissions | -rw-r--r-- |
54736
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
1 |
/* |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
4 |
* |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
8 |
* |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
13 |
* accompanied this code). |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
14 |
* |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
18 |
* |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
21 |
* questions. |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
22 |
*/ |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
23 |
|
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
24 |
/** |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
25 |
* @test Level2RecompilationTest |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
26 |
* @summary Test downgrading mechanism from level 3 to level 2 for those profiled methods. |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
27 |
* @library /test/lib / |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
28 |
* @modules java.base/jdk.internal.misc |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
29 |
* java.management |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
30 |
* |
59064
f1a5d48d0471
8226795: compiler/tiered/Level2RecompilationTest.java fails when XX:TieredStopAtLevel=1/2/3 is set
iignatyev
parents:
54736
diff
changeset
|
31 |
* @comment the test can't be run w/ TieredStopAtLevel < 4 |
f1a5d48d0471
8226795: compiler/tiered/Level2RecompilationTest.java fails when XX:TieredStopAtLevel=1/2/3 is set
iignatyev
parents:
54736
diff
changeset
|
32 |
* @requires vm.flavor == "server" & (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel == 4) |
f1a5d48d0471
8226795: compiler/tiered/Level2RecompilationTest.java fails when XX:TieredStopAtLevel=1/2/3 is set
iignatyev
parents:
54736
diff
changeset
|
33 |
* |
54736
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
34 |
* @build sun.hotspot.WhiteBox |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
35 |
* @run driver ClassFileInstaller sun.hotspot.WhiteBox |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
36 |
* sun.hotspot.WhiteBox$WhiteBoxPermission |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
37 |
* @run main/othervm -Xbootclasspath/a:. -XX:+TieredCompilation |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
38 |
* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-UseCounterDecay |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
39 |
* -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCaseHelper::* |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
40 |
* -XX:CompileCommand=print,compiler.whitebox.SimpleTestCaseHelper::* |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
41 |
* compiler.tiered.Level2RecompilationTest |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
42 |
*/ |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
43 |
|
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
44 |
package compiler.tiered; |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
45 |
|
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
46 |
import compiler.whitebox.CompilerWhiteBoxTest; |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
47 |
import jtreg.SkippedException; |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
48 |
|
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
49 |
public class Level2RecompilationTest extends CompLevelsTest { |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
50 |
public static void main(String[] args) throws Throwable { |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
51 |
if (CompilerWhiteBoxTest.skipOnTieredCompilation(false)) { |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
52 |
throw new SkippedException("Test isn't applicable for non-tiered mode"); |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
53 |
} |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
54 |
String[] testcases = {"METHOD_TEST", "OSR_STATIC_TEST"}; |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
55 |
CompilerWhiteBoxTest.main(Level2RecompilationTest::new, testcases); |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
56 |
} |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
57 |
|
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
58 |
protected Level2RecompilationTest(TestCase testCase) { |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
59 |
super(testCase); |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
60 |
// to prevent inlining of #method |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
61 |
WHITE_BOX.testSetDontInlineMethod(method, true); |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
62 |
} |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
63 |
|
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
64 |
@Override |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
65 |
protected void test() throws Exception { |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
66 |
if (skipXcompOSR()) { |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
67 |
return; |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
68 |
} |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
69 |
|
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
70 |
checkNotCompiled(); |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
71 |
int bci = WHITE_BOX.getMethodEntryBci(method); |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
72 |
WHITE_BOX.markMethodProfiled(method); |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
73 |
if (testCase.isOsr()) { |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
74 |
// for OSR compilation, it must be the begin of a BB. |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
75 |
// c1_GraphBulider.cpp:153 assert(method()->bci_block_start().at(cur_bci), ... |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
76 |
bci = 0; |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
77 |
} |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
78 |
|
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
79 |
WHITE_BOX.enqueueMethodForCompilation(method, COMP_LEVEL_FULL_PROFILE, bci); |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
80 |
checkCompiled(); |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
81 |
checkLevel(COMP_LEVEL_LIMITED_PROFILE, getCompLevel()); |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
82 |
|
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
83 |
for (int i=0; i<1_000; ++i) { |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
84 |
WHITE_BOX.enqueueMethodForCompilation(method, COMP_LEVEL_FULL_PROFILE, bci); |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
85 |
waitBackgroundCompilation(); |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
86 |
checkLevel(COMP_LEVEL_LIMITED_PROFILE, getCompLevel()); |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
87 |
} |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
88 |
} |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
89 |
|
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
90 |
@Override |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
91 |
protected void checkLevel(int expected, int actual) { |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
92 |
if (expected == COMP_LEVEL_FULL_PROFILE |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
93 |
&& actual == COMP_LEVEL_LIMITED_PROFILE) { |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
94 |
// for simple method full_profile may be replaced by limited_profile |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
95 |
if (IS_VERBOSE) { |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
96 |
System.out.printf("Level check: full profiling was replaced " |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
97 |
+ "by limited profiling. Expected: %d, actual:%d\n", |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
98 |
expected, actual); |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
99 |
} |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
100 |
return; |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
101 |
} |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
102 |
super.checkLevel(expected, actual); |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
103 |
} |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
104 |
} |
1dc9bf9d016b
8222670: pathological case of JIT recompilation and code cache bloat
xliu
parents:
diff
changeset
|
105 |