author | dnsimon |
Mon, 06 Nov 2017 12:17:59 +0100 | |
changeset 47793 | 3dcd54513db1 |
parent 47668 | fc4cfca10556 |
child 49358 | 0dc249f5c260 |
permissions | -rw-r--r-- |
43972 | 1 |
/* |
47668 | 2 |
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
43972 | 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 jdk.vm.ci.hotspot; |
|
25 |
||
26 |
import jdk.vm.ci.code.InstalledCode; |
|
27 |
import jdk.vm.ci.code.InvalidInstalledCodeException; |
|
28 |
import jdk.vm.ci.code.TargetDescription; |
|
29 |
import jdk.vm.ci.meta.ConstantPool; |
|
30 |
import jdk.vm.ci.meta.ResolvedJavaMethod; |
|
31 |
import java.lang.reflect.Executable; |
|
32 |
||
33 |
/** |
|
34 |
* A simple "proxy" class to get test access to CompilerToVM package-private methods |
|
35 |
*/ |
|
36 |
public class CompilerToVMHelper { |
|
37 |
public static final CompilerToVM CTVM = new CompilerToVM(); |
|
38 |
||
39 |
public static byte[] getBytecode(HotSpotResolvedJavaMethod method) { |
|
40 |
return CTVM.getBytecode((HotSpotResolvedJavaMethodImpl)method); |
|
41 |
} |
|
42 |
||
43 |
public static int getExceptionTableLength(HotSpotResolvedJavaMethod method) { |
|
44 |
return CTVM.getExceptionTableLength((HotSpotResolvedJavaMethodImpl)method); |
|
45 |
} |
|
46 |
||
47 |
public static long getExceptionTableStart(HotSpotResolvedJavaMethod method) { |
|
48 |
return CTVM.getExceptionTableStart((HotSpotResolvedJavaMethodImpl)method); |
|
49 |
} |
|
50 |
||
51 |
public static Object getFlagValue(String name) { |
|
52 |
return CTVM.getFlagValue(name); |
|
53 |
} |
|
54 |
||
55 |
public static boolean isCompilable(HotSpotResolvedJavaMethod method) { |
|
56 |
return CTVM.isCompilable((HotSpotResolvedJavaMethodImpl)method); |
|
57 |
} |
|
58 |
||
59 |
public static boolean hasNeverInlineDirective(HotSpotResolvedJavaMethod method) { |
|
60 |
return CTVM.hasNeverInlineDirective((HotSpotResolvedJavaMethodImpl)method); |
|
61 |
} |
|
62 |
||
63 |
public static boolean shouldInlineMethod(HotSpotResolvedJavaMethod method) { |
|
64 |
return CTVM.shouldInlineMethod((HotSpotResolvedJavaMethodImpl)method); |
|
65 |
} |
|
66 |
||
67 |
public static HotSpotResolvedJavaMethod findUniqueConcreteMethod( |
|
68 |
HotSpotResolvedObjectType actualHolderType, |
|
69 |
HotSpotResolvedJavaMethod method) { |
|
70 |
return CTVM.findUniqueConcreteMethod((HotSpotResolvedObjectTypeImpl) actualHolderType, (HotSpotResolvedJavaMethodImpl)method); |
|
71 |
} |
|
72 |
||
73 |
public static HotSpotResolvedObjectType getImplementor(HotSpotResolvedObjectType type) { |
|
74 |
return CTVM.getImplementor((HotSpotResolvedObjectTypeImpl) type); |
|
75 |
} |
|
76 |
||
77 |
public static boolean methodIsIgnoredBySecurityStackWalk(HotSpotResolvedJavaMethod method) { |
|
78 |
return CTVM.methodIsIgnoredBySecurityStackWalk((HotSpotResolvedJavaMethodImpl)method); |
|
79 |
} |
|
80 |
||
81 |
public static HotSpotResolvedObjectType lookupType(String name, |
|
46972
3e88de95fccf
8186459: [JVMCI] ClassNotFoundException thrown by CompilerToVM.lookupType() should be converted to a LinkageError
dnsimon
parents:
46481
diff
changeset
|
82 |
Class<?> accessingClass, boolean resolve) throws ClassNotFoundException { |
3e88de95fccf
8186459: [JVMCI] ClassNotFoundException thrown by CompilerToVM.lookupType() should be converted to a LinkageError
dnsimon
parents:
46481
diff
changeset
|
83 |
return CTVM.lookupType(name, accessingClass, resolve); |
3e88de95fccf
8186459: [JVMCI] ClassNotFoundException thrown by CompilerToVM.lookupType() should be converted to a LinkageError
dnsimon
parents:
46481
diff
changeset
|
84 |
} |
3e88de95fccf
8186459: [JVMCI] ClassNotFoundException thrown by CompilerToVM.lookupType() should be converted to a LinkageError
dnsimon
parents:
46481
diff
changeset
|
85 |
|
3e88de95fccf
8186459: [JVMCI] ClassNotFoundException thrown by CompilerToVM.lookupType() should be converted to a LinkageError
dnsimon
parents:
46481
diff
changeset
|
86 |
public static HotSpotResolvedObjectType lookupTypeHelper(String name, |
43972 | 87 |
Class<?> accessingClass, boolean resolve) { |
46972
3e88de95fccf
8186459: [JVMCI] ClassNotFoundException thrown by CompilerToVM.lookupType() should be converted to a LinkageError
dnsimon
parents:
46481
diff
changeset
|
88 |
try { |
3e88de95fccf
8186459: [JVMCI] ClassNotFoundException thrown by CompilerToVM.lookupType() should be converted to a LinkageError
dnsimon
parents:
46481
diff
changeset
|
89 |
return lookupType(name, accessingClass, resolve); |
3e88de95fccf
8186459: [JVMCI] ClassNotFoundException thrown by CompilerToVM.lookupType() should be converted to a LinkageError
dnsimon
parents:
46481
diff
changeset
|
90 |
} catch (ClassNotFoundException e) { |
3e88de95fccf
8186459: [JVMCI] ClassNotFoundException thrown by CompilerToVM.lookupType() should be converted to a LinkageError
dnsimon
parents:
46481
diff
changeset
|
91 |
throw (NoClassDefFoundError) new NoClassDefFoundError().initCause(e); |
3e88de95fccf
8186459: [JVMCI] ClassNotFoundException thrown by CompilerToVM.lookupType() should be converted to a LinkageError
dnsimon
parents:
46481
diff
changeset
|
92 |
} |
43972 | 93 |
} |
94 |
||
95 |
public static Object resolveConstantInPool(ConstantPool constantPool, int cpi) { |
|
96 |
return CTVM.resolveConstantInPool((HotSpotConstantPool) constantPool, cpi); |
|
97 |
} |
|
98 |
||
99 |
public static Object resolvePossiblyCachedConstantInPool(ConstantPool constantPool, int cpi) { |
|
100 |
return CTVM.resolvePossiblyCachedConstantInPool((HotSpotConstantPool) constantPool, cpi); |
|
101 |
} |
|
102 |
||
103 |
public static int lookupNameAndTypeRefIndexInPool(ConstantPool constantPool, int cpi) { |
|
104 |
return CTVM.lookupNameAndTypeRefIndexInPool((HotSpotConstantPool) constantPool, cpi); |
|
105 |
} |
|
106 |
||
107 |
public static String lookupNameInPool(ConstantPool constantPool, int cpi) { |
|
108 |
return CTVM.lookupNameInPool((HotSpotConstantPool) constantPool, cpi); |
|
109 |
} |
|
110 |
||
111 |
public static String lookupSignatureInPool(ConstantPool constantPool, int cpi) { |
|
112 |
return CTVM.lookupSignatureInPool((HotSpotConstantPool) constantPool, cpi); |
|
113 |
} |
|
114 |
||
115 |
public static int lookupKlassRefIndexInPool(ConstantPool constantPool, int cpi) { |
|
116 |
return CTVM.lookupKlassRefIndexInPool((HotSpotConstantPool) constantPool, cpi); |
|
117 |
} |
|
118 |
||
119 |
public static Object lookupKlassInPool(ConstantPool constantPool, int cpi) { |
|
120 |
return CTVM.lookupKlassInPool((HotSpotConstantPool) constantPool, cpi); |
|
121 |
} |
|
122 |
||
123 |
public static HotSpotResolvedJavaMethod lookupMethodInPool( |
|
124 |
ConstantPool constantPool, int cpi, byte opcode) { |
|
125 |
return CTVM.lookupMethodInPool((HotSpotConstantPool) constantPool, cpi, opcode); |
|
126 |
} |
|
127 |
||
128 |
public static void resolveInvokeDynamicInPool( |
|
129 |
ConstantPool constantPool, int cpi) { |
|
130 |
CTVM.resolveInvokeDynamicInPool((HotSpotConstantPool) constantPool, cpi); |
|
131 |
} |
|
132 |
||
133 |
public static void resolveInvokeHandleInPool( |
|
134 |
ConstantPool constantPool, int cpi) { |
|
135 |
CTVM.resolveInvokeHandleInPool((HotSpotConstantPool) constantPool, cpi); |
|
136 |
} |
|
137 |
||
138 |
public static HotSpotResolvedObjectType resolveTypeInPool( |
|
139 |
ConstantPool constantPool, int cpi) { |
|
140 |
return CTVM.resolveTypeInPool((HotSpotConstantPool) constantPool, cpi); |
|
141 |
} |
|
142 |
||
143 |
public static HotSpotResolvedObjectType resolveFieldInPool( |
|
144 |
ConstantPool constantPool, int cpi, ResolvedJavaMethod method, byte opcode, int[] info) { |
|
145 |
return CTVM.resolveFieldInPool((HotSpotConstantPool) constantPool, cpi, (HotSpotResolvedJavaMethodImpl) method, opcode, info); |
|
146 |
} |
|
147 |
||
148 |
public static int constantPoolRemapInstructionOperandFromCache( |
|
149 |
ConstantPool constantPool, int cpci) { |
|
150 |
return CTVM.constantPoolRemapInstructionOperandFromCache((HotSpotConstantPool) constantPool, cpci); |
|
151 |
} |
|
152 |
||
153 |
public static Object lookupAppendixInPool( |
|
154 |
ConstantPool constantPool, int cpi) { |
|
155 |
return CTVM.lookupAppendixInPool((HotSpotConstantPool) constantPool, cpi); |
|
156 |
} |
|
157 |
||
158 |
public static int installCode(TargetDescription target, |
|
159 |
HotSpotCompiledCode compiledCode, InstalledCode code, HotSpotSpeculationLog speculationLog) { |
|
160 |
return CTVM.installCode(target, compiledCode, code, speculationLog); |
|
161 |
} |
|
162 |
||
163 |
public static int getMetadata(TargetDescription target, |
|
164 |
HotSpotCompiledCode compiledCode, HotSpotMetaData metaData) { |
|
165 |
return CTVM.getMetadata(target, compiledCode, metaData); |
|
166 |
} |
|
167 |
||
168 |
public static void resetCompilationStatistics() { |
|
169 |
CTVM.resetCompilationStatistics(); |
|
170 |
} |
|
171 |
||
172 |
public static Object[] readConfiguration() { |
|
173 |
return CTVM.readConfiguration(); |
|
174 |
} |
|
175 |
||
176 |
public static HotSpotResolvedJavaMethod resolveMethod( |
|
177 |
HotSpotResolvedObjectType exactReceiver, |
|
178 |
HotSpotResolvedJavaMethod method, |
|
179 |
HotSpotResolvedObjectType caller) { |
|
180 |
return CTVM.resolveMethod((HotSpotResolvedObjectTypeImpl) exactReceiver, (HotSpotResolvedJavaMethodImpl) method, (HotSpotResolvedObjectTypeImpl) caller); |
|
181 |
} |
|
182 |
||
183 |
public static HotSpotResolvedJavaMethod getClassInitializer( |
|
184 |
HotSpotResolvedObjectType type) { |
|
185 |
return CTVM.getClassInitializer((HotSpotResolvedObjectTypeImpl) type); |
|
186 |
} |
|
187 |
||
188 |
public static boolean hasFinalizableSubclass(HotSpotResolvedObjectType type) { |
|
189 |
return CTVM.hasFinalizableSubclass((HotSpotResolvedObjectTypeImpl) type); |
|
190 |
} |
|
191 |
||
192 |
public static HotSpotResolvedJavaMethodImpl asResolvedJavaMethod( |
|
193 |
Executable executable) { |
|
194 |
return CTVM.asResolvedJavaMethod(executable); |
|
195 |
} |
|
196 |
||
197 |
public static long getMaxCallTargetOffset(long address) { |
|
198 |
return CTVM.getMaxCallTargetOffset(address); |
|
199 |
} |
|
200 |
||
201 |
public static String disassembleCodeBlob(InstalledCode codeBlob) { |
|
202 |
return CTVM.disassembleCodeBlob(codeBlob); |
|
203 |
} |
|
204 |
||
205 |
public static StackTraceElement getStackTraceElement( |
|
206 |
HotSpotResolvedJavaMethod method, int bci) { |
|
207 |
return CTVM.getStackTraceElement((HotSpotResolvedJavaMethodImpl)method, bci); |
|
208 |
} |
|
209 |
||
210 |
public static Object executeInstalledCode(Object[] args, |
|
211 |
InstalledCode installedCode) throws InvalidInstalledCodeException { |
|
212 |
return CTVM.executeInstalledCode(args, installedCode); |
|
213 |
} |
|
214 |
||
215 |
public static long[] getLineNumberTable(HotSpotResolvedJavaMethod method) { |
|
216 |
return CTVM.getLineNumberTable((HotSpotResolvedJavaMethodImpl)method); |
|
217 |
} |
|
218 |
||
219 |
public static int getLocalVariableTableLength(HotSpotResolvedJavaMethod method) { |
|
220 |
return CTVM.getLocalVariableTableLength((HotSpotResolvedJavaMethodImpl)method); |
|
221 |
} |
|
222 |
||
223 |
public static long getLocalVariableTableStart(HotSpotResolvedJavaMethod method) { |
|
224 |
return CTVM.getLocalVariableTableStart((HotSpotResolvedJavaMethodImpl)method); |
|
225 |
} |
|
226 |
||
47793
3dcd54513db1
8186478: [JVMCI] rename HotSpotResolvedJavaMethod#setNotInlineableOrCompileable
dnsimon
parents:
47668
diff
changeset
|
227 |
public static void setNotInlinableOrCompilable(HotSpotResolvedJavaMethod method) { |
3dcd54513db1
8186478: [JVMCI] rename HotSpotResolvedJavaMethod#setNotInlineableOrCompileable
dnsimon
parents:
47668
diff
changeset
|
228 |
CTVM.setNotInlinableOrCompilable((HotSpotResolvedJavaMethodImpl)method); |
43972 | 229 |
} |
230 |
||
231 |
public static void reprofile(HotSpotResolvedJavaMethod method) { |
|
232 |
CTVM.reprofile((HotSpotResolvedJavaMethodImpl)method); |
|
233 |
} |
|
234 |
||
235 |
public static void invalidateInstalledCode(InstalledCode installedCode) { |
|
236 |
CTVM.invalidateInstalledCode(installedCode); |
|
237 |
} |
|
238 |
||
239 |
public static long[] collectCounters() { |
|
240 |
return CTVM.collectCounters(); |
|
241 |
} |
|
242 |
||
243 |
public static boolean isMature(long metaspaceMethodData) { |
|
244 |
return CTVM.isMature(metaspaceMethodData); |
|
245 |
} |
|
246 |
||
247 |
public static int allocateCompileId(HotSpotResolvedJavaMethod method, |
|
248 |
int entryBCI) { |
|
249 |
return CTVM.allocateCompileId((HotSpotResolvedJavaMethodImpl) method, entryBCI); |
|
250 |
} |
|
251 |
||
252 |
public static boolean hasCompiledCodeForOSR( |
|
253 |
HotSpotResolvedJavaMethod method, int entryBCI, int level) { |
|
254 |
return CTVM.hasCompiledCodeForOSR((HotSpotResolvedJavaMethodImpl) method, entryBCI, level); |
|
255 |
} |
|
256 |
||
257 |
public static String getSymbol(long metaspaceSymbol) { |
|
258 |
return CTVM.getSymbol(metaspaceSymbol); |
|
259 |
} |
|
260 |
||
261 |
public static HotSpotStackFrameReference getNextStackFrame( |
|
262 |
HotSpotStackFrameReference frame, |
|
263 |
ResolvedJavaMethod[] methods, int initialSkip) { |
|
264 |
return CTVM.getNextStackFrame(frame, methods, initialSkip); |
|
265 |
} |
|
266 |
||
267 |
public static void materializeVirtualObjects( |
|
268 |
HotSpotStackFrameReference stackFrame, boolean invalidate) { |
|
269 |
CTVM.materializeVirtualObjects(stackFrame, invalidate); |
|
270 |
} |
|
271 |
||
272 |
public static int getVtableIndexForInterfaceMethod(HotSpotResolvedObjectType type, |
|
273 |
HotSpotResolvedJavaMethod method) { |
|
274 |
return CTVM.getVtableIndexForInterfaceMethod((HotSpotResolvedObjectTypeImpl) type, (HotSpotResolvedJavaMethodImpl) method); |
|
275 |
} |
|
276 |
||
277 |
public static boolean shouldDebugNonSafepoints() { |
|
278 |
return CTVM.shouldDebugNonSafepoints(); |
|
279 |
} |
|
280 |
||
281 |
public static void writeDebugOutput(byte[] bytes, int offset, int length) { |
|
282 |
CTVM.writeDebugOutput(bytes, offset, length); |
|
283 |
} |
|
284 |
||
285 |
public static void flushDebugOutput() { |
|
286 |
CTVM.flushDebugOutput(); |
|
287 |
} |
|
288 |
||
289 |
public static HotSpotResolvedJavaMethod getResolvedJavaMethod(Object base, |
|
290 |
long displacement) { |
|
291 |
return CTVM.getResolvedJavaMethod(base, displacement); |
|
292 |
} |
|
293 |
||
294 |
public static HotSpotConstantPool getConstantPool(Object object) { |
|
295 |
return CTVM.getConstantPool(object); |
|
296 |
} |
|
297 |
||
298 |
public static HotSpotResolvedObjectType getResolvedJavaType(Object base, |
|
299 |
long displacement, boolean compressed) { |
|
300 |
return CTVM.getResolvedJavaType(base, displacement, compressed); |
|
301 |
} |
|
302 |
||
303 |
public static long getMetaspacePointer(Object o) { |
|
304 |
return ((MetaspaceWrapperObject) o).getMetaspacePointer(); |
|
305 |
} |
|
306 |
||
307 |
public static Class<?> CompilerToVMClass() { |
|
308 |
return CompilerToVM.class; |
|
309 |
} |
|
310 |
||
311 |
public static Class<?> getMirror(HotSpotResolvedObjectType type) { |
|
312 |
return ((HotSpotResolvedJavaType) type).mirror(); |
|
313 |
} |
|
314 |
} |