Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/jvmci/compilerToVM/IsMatureTest.java
41153 views
1
/*
2
* Copyright (c) 2015, 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
28
* @library / /test/lib
29
* ../common/patches
30
* @modules java.base/jdk.internal.misc
31
* jdk.internal.vm.ci/jdk.vm.ci.hotspot
32
*
33
* @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper
34
* sun.hotspot.WhiteBox
35
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
36
* @run main/othervm -Xbootclasspath/a:.
37
* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
38
* -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
39
* compiler.jvmci.compilerToVM.IsMatureTest
40
*/
41
42
package compiler.jvmci.compilerToVM;
43
44
import compiler.jvmci.common.testcases.SimpleClass;
45
import compiler.whitebox.CompilerWhiteBoxTest;
46
import jdk.test.lib.Asserts;
47
import jdk.test.lib.Platform;
48
import jdk.vm.ci.hotspot.CompilerToVMHelper;
49
import sun.hotspot.WhiteBox;
50
51
import java.lang.reflect.Executable;
52
53
public class IsMatureTest {
54
private static final WhiteBox WB = WhiteBox.getWhiteBox();
55
private static final boolean TIERED
56
= WB.getBooleanVMFlag("TieredCompilation");
57
58
public static void main(String[] args) throws Exception {
59
new IsMatureTest().test();
60
}
61
62
public void test() throws Exception {
63
SimpleClass sclass = new SimpleClass();
64
Executable method = SimpleClass.class.getDeclaredMethod("testMethod");
65
long methodData = WB.getMethodData(method);
66
boolean isMature = CompilerToVMHelper.isMature(methodData);
67
Asserts.assertEQ(methodData, 0L,
68
"Never invoked method can't have method data");
69
Asserts.assertFalse(isMature, "Never invoked method can't be mature");
70
for (int i = 0; i < CompilerWhiteBoxTest.THRESHOLD; i++) {
71
sclass.testMethod();
72
}
73
methodData = WB.getMethodData(method);
74
isMature = CompilerToVMHelper.isMature(methodData);
75
int compLevel = WB.getMethodCompilationLevel(method);
76
// methodData doesn't necessarily exist for interpreter and compilation level 1
77
if (compLevel != CompilerWhiteBoxTest.COMP_LEVEL_NONE
78
&& compLevel != CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE) {
79
Asserts.assertNE(methodData, 0L,
80
"Multiple times invoked method should have method data");
81
/* a method is not mature in Xcomp mode with tiered compilation disabled,
82
see NonTieredCompPolicy::is_mature */
83
Asserts.assertEQ(isMature, !(Platform.isComp() && !TIERED),
84
"Unexpected isMature state for multiple times invoked method");
85
}
86
}
87
}
88
89