Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/jvmci/errors/CodeInstallerTest.java
41152 views
1
/*
2
* Copyright (c) 2015, 2019, 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
package compiler.jvmci.errors;
25
26
import jdk.vm.ci.code.Architecture;
27
import jdk.vm.ci.code.CodeCacheProvider;
28
import jdk.vm.ci.code.Register;
29
import jdk.vm.ci.code.RegisterArray;
30
import jdk.vm.ci.code.StackSlot;
31
import jdk.vm.ci.code.site.DataPatch;
32
import jdk.vm.ci.code.site.Site;
33
import jdk.vm.ci.hotspot.HotSpotCompiledCode;
34
import jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment;
35
import jdk.vm.ci.hotspot.HotSpotCompiledNmethod;
36
import jdk.vm.ci.hotspot.HotSpotConstantReflectionProvider;
37
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod;
38
import jdk.vm.ci.meta.Assumptions.Assumption;
39
import jdk.vm.ci.meta.MetaAccessProvider;
40
import jdk.vm.ci.meta.PlatformKind;
41
import jdk.vm.ci.meta.ResolvedJavaMethod;
42
import jdk.vm.ci.runtime.JVMCI;
43
import jdk.vm.ci.runtime.JVMCIBackend;
44
import org.junit.Assert;
45
46
import java.lang.reflect.Method;
47
48
public class CodeInstallerTest {
49
50
protected final Architecture arch;
51
protected final CodeCacheProvider codeCache;
52
protected final MetaAccessProvider metaAccess;
53
protected final HotSpotConstantReflectionProvider constantReflection;
54
55
protected final HotSpotResolvedJavaMethod dummyMethod;
56
57
public static void dummyMethod() {
58
}
59
60
protected CodeInstallerTest() {
61
JVMCIBackend backend = JVMCI.getRuntime().getHostJVMCIBackend();
62
metaAccess = backend.getMetaAccess();
63
codeCache = backend.getCodeCache();
64
constantReflection = (HotSpotConstantReflectionProvider) backend.getConstantReflection();
65
arch = codeCache.getTarget().arch;
66
67
Method method = null;
68
try {
69
method = CodeInstallerTest.class.getMethod("dummyMethod");
70
} catch (NoSuchMethodException e) {
71
Assert.fail();
72
}
73
74
dummyMethod = (HotSpotResolvedJavaMethod) metaAccess.lookupJavaMethod(method);
75
}
76
77
protected void installEmptyCode(Site[] sites, Assumption[] assumptions, Comment[] comments, int dataSectionAlignment, DataPatch[] dataSectionPatches, StackSlot deoptRescueSlot) {
78
HotSpotCompiledCode code = new HotSpotCompiledNmethod("dummyMethod", new byte[0], 0, sites, assumptions, new ResolvedJavaMethod[]{dummyMethod}, comments, new byte[8], dataSectionAlignment,
79
dataSectionPatches, false, 0, deoptRescueSlot,
80
dummyMethod, 0, 1, 0L, false);
81
codeCache.addCode(dummyMethod, code, null, null);
82
}
83
84
protected Register getRegister(PlatformKind kind, int index) {
85
int idx = index;
86
RegisterArray allRegs = arch.getAvailableValueRegisters();
87
for (Register reg : allRegs) {
88
if (arch.canStoreValue(reg.getRegisterCategory(), kind)) {
89
if (idx-- == 0) {
90
return reg;
91
}
92
}
93
}
94
return null;
95
}
96
}
97
98