Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/compiler/jvmci/errors/TestInvalidCompilationResult.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
/**
25
* @test
26
* @requires vm.jvmci
27
* @modules jdk.internal.vm.ci/jdk.vm.ci.hotspot
28
* jdk.internal.vm.ci/jdk.vm.ci.code
29
* jdk.internal.vm.ci/jdk.vm.ci.code.site
30
* jdk.internal.vm.ci/jdk.vm.ci.meta
31
* jdk.internal.vm.ci/jdk.vm.ci.runtime
32
* jdk.internal.vm.ci/jdk.vm.ci.common
33
* @compile CodeInstallerTest.java
34
* @run junit/othervm -da:jdk.vm.ci... -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI
35
* -XX:-UseJVMCICompiler compiler.jvmci.errors.TestInvalidCompilationResult
36
*/
37
38
package compiler.jvmci.errors;
39
40
import jdk.vm.ci.code.StackSlot;
41
import jdk.vm.ci.code.site.ConstantReference;
42
import jdk.vm.ci.code.site.DataPatch;
43
import jdk.vm.ci.code.site.DataSectionReference;
44
import jdk.vm.ci.code.site.Infopoint;
45
import jdk.vm.ci.code.site.InfopointReason;
46
import jdk.vm.ci.code.site.Mark;
47
import jdk.vm.ci.code.site.Reference;
48
import jdk.vm.ci.code.site.Site;
49
import jdk.vm.ci.common.JVMCIError;
50
import jdk.vm.ci.hotspot.HotSpotCompiledCode.Comment;
51
import jdk.vm.ci.hotspot.HotSpotConstant;
52
import jdk.vm.ci.meta.Assumptions.Assumption;
53
import jdk.vm.ci.meta.VMConstant;
54
import org.junit.Test;
55
56
/**
57
* Tests for errors in the code installer.
58
*/
59
public class TestInvalidCompilationResult extends CodeInstallerTest {
60
61
private static class InvalidAssumption extends Assumption {
62
}
63
64
private static class InvalidVMConstant implements VMConstant {
65
66
public boolean isDefaultForKind() {
67
return false;
68
}
69
70
public String toValueString() {
71
return null;
72
}
73
}
74
75
private static class InvalidReference extends Reference {
76
77
@Override
78
public int hashCode() {
79
return 0;
80
}
81
82
@Override
83
public boolean equals(Object obj) {
84
return false;
85
}
86
}
87
88
@Test(expected = JVMCIError.class)
89
public void testInvalidAssumption() {
90
installEmptyCode(new Site[0], new Assumption[]{new InvalidAssumption()}, new Comment[0], 16, new DataPatch[0], null);
91
}
92
93
@Test(expected = JVMCIError.class)
94
public void testInvalidAlignment() {
95
installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 7, new DataPatch[0], null);
96
}
97
98
@Test(expected = NullPointerException.class)
99
public void testNullDataPatchInDataSection() {
100
installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 16, new DataPatch[]{null}, null);
101
}
102
103
@Test(expected = NullPointerException.class)
104
public void testNullReferenceInDataSection() {
105
installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 16, new DataPatch[]{new DataPatch(0, null)}, null);
106
}
107
108
@Test(expected = JVMCIError.class)
109
public void testInvalidDataSectionReference() {
110
DataSectionReference ref = new DataSectionReference();
111
ref.setOffset(0);
112
installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 16, new DataPatch[]{new DataPatch(0, ref)}, null);
113
}
114
115
@Test(expected = JVMCIError.class)
116
public void testInvalidNarrowMethodInDataSection() {
117
HotSpotConstant c = (HotSpotConstant) dummyMethod.getEncoding();
118
ConstantReference ref = new ConstantReference((VMConstant) c.compress());
119
installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 16, new DataPatch[]{new DataPatch(0, ref)}, null);
120
}
121
122
@Test(expected = NullPointerException.class)
123
public void testNullConstantInDataSection() {
124
ConstantReference ref = new ConstantReference(null);
125
installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 16, new DataPatch[]{new DataPatch(0, ref)}, null);
126
}
127
128
@Test(expected = JVMCIError.class)
129
public void testInvalidConstantInDataSection() {
130
ConstantReference ref = new ConstantReference(new InvalidVMConstant());
131
installEmptyCode(new Site[0], new Assumption[0], new Comment[0], 16, new DataPatch[]{new DataPatch(0, ref)}, null);
132
}
133
134
@Test(expected = NullPointerException.class)
135
public void testNullReferenceInCode() {
136
installEmptyCode(new Site[]{new DataPatch(0, null)}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null);
137
}
138
139
@Test(expected = NullPointerException.class)
140
public void testNullConstantInCode() {
141
ConstantReference ref = new ConstantReference(null);
142
installEmptyCode(new Site[]{new DataPatch(0, ref)}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null);
143
}
144
145
@Test(expected = JVMCIError.class)
146
public void testInvalidConstantInCode() {
147
ConstantReference ref = new ConstantReference(new InvalidVMConstant());
148
installEmptyCode(new Site[]{new DataPatch(0, ref)}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null);
149
}
150
151
@Test(expected = JVMCIError.class)
152
public void testInvalidReference() {
153
InvalidReference ref = new InvalidReference();
154
installEmptyCode(new Site[]{new DataPatch(0, ref)}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null);
155
}
156
157
@Test(expected = JVMCIError.class)
158
public void testOutOfBoundsDataSectionReference() {
159
DataSectionReference ref = new DataSectionReference();
160
ref.setOffset(0x1000);
161
installEmptyCode(new Site[]{new DataPatch(0, ref)}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null);
162
}
163
164
@Test(expected = JVMCIError.class)
165
public void testInvalidMark() {
166
installEmptyCode(new Site[]{new Mark(0, new Object())}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null);
167
}
168
169
@Test(expected = JVMCIError.class)
170
public void testInvalidMarkInt() {
171
installEmptyCode(new Site[]{new Mark(0, -1)}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null);
172
}
173
174
@Test(expected = NullPointerException.class)
175
public void testNullSite() {
176
installEmptyCode(new Site[]{null}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null);
177
}
178
179
@Test(expected = JVMCIError.class)
180
public void testInfopointMissingDebugInfo() {
181
Infopoint info = new Infopoint(0, null, InfopointReason.METHOD_START);
182
installEmptyCode(new Site[]{info}, new Assumption[0], new Comment[0], 16, new DataPatch[0], null);
183
}
184
185
@Test(expected = JVMCIError.class)
186
public void testSafepointMissingDebugInfo() {
187
Infopoint info = new Infopoint(0, null, InfopointReason.SAFEPOINT);
188
StackSlot deoptRescueSlot = StackSlot.get(null, 0, true);
189
installEmptyCode(new Site[]{info}, new Assumption[0], new Comment[0], 16, new DataPatch[0], deoptRescueSlot);
190
}
191
192
@Test(expected = JVMCIError.class)
193
public void testInvalidDeoptRescueSlot() {
194
StackSlot deoptRescueSlot = StackSlot.get(null, -1, false);
195
installEmptyCode(new Site[]{}, new Assumption[0], new Comment[0], 16, new DataPatch[0], deoptRescueSlot);
196
}
197
}
198
199