Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/jvmci/compilerToVM/ReprofileTest.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 & (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel == 4)
28
* @library /test/lib /
29
* @library ../common/patches
30
* @modules java.base/jdk.internal.misc
31
* @modules 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
*
37
* @build jdk.internal.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper sun.hotspot.WhiteBox
38
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
39
* @run main/othervm -Xbootclasspath/a:.
40
* -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
41
* -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
42
* -Xmixed -Xbatch
43
* compiler.jvmci.compilerToVM.ReprofileTest
44
*/
45
46
package compiler.jvmci.compilerToVM;
47
48
import compiler.jvmci.common.CTVMUtilities;
49
import compiler.whitebox.CompilerWhiteBoxTest;
50
import jdk.test.lib.Asserts;
51
import jdk.vm.ci.hotspot.CompilerToVMHelper;
52
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
53
import jdk.vm.ci.meta.ProfilingInfo;
54
55
import java.lang.reflect.Method;
56
import java.util.ArrayList;
57
import java.util.List;
58
59
public class ReprofileTest {
60
61
public static void main(String[] args) {
62
List<Method> testCases = createTestCases();
63
testCases.forEach(ReprofileTest::runSanityTest);
64
}
65
66
private static List<Method> createTestCases() {
67
List<Method> testCases = new ArrayList<>();
68
try {
69
70
Class<?> aClass = DummyClass.class;
71
testCases.add(aClass.getMethod("dummyInstanceFunction"));
72
73
aClass = DummyClass.class;
74
testCases.add(aClass.getMethod("dummyFunction"));
75
} catch (NoSuchMethodException e) {
76
throw new Error("TEST BUG " + e.getMessage(), e);
77
}
78
return testCases;
79
}
80
81
private static void runSanityTest(Method aMethod) {
82
System.out.println(aMethod);
83
HotSpotResolvedJavaMethod method = CTVMUtilities
84
.getResolvedMethod(aMethod);
85
ProfilingInfo startProfile = method.getProfilingInfo();
86
Asserts.assertFalse(startProfile.isMature(), aMethod
87
+ " : profiling info is mature in the beginning");
88
89
// make interpreter to profile this method
90
try {
91
Object obj = aMethod.getDeclaringClass().newInstance();
92
for (long i = 0; i < CompilerWhiteBoxTest.THRESHOLD; i++) {
93
aMethod.invoke(obj);
94
}
95
} catch (ReflectiveOperationException e) {
96
throw new Error("TEST BUG : " + e.getMessage(), e);
97
}
98
ProfilingInfo compProfile = method.getProfilingInfo();
99
100
Asserts.assertNE(startProfile.toString(), compProfile.toString(),
101
String.format("%s : profiling info wasn't changed after "
102
+ "%d invocations",
103
aMethod, CompilerWhiteBoxTest.THRESHOLD));
104
Asserts.assertTrue(compProfile.isMature(),
105
String.format("%s is not mature after %d invocations",
106
aMethod, CompilerWhiteBoxTest.THRESHOLD));
107
108
CompilerToVMHelper.reprofile(method);
109
ProfilingInfo reprofiledProfile = method.getProfilingInfo();
110
111
Asserts.assertNE(startProfile.toString(), reprofiledProfile.toString(),
112
aMethod + " : profiling info wasn't changed after reprofiling");
113
Asserts.assertNE(compProfile.toString(), reprofiledProfile.toString(),
114
aMethod + " : profiling info didn't change after reprofile");
115
Asserts.assertFalse(reprofiledProfile.isMature(), aMethod
116
+ " : profiling info is mature after reprofiling");
117
}
118
}
119
120