author | dnsimon |
Fri, 05 Oct 2018 20:03:14 +0200 | |
changeset 52033 | d6aa9ea2405d |
parent 51736 | 42d99cb7f50f |
child 52578 | 7dd81e82d083 |
permissions | -rw-r--r-- |
43972 | 1 |
/* |
47667 | 2 |
* Copyright (c) 2012, 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 |
*/ |
|
50858 | 23 |
|
24 |
||
43972 | 25 |
package org.graalvm.compiler.hotspot; |
26 |
||
27 |
import java.util.EnumSet; |
|
46459 | 28 |
|
51736 | 29 |
import jdk.internal.vm.compiler.collections.EconomicMap; |
30 |
import jdk.internal.vm.compiler.collections.EconomicSet; |
|
31 |
import jdk.internal.vm.compiler.collections.Equivalence; |
|
32 |
import jdk.internal.vm.compiler.collections.MapCursor; |
|
43972 | 33 |
import org.graalvm.compiler.code.CompilationResult; |
34 |
import org.graalvm.compiler.core.common.CompilationIdentifier; |
|
35 |
import org.graalvm.compiler.core.common.cfg.AbstractBlockBase; |
|
36 |
import org.graalvm.compiler.core.common.spi.ForeignCallDescriptor; |
|
37 |
import org.graalvm.compiler.core.common.spi.ForeignCallLinkage; |
|
38 |
import org.graalvm.compiler.core.target.Backend; |
|
39 |
import org.graalvm.compiler.graph.Node.ConstantNodeParameter; |
|
40 |
import org.graalvm.compiler.graph.Node.NodeIntrinsic; |
|
41 |
import org.graalvm.compiler.hotspot.meta.HotSpotProviders; |
|
42 |
import org.graalvm.compiler.hotspot.nodes.VMErrorNode; |
|
43 |
import org.graalvm.compiler.hotspot.nodes.aot.ResolveConstantStubCall; |
|
44 |
import org.graalvm.compiler.hotspot.replacements.AESCryptSubstitutions; |
|
45 |
import org.graalvm.compiler.hotspot.replacements.BigIntegerSubstitutions; |
|
46 |
import org.graalvm.compiler.hotspot.replacements.CipherBlockChainingSubstitutions; |
|
47 |
import org.graalvm.compiler.hotspot.replacements.SHA2Substitutions; |
|
48 |
import org.graalvm.compiler.hotspot.replacements.SHA5Substitutions; |
|
49 |
import org.graalvm.compiler.hotspot.replacements.SHASubstitutions; |
|
50 |
import org.graalvm.compiler.hotspot.stubs.ExceptionHandlerStub; |
|
51 |
import org.graalvm.compiler.hotspot.stubs.Stub; |
|
52 |
import org.graalvm.compiler.hotspot.stubs.UnwindExceptionToCallerStub; |
|
53 |
import org.graalvm.compiler.hotspot.word.KlassPointer; |
|
54 |
import org.graalvm.compiler.hotspot.word.MethodCountersPointer; |
|
55 |
import org.graalvm.compiler.lir.LIR; |
|
56 |
import org.graalvm.compiler.lir.LIRFrameState; |
|
57 |
import org.graalvm.compiler.lir.LIRInstruction; |
|
58 |
import org.graalvm.compiler.lir.LIRInstruction.OperandFlag; |
|
59 |
import org.graalvm.compiler.lir.LIRInstruction.OperandMode; |
|
60 |
import org.graalvm.compiler.lir.StandardOp.LabelOp; |
|
61 |
import org.graalvm.compiler.lir.StandardOp.SaveRegistersOp; |
|
62 |
import org.graalvm.compiler.lir.ValueConsumer; |
|
63 |
import org.graalvm.compiler.lir.asm.CompilationResultBuilder; |
|
64 |
import org.graalvm.compiler.lir.framemap.FrameMap; |
|
65 |
import org.graalvm.compiler.nodes.UnwindNode; |
|
66 |
import org.graalvm.compiler.nodes.extended.ForeignCallNode; |
|
67 |
import org.graalvm.compiler.options.Option; |
|
46344 | 68 |
import org.graalvm.compiler.options.OptionKey; |
43972 | 69 |
import org.graalvm.compiler.options.OptionType; |
46344 | 70 |
import org.graalvm.compiler.options.OptionValues; |
43972 | 71 |
import org.graalvm.compiler.phases.tiers.SuitesProvider; |
72 |
import org.graalvm.compiler.word.Word; |
|
49873 | 73 |
import jdk.internal.vm.compiler.word.Pointer; |
43972 | 74 |
|
75 |
import jdk.vm.ci.code.CompilationRequest; |
|
76 |
import jdk.vm.ci.code.CompiledCode; |
|
77 |
import jdk.vm.ci.code.Register; |
|
78 |
import jdk.vm.ci.code.RegisterSaveLayout; |
|
79 |
import jdk.vm.ci.code.StackSlot; |
|
80 |
import jdk.vm.ci.code.ValueUtil; |
|
81 |
import jdk.vm.ci.hotspot.HotSpotCompilationRequest; |
|
82 |
import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; |
|
83 |
import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; |
|
84 |
import jdk.vm.ci.meta.ResolvedJavaMethod; |
|
85 |
import jdk.vm.ci.meta.Value; |
|
86 |
import jdk.vm.ci.runtime.JVMCICompiler; |
|
87 |
||
88 |
/** |
|
89 |
* HotSpot specific backend. |
|
90 |
*/ |
|
91 |
public abstract class HotSpotBackend extends Backend implements FrameMap.ReferenceMapBuilderFactory { |
|
92 |
||
93 |
public static class Options { |
|
94 |
// @formatter:off |
|
95 |
@Option(help = "Use Graal arithmetic stubs instead of HotSpot stubs where possible") |
|
49451 | 96 |
public static final OptionKey<Boolean> GraalArithmeticStubs = new OptionKey<>(false); // GR-8276 |
43972 | 97 |
@Option(help = "Enables instruction profiling on assembler level. Valid values are a comma separated list of supported instructions." + |
98 |
" Compare with subclasses of Assembler.InstructionCounter.", type = OptionType.Debug) |
|
46344 | 99 |
public static final OptionKey<String> ASMInstructionProfiling = new OptionKey<>(null); |
43972 | 100 |
// @formatter:on |
101 |
} |
|
102 |
||
103 |
/** |
|
104 |
* Descriptor for {@link ExceptionHandlerStub}. This stub is called by the |
|
105 |
* {@linkplain GraalHotSpotVMConfig#MARKID_EXCEPTION_HANDLER_ENTRY exception handler} in a |
|
106 |
* compiled method. |
|
107 |
*/ |
|
108 |
public static final ForeignCallDescriptor EXCEPTION_HANDLER = new ForeignCallDescriptor("exceptionHandler", void.class, Object.class, Word.class); |
|
109 |
||
110 |
/** |
|
111 |
* Descriptor for SharedRuntime::get_ic_miss_stub(). |
|
112 |
*/ |
|
113 |
public static final ForeignCallDescriptor IC_MISS_HANDLER = new ForeignCallDescriptor("icMissHandler", void.class); |
|
114 |
||
115 |
/** |
|
116 |
* Descriptor for SharedRuntime::get_handle_wrong_method_stub(). |
|
117 |
*/ |
|
118 |
public static final ForeignCallDescriptor WRONG_METHOD_HANDLER = new ForeignCallDescriptor("wrongMethodHandler", void.class); |
|
119 |
||
120 |
/** |
|
121 |
* Descriptor for {@link UnwindExceptionToCallerStub}. This stub is called by code generated |
|
122 |
* from {@link UnwindNode}. |
|
123 |
*/ |
|
124 |
public static final ForeignCallDescriptor UNWIND_EXCEPTION_TO_CALLER = new ForeignCallDescriptor("unwindExceptionToCaller", void.class, Object.class, Word.class); |
|
125 |
||
126 |
/** |
|
127 |
* Descriptor for the arguments when unwinding to an exception handler in a caller. |
|
128 |
*/ |
|
129 |
public static final ForeignCallDescriptor EXCEPTION_HANDLER_IN_CALLER = new ForeignCallDescriptor("exceptionHandlerInCaller", void.class, Object.class, Word.class); |
|
130 |
||
131 |
private final HotSpotGraalRuntimeProvider runtime; |
|
132 |
||
133 |
/** |
|
134 |
* @see AESCryptSubstitutions#encryptBlockStub(ForeignCallDescriptor, Word, Word, Pointer) |
|
135 |
*/ |
|
136 |
public static final ForeignCallDescriptor ENCRYPT_BLOCK = new ForeignCallDescriptor("encrypt_block", void.class, Word.class, Word.class, Pointer.class); |
|
137 |
||
138 |
/** |
|
139 |
* @see AESCryptSubstitutions#decryptBlockStub(ForeignCallDescriptor, Word, Word, Pointer) |
|
140 |
*/ |
|
141 |
public static final ForeignCallDescriptor DECRYPT_BLOCK = new ForeignCallDescriptor("decrypt_block", void.class, Word.class, Word.class, Pointer.class); |
|
142 |
||
143 |
/** |
|
144 |
* @see AESCryptSubstitutions#decryptBlockStub(ForeignCallDescriptor, Word, Word, Pointer) |
|
145 |
*/ |
|
146 |
public static final ForeignCallDescriptor DECRYPT_BLOCK_WITH_ORIGINAL_KEY = new ForeignCallDescriptor("decrypt_block_with_original_key", void.class, Word.class, Word.class, Pointer.class, |
|
147 |
Pointer.class); |
|
148 |
||
149 |
/** |
|
150 |
* @see CipherBlockChainingSubstitutions#crypt |
|
151 |
*/ |
|
152 |
public static final ForeignCallDescriptor ENCRYPT = new ForeignCallDescriptor("encrypt", void.class, Word.class, Word.class, Pointer.class, Pointer.class, int.class); |
|
153 |
||
154 |
/** |
|
155 |
* @see CipherBlockChainingSubstitutions#crypt |
|
156 |
*/ |
|
157 |
public static final ForeignCallDescriptor DECRYPT = new ForeignCallDescriptor("decrypt", void.class, Word.class, Word.class, Pointer.class, Pointer.class, int.class); |
|
158 |
||
159 |
/** |
|
160 |
* @see CipherBlockChainingSubstitutions#crypt |
|
161 |
*/ |
|
162 |
public static final ForeignCallDescriptor DECRYPT_WITH_ORIGINAL_KEY = new ForeignCallDescriptor("decrypt_with_original_key", void.class, Word.class, Word.class, Pointer.class, Pointer.class, |
|
163 |
int.class, Pointer.class); |
|
164 |
||
165 |
/** |
|
166 |
* @see BigIntegerSubstitutions#multiplyToLen |
|
167 |
*/ |
|
168 |
public static final ForeignCallDescriptor MULTIPLY_TO_LEN = new ForeignCallDescriptor("multiplyToLen", void.class, Word.class, int.class, Word.class, int.class, Word.class, int.class); |
|
169 |
||
170 |
public static void multiplyToLenStub(Word xAddr, int xlen, Word yAddr, int ylen, Word zAddr, int zLen) { |
|
171 |
multiplyToLenStub(HotSpotBackend.MULTIPLY_TO_LEN, xAddr, xlen, yAddr, ylen, zAddr, zLen); |
|
172 |
} |
|
173 |
||
174 |
@NodeIntrinsic(ForeignCallNode.class) |
|
175 |
private static native void multiplyToLenStub(@ConstantNodeParameter ForeignCallDescriptor descriptor, Word xIn, int xLen, Word yIn, int yLen, Word zIn, int zLen); |
|
176 |
||
177 |
/** |
|
178 |
* @see BigIntegerSubstitutions#mulAdd |
|
179 |
*/ |
|
180 |
public static final ForeignCallDescriptor MUL_ADD = new ForeignCallDescriptor("mulAdd", int.class, Word.class, Word.class, int.class, int.class, int.class); |
|
181 |
||
182 |
public static int mulAddStub(Word inAddr, Word outAddr, int newOffset, int len, int k) { |
|
183 |
return mulAddStub(HotSpotBackend.MUL_ADD, inAddr, outAddr, newOffset, len, k); |
|
184 |
} |
|
185 |
||
186 |
@NodeIntrinsic(ForeignCallNode.class) |
|
187 |
private static native int mulAddStub(@ConstantNodeParameter ForeignCallDescriptor descriptor, Word inAddr, Word outAddr, int newOffset, int len, int k); |
|
188 |
||
189 |
/** |
|
190 |
* @see BigIntegerSubstitutions#implMontgomeryMultiply |
|
191 |
*/ |
|
192 |
public static final ForeignCallDescriptor MONTGOMERY_MULTIPLY = new ForeignCallDescriptor("implMontgomeryMultiply", void.class, Word.class, Word.class, Word.class, int.class, long.class, |
|
193 |
Word.class); |
|
194 |
||
195 |
public static void implMontgomeryMultiply(Word aAddr, Word bAddr, Word nAddr, int len, long inv, Word productAddr) { |
|
196 |
implMontgomeryMultiply(HotSpotBackend.MONTGOMERY_MULTIPLY, aAddr, bAddr, nAddr, len, inv, productAddr); |
|
197 |
} |
|
198 |
||
199 |
@NodeIntrinsic(ForeignCallNode.class) |
|
200 |
private static native void implMontgomeryMultiply(@ConstantNodeParameter ForeignCallDescriptor descriptor, Word aAddr, Word bAddr, Word nAddr, int len, long inv, Word productAddr); |
|
201 |
||
202 |
/** |
|
203 |
* @see BigIntegerSubstitutions#implMontgomerySquare |
|
204 |
*/ |
|
205 |
public static final ForeignCallDescriptor MONTGOMERY_SQUARE = new ForeignCallDescriptor("implMontgomerySquare", void.class, Word.class, Word.class, int.class, long.class, Word.class); |
|
206 |
||
207 |
public static void implMontgomerySquare(Word aAddr, Word nAddr, int len, long inv, Word productAddr) { |
|
208 |
implMontgomerySquare(HotSpotBackend.MONTGOMERY_SQUARE, aAddr, nAddr, len, inv, productAddr); |
|
209 |
} |
|
210 |
||
211 |
@NodeIntrinsic(ForeignCallNode.class) |
|
212 |
private static native void implMontgomerySquare(@ConstantNodeParameter ForeignCallDescriptor descriptor, Word aAddr, Word nAddr, int len, long inv, Word productAddr); |
|
213 |
||
214 |
/** |
|
215 |
* @see BigIntegerSubstitutions#implSquareToLen |
|
216 |
*/ |
|
217 |
public static final ForeignCallDescriptor SQUARE_TO_LEN = new ForeignCallDescriptor("implSquareToLen", void.class, Word.class, int.class, Word.class, int.class); |
|
218 |
||
219 |
public static void implSquareToLen(Word xAddr, int len, Word zAddr, int zLen) { |
|
220 |
implSquareToLen(SQUARE_TO_LEN, xAddr, len, zAddr, zLen); |
|
221 |
} |
|
222 |
||
223 |
@NodeIntrinsic(ForeignCallNode.class) |
|
224 |
private static native void implSquareToLen(@ConstantNodeParameter ForeignCallDescriptor descriptor, Word xAddr, int len, Word zAddr, int zLen); |
|
225 |
||
226 |
/** |
|
227 |
* @see SHASubstitutions#implCompress0 |
|
228 |
*/ |
|
229 |
public static final ForeignCallDescriptor SHA_IMPL_COMPRESS = new ForeignCallDescriptor("shaImplCompress", void.class, Word.class, Object.class); |
|
230 |
||
231 |
public static void shaImplCompressStub(Word bufAddr, Object state) { |
|
232 |
shaImplCompressStub(HotSpotBackend.SHA_IMPL_COMPRESS, bufAddr, state); |
|
233 |
} |
|
234 |
||
235 |
@NodeIntrinsic(ForeignCallNode.class) |
|
236 |
private static native void shaImplCompressStub(@ConstantNodeParameter ForeignCallDescriptor descriptor, Word bufAddr, Object state); |
|
237 |
||
238 |
/** |
|
239 |
* @see SHA2Substitutions#implCompress0 |
|
240 |
*/ |
|
241 |
public static final ForeignCallDescriptor SHA2_IMPL_COMPRESS = new ForeignCallDescriptor("sha2ImplCompress", void.class, Word.class, Object.class); |
|
242 |
||
243 |
public static void sha2ImplCompressStub(Word bufAddr, Object state) { |
|
244 |
sha2ImplCompressStub(HotSpotBackend.SHA2_IMPL_COMPRESS, bufAddr, state); |
|
245 |
} |
|
246 |
||
247 |
@NodeIntrinsic(ForeignCallNode.class) |
|
248 |
private static native void sha2ImplCompressStub(@ConstantNodeParameter ForeignCallDescriptor descriptor, Word bufAddr, Object state); |
|
249 |
||
250 |
/** |
|
251 |
* @see SHA5Substitutions#implCompress0 |
|
252 |
*/ |
|
253 |
public static final ForeignCallDescriptor SHA5_IMPL_COMPRESS = new ForeignCallDescriptor("sha5ImplCompress", void.class, Word.class, Object.class); |
|
254 |
||
255 |
public static void sha5ImplCompressStub(Word bufAddr, Object state) { |
|
256 |
sha5ImplCompressStub(HotSpotBackend.SHA5_IMPL_COMPRESS, bufAddr, state); |
|
257 |
} |
|
258 |
||
259 |
@NodeIntrinsic(ForeignCallNode.class) |
|
260 |
private static native void sha5ImplCompressStub(@ConstantNodeParameter ForeignCallDescriptor descriptor, Word bufAddr, Object state); |
|
261 |
||
262 |
/** |
|
47084 | 263 |
* @see org.graalvm.compiler.hotspot.meta.HotSpotUnsafeSubstitutions#copyMemory |
264 |
*/ |
|
265 |
public static final ForeignCallDescriptor UNSAFE_ARRAYCOPY = new ForeignCallDescriptor("unsafe_arraycopy", void.class, Word.class, Word.class, Word.class); |
|
266 |
||
267 |
public static void unsafeArraycopy(Word srcAddr, Word dstAddr, Word size) { |
|
268 |
unsafeArraycopyStub(HotSpotBackend.UNSAFE_ARRAYCOPY, srcAddr, dstAddr, size); |
|
269 |
} |
|
270 |
||
47798 | 271 |
public static final ForeignCallDescriptor GENERIC_ARRAYCOPY = new ForeignCallDescriptor("generic_arraycopy", int.class, Word.class, int.class, Word.class, int.class, int.class); |
272 |
||
47084 | 273 |
@NodeIntrinsic(ForeignCallNode.class) |
274 |
private static native void unsafeArraycopyStub(@ConstantNodeParameter ForeignCallDescriptor descriptor, Word srcAddr, Word dstAddr, Word size); |
|
275 |
||
276 |
/** |
|
43972 | 277 |
* @see VMErrorNode |
278 |
*/ |
|
279 |
public static final ForeignCallDescriptor VM_ERROR = new ForeignCallDescriptor("vm_error", void.class, Object.class, Object.class, long.class); |
|
280 |
||
281 |
/** |
|
52033
d6aa9ea2405d
8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents:
51736
diff
changeset
|
282 |
* New multi array stub that throws an {@link OutOfMemoryError} on allocation failure. |
43972 | 283 |
*/ |
284 |
public static final ForeignCallDescriptor NEW_MULTI_ARRAY = new ForeignCallDescriptor("new_multi_array", Object.class, KlassPointer.class, int.class, Word.class); |
|
285 |
||
286 |
/** |
|
52033
d6aa9ea2405d
8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents:
51736
diff
changeset
|
287 |
* New multi array stub that will return null on allocation failure. |
d6aa9ea2405d
8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents:
51736
diff
changeset
|
288 |
*/ |
d6aa9ea2405d
8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents:
51736
diff
changeset
|
289 |
public static final ForeignCallDescriptor NEW_MULTI_ARRAY_OR_NULL = new ForeignCallDescriptor("new_multi_array_or_null", Object.class, KlassPointer.class, int.class, Word.class); |
d6aa9ea2405d
8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents:
51736
diff
changeset
|
290 |
|
d6aa9ea2405d
8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents:
51736
diff
changeset
|
291 |
/** |
d6aa9ea2405d
8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents:
51736
diff
changeset
|
292 |
* New array stub that throws an {@link OutOfMemoryError} on allocation failure. |
43972 | 293 |
*/ |
51736 | 294 |
public static final ForeignCallDescriptor NEW_ARRAY = new ForeignCallDescriptor("new_array", Object.class, KlassPointer.class, int.class); |
43972 | 295 |
|
296 |
/** |
|
52033
d6aa9ea2405d
8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents:
51736
diff
changeset
|
297 |
* New array stub that will return null on allocation failure. |
d6aa9ea2405d
8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents:
51736
diff
changeset
|
298 |
*/ |
d6aa9ea2405d
8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents:
51736
diff
changeset
|
299 |
public static final ForeignCallDescriptor NEW_ARRAY_OR_NULL = new ForeignCallDescriptor("new_array_or_null", Object.class, KlassPointer.class, int.class); |
d6aa9ea2405d
8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents:
51736
diff
changeset
|
300 |
|
d6aa9ea2405d
8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents:
51736
diff
changeset
|
301 |
/** |
d6aa9ea2405d
8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents:
51736
diff
changeset
|
302 |
* New instance stub that throws an {@link OutOfMemoryError} on allocation failure. |
43972 | 303 |
*/ |
304 |
public static final ForeignCallDescriptor NEW_INSTANCE = new ForeignCallDescriptor("new_instance", Object.class, KlassPointer.class); |
|
305 |
||
306 |
/** |
|
52033
d6aa9ea2405d
8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents:
51736
diff
changeset
|
307 |
* New instance stub that will return null on allocation failure. |
d6aa9ea2405d
8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents:
51736
diff
changeset
|
308 |
*/ |
d6aa9ea2405d
8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents:
51736
diff
changeset
|
309 |
public static final ForeignCallDescriptor NEW_INSTANCE_OR_NULL = new ForeignCallDescriptor("new_instance_or_null", Object.class, KlassPointer.class); |
d6aa9ea2405d
8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents:
51736
diff
changeset
|
310 |
|
d6aa9ea2405d
8208686: [AOT] JVMTI ResourceExhausted event repeated for same allocation
dnsimon
parents:
51736
diff
changeset
|
311 |
/** |
43972 | 312 |
* @see ResolveConstantStubCall |
313 |
*/ |
|
314 |
public static final ForeignCallDescriptor RESOLVE_STRING_BY_SYMBOL = new ForeignCallDescriptor("resolve_string_by_symbol", Object.class, Word.class, Word.class); |
|
315 |
||
316 |
/** |
|
317 |
* @see ResolveConstantStubCall |
|
318 |
*/ |
|
47667 | 319 |
public static final ForeignCallDescriptor RESOLVE_DYNAMIC_INVOKE = new ForeignCallDescriptor("resolve_dynamic_invoke", Object.class, Word.class); |
320 |
||
321 |
/** |
|
322 |
* @see ResolveConstantStubCall |
|
323 |
*/ |
|
43972 | 324 |
public static final ForeignCallDescriptor RESOLVE_KLASS_BY_SYMBOL = new ForeignCallDescriptor("resolve_klass_by_symbol", Word.class, Word.class, Word.class); |
325 |
||
326 |
/** |
|
327 |
* @see ResolveConstantStubCall |
|
328 |
*/ |
|
329 |
public static final ForeignCallDescriptor INITIALIZE_KLASS_BY_SYMBOL = new ForeignCallDescriptor("initialize_klass_by_symbol", Word.class, Word.class, Word.class); |
|
330 |
||
331 |
/** |
|
332 |
* @see ResolveConstantStubCall |
|
333 |
*/ |
|
334 |
public static final ForeignCallDescriptor RESOLVE_METHOD_BY_SYMBOL_AND_LOAD_COUNTERS = new ForeignCallDescriptor("resolve_method_by_symbol_and_load_counters", Word.class, Word.class, Word.class, |
|
335 |
Word.class); |
|
336 |
||
337 |
/** |
|
338 |
* Tiered support. |
|
339 |
*/ |
|
340 |
public static final ForeignCallDescriptor INVOCATION_EVENT = new ForeignCallDescriptor("invocation_event", void.class, MethodCountersPointer.class); |
|
341 |
public static final ForeignCallDescriptor BACKEDGE_EVENT = new ForeignCallDescriptor("backedge_event", void.class, MethodCountersPointer.class, int.class, int.class); |
|
342 |
||
343 |
public HotSpotBackend(HotSpotGraalRuntimeProvider runtime, HotSpotProviders providers) { |
|
344 |
super(providers); |
|
345 |
this.runtime = runtime; |
|
346 |
} |
|
347 |
||
348 |
public HotSpotGraalRuntimeProvider getRuntime() { |
|
349 |
return runtime; |
|
350 |
} |
|
351 |
||
352 |
/** |
|
353 |
* Performs any remaining initialization that was deferred until the {@linkplain #getRuntime() |
|
354 |
* runtime} object was initialized and this backend was registered with it. |
|
355 |
* |
|
356 |
* @param jvmciRuntime |
|
46344 | 357 |
* @param options |
43972 | 358 |
*/ |
46344 | 359 |
public void completeInitialization(HotSpotJVMCIRuntime jvmciRuntime, OptionValues options) { |
43972 | 360 |
} |
361 |
||
362 |
/** |
|
363 |
* Finds all the registers that are defined by some given LIR. |
|
364 |
* |
|
365 |
* @param lir the LIR to examine |
|
366 |
* @return the registers that are defined by or used as temps for any instruction in {@code lir} |
|
367 |
*/ |
|
46344 | 368 |
protected final EconomicSet<Register> gatherDestroyedCallerRegisters(LIR lir) { |
369 |
final EconomicSet<Register> destroyedRegisters = EconomicSet.create(Equivalence.IDENTITY); |
|
43972 | 370 |
ValueConsumer defConsumer = new ValueConsumer() { |
371 |
||
372 |
@Override |
|
373 |
public void visitValue(Value value, OperandMode mode, EnumSet<OperandFlag> flags) { |
|
374 |
if (ValueUtil.isRegister(value)) { |
|
375 |
final Register reg = ValueUtil.asRegister(value); |
|
376 |
destroyedRegisters.add(reg); |
|
377 |
} |
|
378 |
} |
|
379 |
}; |
|
380 |
for (AbstractBlockBase<?> block : lir.codeEmittingOrder()) { |
|
381 |
if (block == null) { |
|
382 |
continue; |
|
383 |
} |
|
384 |
for (LIRInstruction op : lir.getLIRforBlock(block)) { |
|
385 |
if (op instanceof LabelOp) { |
|
386 |
// Don't consider this as a definition |
|
387 |
} else { |
|
388 |
op.visitEachTemp(defConsumer); |
|
389 |
op.visitEachOutput(defConsumer); |
|
390 |
} |
|
391 |
} |
|
392 |
} |
|
393 |
return translateToCallerRegisters(destroyedRegisters); |
|
394 |
} |
|
395 |
||
396 |
/** |
|
397 |
* Updates a given stub with respect to the registers it destroys. |
|
398 |
* <p> |
|
399 |
* Any entry in {@code calleeSaveInfo} that {@linkplain SaveRegistersOp#supportsRemove() |
|
400 |
* supports} pruning will have {@code destroyedRegisters} |
|
46344 | 401 |
* {@linkplain SaveRegistersOp#remove(EconomicSet) removed} as these registers are declared as |
43972 | 402 |
* temporaries in the stub's {@linkplain ForeignCallLinkage linkage} (and thus will be saved by |
403 |
* the stub's caller). |
|
404 |
* |
|
405 |
* @param stub the stub to update |
|
406 |
* @param destroyedRegisters the registers destroyed by the stub |
|
407 |
* @param calleeSaveInfo a map from debug infos to the operations that provide their |
|
408 |
* {@linkplain RegisterSaveLayout callee-save information} |
|
409 |
* @param frameMap used to {@linkplain FrameMap#offsetForStackSlot(StackSlot) convert} a virtual |
|
410 |
* slot to a frame slot index |
|
411 |
*/ |
|
46344 | 412 |
protected void updateStub(Stub stub, EconomicSet<Register> destroyedRegisters, EconomicMap<LIRFrameState, SaveRegistersOp> calleeSaveInfo, FrameMap frameMap) { |
43972 | 413 |
stub.initDestroyedCallerRegisters(destroyedRegisters); |
414 |
||
46344 | 415 |
MapCursor<LIRFrameState, SaveRegistersOp> cursor = calleeSaveInfo.getEntries(); |
416 |
while (cursor.advance()) { |
|
417 |
SaveRegistersOp save = cursor.getValue(); |
|
43972 | 418 |
if (save.supportsRemove()) { |
419 |
save.remove(destroyedRegisters); |
|
420 |
} |
|
46344 | 421 |
if (cursor.getKey() != LIRFrameState.NO_STATE) { |
422 |
cursor.getKey().debugInfo().setCalleeSaveInfo(save.getMap(frameMap)); |
|
43972 | 423 |
} |
424 |
} |
|
425 |
} |
|
426 |
||
427 |
@Override |
|
428 |
public HotSpotProviders getProviders() { |
|
429 |
return (HotSpotProviders) super.getProviders(); |
|
430 |
} |
|
431 |
||
432 |
@Override |
|
433 |
public SuitesProvider getSuites() { |
|
434 |
return getProviders().getSuites(); |
|
435 |
} |
|
436 |
||
437 |
protected void profileInstructions(LIR lir, CompilationResultBuilder crb) { |
|
46344 | 438 |
if (HotSpotBackend.Options.ASMInstructionProfiling.getValue(lir.getOptions()) != null) { |
43972 | 439 |
HotSpotInstructionProfiling.countInstructions(lir, crb.asm); |
440 |
} |
|
441 |
} |
|
442 |
||
443 |
@Override |
|
444 |
public CompiledCode createCompiledCode(ResolvedJavaMethod method, CompilationRequest compilationRequest, CompilationResult compResult) { |
|
445 |
HotSpotCompilationRequest compRequest = compilationRequest instanceof HotSpotCompilationRequest ? (HotSpotCompilationRequest) compilationRequest : null; |
|
46371 | 446 |
return HotSpotCompiledCodeBuilder.createCompiledCode(getCodeCache(), method, compRequest, compResult); |
43972 | 447 |
} |
448 |
||
449 |
@Override |
|
450 |
public CompilationIdentifier getCompilationIdentifier(ResolvedJavaMethod resolvedJavaMethod) { |
|
451 |
if (resolvedJavaMethod instanceof HotSpotResolvedJavaMethod) { |
|
452 |
HotSpotCompilationRequest request = new HotSpotCompilationRequest((HotSpotResolvedJavaMethod) resolvedJavaMethod, JVMCICompiler.INVOCATION_ENTRY_BCI, 0L); |
|
453 |
return new HotSpotCompilationIdentifier(request); |
|
454 |
} |
|
455 |
return super.getCompilationIdentifier(resolvedJavaMethod); |
|
456 |
} |
|
457 |
} |