Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/jvmci/compilerToVM/IsMatureVsReprofileTest.java
41153 views
1
/*
2
* Copyright (c) 2017, 2021, 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
* @bug 8136421
27
* @requires vm.jvmci & (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel == 4)
28
* @library / /test/lib
29
* ../common/patches
30
* @modules java.base/jdk.internal.misc
31
* java.base/jdk.internal.org.objectweb.asm
32
* java.base/jdk.internal.org.objectweb.asm.tree
33
* jdk.internal.vm.ci/jdk.vm.ci.hotspot
34
* jdk.internal.vm.ci/jdk.vm.ci.code
35
* jdk.internal.vm.ci/jdk.vm.ci.meta
36
* jdk.internal.vm.ci/jdk.vm.ci.runtime
37
*
38
* @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
39
* sun.hotspot.WhiteBox
40
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
41
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
42
* -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -Xbatch -XX:CompileThresholdScaling=1.0
43
* compiler.jvmci.compilerToVM.IsMatureVsReprofileTest
44
*/
45
46
package compiler.jvmci.compilerToVM;
47
48
import compiler.jvmci.common.CTVMUtilities;
49
import compiler.jvmci.common.testcases.SimpleClass;
50
import jdk.vm.ci.hotspot.CompilerToVMHelper;
51
import jdk.test.lib.Asserts;
52
import sun.hotspot.WhiteBox;
53
import compiler.whitebox.CompilerWhiteBoxTest;
54
import java.lang.reflect.Executable;
55
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
56
import jdk.test.lib.Platform;
57
58
public class IsMatureVsReprofileTest {
59
private static final WhiteBox WB = WhiteBox.getWhiteBox();
60
private static final boolean TIERED = WB.getBooleanVMFlag("TieredCompilation");
61
private static final boolean IS_XCOMP = Platform.isComp();
62
63
public static void main(String[] args) throws Exception {
64
new IsMatureVsReprofileTest().test();
65
}
66
67
public void test() throws Exception {
68
SimpleClass sclass = new SimpleClass();
69
Executable method = SimpleClass.class.getDeclaredMethod("testMethod");
70
long metaspaceMethodData = WB.getMethodData(method);
71
Asserts.assertEQ(metaspaceMethodData, 0L, "MDO should be null for a "
72
+ "never invoked method");
73
boolean isMature = CompilerToVMHelper.isMature(metaspaceMethodData);
74
Asserts.assertFalse(isMature, "null MDO can't be mature");
75
for (int i = 0; i < CompilerWhiteBoxTest.THRESHOLD; i++) {
76
sclass.testMethod();
77
}
78
Asserts.assertTrue(WB.isMethodCompiled(method),
79
"Method should be compiled");
80
metaspaceMethodData = WB.getMethodData(method);
81
Asserts.assertNE(metaspaceMethodData, 0L,
82
"Multiple times invoked method should have MDO");
83
isMature = CompilerToVMHelper.isMature(metaspaceMethodData);
84
/* a method is not mature for -Xcomp and -Tiered,
85
see NonTieredCompPolicy::is_mature */
86
Asserts.assertEQ(!IS_XCOMP || TIERED, isMature,
87
"Unexpected isMature state for compiled method");
88
HotSpotResolvedJavaMethod resolvedMethod
89
= CTVMUtilities.getResolvedMethod(method);
90
CompilerToVMHelper.reprofile(resolvedMethod);
91
Asserts.assertFalse(WB.isMethodCompiled(method),
92
"Unexpected method compilation state after reprofile");
93
metaspaceMethodData = WB.getMethodData(method);
94
isMature = CompilerToVMHelper.isMature(metaspaceMethodData);
95
Asserts.assertNE(metaspaceMethodData, 0L,
96
"Got null MDO after reprofile");
97
Asserts.assertEQ(TIERED && IS_XCOMP, isMature,
98
"Got unexpected isMature state after reprofiling");
99
}
100
}
101
102