Sat, 09 Nov 2019 20:29:45 +0800
Merge
1 /*
2 * Copyright (c) 1998, 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 */
25 /*
26 * This file has been modified by Loongson Technology in 2015. These
27 * modifications are Copyright (c) 2015 Loongson Technology, and are made
28 * available on the same license terms set forth above.
29 */
31 #include "precompiled.hpp"
32 #include "classfile/systemDictionary.hpp"
33 #include "classfile/vmSymbols.hpp"
34 #include "code/compiledIC.hpp"
35 #include "code/icBuffer.hpp"
36 #include "code/nmethod.hpp"
37 #include "code/pcDesc.hpp"
38 #include "code/scopeDesc.hpp"
39 #include "code/vtableStubs.hpp"
40 #include "compiler/compileBroker.hpp"
41 #include "compiler/compilerOracle.hpp"
42 #include "compiler/oopMap.hpp"
43 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
44 #include "gc_implementation/g1/heapRegion.hpp"
45 #include "gc_interface/collectedHeap.hpp"
46 #include "interpreter/bytecode.hpp"
47 #include "interpreter/interpreter.hpp"
48 #include "interpreter/linkResolver.hpp"
49 #include "memory/barrierSet.hpp"
50 #include "memory/gcLocker.inline.hpp"
51 #include "memory/oopFactory.hpp"
52 #include "oops/objArrayKlass.hpp"
53 #include "oops/oop.inline.hpp"
54 #include "opto/addnode.hpp"
55 #include "opto/callnode.hpp"
56 #include "opto/cfgnode.hpp"
57 #include "opto/connode.hpp"
58 #include "opto/graphKit.hpp"
59 #include "opto/machnode.hpp"
60 #include "opto/matcher.hpp"
61 #include "opto/memnode.hpp"
62 #include "opto/mulnode.hpp"
63 #include "opto/runtime.hpp"
64 #include "opto/subnode.hpp"
65 #include "runtime/fprofiler.hpp"
66 #include "runtime/handles.inline.hpp"
67 #include "runtime/interfaceSupport.hpp"
68 #include "runtime/javaCalls.hpp"
69 #include "runtime/sharedRuntime.hpp"
70 #include "runtime/signature.hpp"
71 #include "runtime/threadCritical.hpp"
72 #include "runtime/vframe.hpp"
73 #include "runtime/vframeArray.hpp"
74 #include "runtime/vframe_hp.hpp"
75 #include "utilities/copy.hpp"
76 #include "utilities/preserveException.hpp"
77 #if defined AD_MD_HPP
78 # include AD_MD_HPP
79 #elif defined TARGET_ARCH_MODEL_x86_32
80 # include "adfiles/ad_x86_32.hpp"
81 #elif defined TARGET_ARCH_MODEL_x86_64
82 # include "adfiles/ad_x86_64.hpp"
83 #elif defined TARGET_ARCH_MODEL_sparc
84 # include "adfiles/ad_sparc.hpp"
85 #elif defined TARGET_ARCH_MODEL_zero
86 # include "adfiles/ad_zero.hpp"
87 #elif defined TARGET_ARCH_MODEL_ppc_64
88 # include "adfiles/ad_ppc_64.hpp"
89 #elif defined TARGET_ARCH_MODEL_mips_64
90 # include "adfiles/ad_mips_64.hpp"
91 #endif
94 // For debugging purposes:
95 // To force FullGCALot inside a runtime function, add the following two lines
96 //
97 // Universe::release_fullgc_alot_dummy();
98 // MarkSweep::invoke(0, "Debugging");
99 //
100 // At command line specify the parameters: -XX:+FullGCALot -XX:FullGCALotStart=100000000
105 // Compiled code entry points
106 address OptoRuntime::_new_instance_Java = NULL;
107 address OptoRuntime::_new_array_Java = NULL;
108 address OptoRuntime::_new_array_nozero_Java = NULL;
109 address OptoRuntime::_multianewarray2_Java = NULL;
110 address OptoRuntime::_multianewarray3_Java = NULL;
111 address OptoRuntime::_multianewarray4_Java = NULL;
112 address OptoRuntime::_multianewarray5_Java = NULL;
113 address OptoRuntime::_multianewarrayN_Java = NULL;
114 address OptoRuntime::_g1_wb_pre_Java = NULL;
115 address OptoRuntime::_g1_wb_post_Java = NULL;
116 address OptoRuntime::_vtable_must_compile_Java = NULL;
117 address OptoRuntime::_complete_monitor_locking_Java = NULL;
118 address OptoRuntime::_rethrow_Java = NULL;
120 address OptoRuntime::_slow_arraycopy_Java = NULL;
121 address OptoRuntime::_register_finalizer_Java = NULL;
123 # ifdef ENABLE_ZAP_DEAD_LOCALS
124 address OptoRuntime::_zap_dead_Java_locals_Java = NULL;
125 address OptoRuntime::_zap_dead_native_locals_Java = NULL;
126 # endif
128 ExceptionBlob* OptoRuntime::_exception_blob;
130 // This should be called in an assertion at the start of OptoRuntime routines
131 // which are entered from compiled code (all of them)
132 #ifdef ASSERT
133 static bool check_compiled_frame(JavaThread* thread) {
134 assert(thread->last_frame().is_runtime_frame(), "cannot call runtime directly from compiled code");
135 RegisterMap map(thread, false);
136 frame caller = thread->last_frame().sender(&map);
137 assert(caller.is_compiled_frame(), "not being called from compiled like code");
138 return true;
139 }
140 #endif // ASSERT
143 #define gen(env, var, type_func_gen, c_func, fancy_jump, pass_tls, save_arg_regs, return_pc) \
144 var = generate_stub(env, type_func_gen, CAST_FROM_FN_PTR(address, c_func), #var, fancy_jump, pass_tls, save_arg_regs, return_pc); \
145 if (var == NULL) { return false; }
147 bool OptoRuntime::generate(ciEnv* env) {
149 generate_exception_blob();
151 // Note: tls: Means fetching the return oop out of the thread-local storage
152 //
153 // variable/name type-function-gen , runtime method ,fncy_jp, tls,save_args,retpc
154 // -------------------------------------------------------------------------------------------------------------------------------
155 gen(env, _new_instance_Java , new_instance_Type , new_instance_C , 0 , true , false, false);
156 gen(env, _new_array_Java , new_array_Type , new_array_C , 0 , true , false, false);
157 gen(env, _new_array_nozero_Java , new_array_Type , new_array_nozero_C , 0 , true , false, false);
158 gen(env, _multianewarray2_Java , multianewarray2_Type , multianewarray2_C , 0 , true , false, false);
159 gen(env, _multianewarray3_Java , multianewarray3_Type , multianewarray3_C , 0 , true , false, false);
160 gen(env, _multianewarray4_Java , multianewarray4_Type , multianewarray4_C , 0 , true , false, false);
161 gen(env, _multianewarray5_Java , multianewarray5_Type , multianewarray5_C , 0 , true , false, false);
162 gen(env, _multianewarrayN_Java , multianewarrayN_Type , multianewarrayN_C , 0 , true , false, false);
163 gen(env, _g1_wb_pre_Java , g1_wb_pre_Type , SharedRuntime::g1_wb_pre , 0 , false, false, false);
164 gen(env, _g1_wb_post_Java , g1_wb_post_Type , SharedRuntime::g1_wb_post , 0 , false, false, false);
165 gen(env, _complete_monitor_locking_Java , complete_monitor_enter_Type , SharedRuntime::complete_monitor_locking_C, 0, false, false, false);
166 gen(env, _rethrow_Java , rethrow_Type , rethrow_C , 2 , true , false, true );
168 gen(env, _slow_arraycopy_Java , slow_arraycopy_Type , SharedRuntime::slow_arraycopy_C , 0 , false, false, false);
169 gen(env, _register_finalizer_Java , register_finalizer_Type , register_finalizer , 0 , false, false, false);
171 # ifdef ENABLE_ZAP_DEAD_LOCALS
172 gen(env, _zap_dead_Java_locals_Java , zap_dead_locals_Type , zap_dead_Java_locals_C , 0 , false, true , false );
173 gen(env, _zap_dead_native_locals_Java , zap_dead_locals_Type , zap_dead_native_locals_C , 0 , false, true , false );
174 # endif
175 return true;
176 }
178 #undef gen
181 // Helper method to do generation of RunTimeStub's
182 address OptoRuntime::generate_stub( ciEnv* env,
183 TypeFunc_generator gen, address C_function,
184 const char *name, int is_fancy_jump,
185 bool pass_tls,
186 bool save_argument_registers,
187 bool return_pc ) {
188 ResourceMark rm;
189 Compile C( env, gen, C_function, name, is_fancy_jump, pass_tls, save_argument_registers, return_pc );
190 return C.stub_entry_point();
191 }
193 const char* OptoRuntime::stub_name(address entry) {
194 #ifndef PRODUCT
195 CodeBlob* cb = CodeCache::find_blob(entry);
196 RuntimeStub* rs =(RuntimeStub *)cb;
197 assert(rs != NULL && rs->is_runtime_stub(), "not a runtime stub");
198 return rs->name();
199 #else
200 // Fast implementation for product mode (maybe it should be inlined too)
201 return "runtime stub";
202 #endif
203 }
206 //=============================================================================
207 // Opto compiler runtime routines
208 //=============================================================================
211 //=============================allocation======================================
212 // We failed the fast-path allocation. Now we need to do a scavenge or GC
213 // and try allocation again.
215 void OptoRuntime::new_store_pre_barrier(JavaThread* thread) {
216 // After any safepoint, just before going back to compiled code,
217 // we inform the GC that we will be doing initializing writes to
218 // this object in the future without emitting card-marks, so
219 // GC may take any compensating steps.
220 // NOTE: Keep this code consistent with GraphKit::store_barrier.
222 oop new_obj = thread->vm_result();
223 if (new_obj == NULL) return;
225 assert(Universe::heap()->can_elide_tlab_store_barriers(),
226 "compiler must check this first");
227 // GC may decide to give back a safer copy of new_obj.
228 new_obj = Universe::heap()->new_store_pre_barrier(thread, new_obj);
229 thread->set_vm_result(new_obj);
230 }
232 // object allocation
233 JRT_BLOCK_ENTRY(void, OptoRuntime::new_instance_C(Klass* klass, JavaThread* thread))
234 JRT_BLOCK;
235 #ifndef PRODUCT
236 SharedRuntime::_new_instance_ctr++; // new instance requires GC
237 #endif
238 assert(check_compiled_frame(thread), "incorrect caller");
240 // These checks are cheap to make and support reflective allocation.
241 int lh = klass->layout_helper();
242 if (Klass::layout_helper_needs_slow_path(lh) || !InstanceKlass::cast(klass)->is_initialized()) {
243 Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
244 klass->check_valid_for_instantiation(false, THREAD);
245 if (!HAS_PENDING_EXCEPTION) {
246 InstanceKlass::cast(klass)->initialize(THREAD);
247 }
248 }
250 if (!HAS_PENDING_EXCEPTION) {
251 // Scavenge and allocate an instance.
252 Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
253 oop result = InstanceKlass::cast(klass)->allocate_instance(THREAD);
254 thread->set_vm_result(result);
256 // Pass oops back through thread local storage. Our apparent type to Java
257 // is that we return an oop, but we can block on exit from this routine and
258 // a GC can trash the oop in C's return register. The generated stub will
259 // fetch the oop from TLS after any possible GC.
260 }
262 deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
263 JRT_BLOCK_END;
265 if (GraphKit::use_ReduceInitialCardMarks()) {
266 // inform GC that we won't do card marks for initializing writes.
267 new_store_pre_barrier(thread);
268 }
269 JRT_END
272 // array allocation
273 JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_C(Klass* array_type, int len, JavaThread *thread))
274 JRT_BLOCK;
275 #ifndef PRODUCT
276 SharedRuntime::_new_array_ctr++; // new array requires GC
277 #endif
278 assert(check_compiled_frame(thread), "incorrect caller");
280 // Scavenge and allocate an instance.
281 oop result;
283 if (array_type->oop_is_typeArray()) {
284 // The oopFactory likes to work with the element type.
285 // (We could bypass the oopFactory, since it doesn't add much value.)
286 BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
287 result = oopFactory::new_typeArray(elem_type, len, THREAD);
288 } else {
289 // Although the oopFactory likes to work with the elem_type,
290 // the compiler prefers the array_type, since it must already have
291 // that latter value in hand for the fast path.
292 Handle holder(THREAD, array_type->klass_holder()); // keep the array klass alive
293 Klass* elem_type = ObjArrayKlass::cast(array_type)->element_klass();
294 result = oopFactory::new_objArray(elem_type, len, THREAD);
295 }
297 // Pass oops back through thread local storage. Our apparent type to Java
298 // is that we return an oop, but we can block on exit from this routine and
299 // a GC can trash the oop in C's return register. The generated stub will
300 // fetch the oop from TLS after any possible GC.
301 deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
302 thread->set_vm_result(result);
303 JRT_BLOCK_END;
305 if (GraphKit::use_ReduceInitialCardMarks()) {
306 // inform GC that we won't do card marks for initializing writes.
307 new_store_pre_barrier(thread);
308 }
309 JRT_END
311 // array allocation without zeroing
312 JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_nozero_C(Klass* array_type, int len, JavaThread *thread))
313 JRT_BLOCK;
314 #ifndef PRODUCT
315 SharedRuntime::_new_array_ctr++; // new array requires GC
316 #endif
317 assert(check_compiled_frame(thread), "incorrect caller");
319 // Scavenge and allocate an instance.
320 oop result;
322 assert(array_type->oop_is_typeArray(), "should be called only for type array");
323 // The oopFactory likes to work with the element type.
324 BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
325 result = oopFactory::new_typeArray_nozero(elem_type, len, THREAD);
327 // Pass oops back through thread local storage. Our apparent type to Java
328 // is that we return an oop, but we can block on exit from this routine and
329 // a GC can trash the oop in C's return register. The generated stub will
330 // fetch the oop from TLS after any possible GC.
331 deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
332 thread->set_vm_result(result);
333 JRT_BLOCK_END;
335 if (GraphKit::use_ReduceInitialCardMarks()) {
336 // inform GC that we won't do card marks for initializing writes.
337 new_store_pre_barrier(thread);
338 }
340 oop result = thread->vm_result();
341 if ((len > 0) && (result != NULL) &&
342 is_deoptimized_caller_frame(thread)) {
343 // Zero array here if the caller is deoptimized.
344 int size = ((typeArrayOop)result)->object_size();
345 BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
346 const size_t hs = arrayOopDesc::header_size(elem_type);
347 // Align to next 8 bytes to avoid trashing arrays's length.
348 const size_t aligned_hs = align_object_offset(hs);
349 HeapWord* obj = (HeapWord*)result;
350 if (aligned_hs > hs) {
351 Copy::zero_to_words(obj+hs, aligned_hs-hs);
352 }
353 // Optimized zeroing.
354 Copy::fill_to_aligned_words(obj+aligned_hs, size-aligned_hs);
355 }
357 JRT_END
359 // Note: multianewarray for one dimension is handled inline by GraphKit::new_array.
361 // multianewarray for 2 dimensions
362 JRT_ENTRY(void, OptoRuntime::multianewarray2_C(Klass* elem_type, int len1, int len2, JavaThread *thread))
363 #ifndef PRODUCT
364 SharedRuntime::_multi2_ctr++; // multianewarray for 1 dimension
365 #endif
366 assert(check_compiled_frame(thread), "incorrect caller");
367 assert(elem_type->is_klass(), "not a class");
368 jint dims[2];
369 dims[0] = len1;
370 dims[1] = len2;
371 Handle holder(THREAD, elem_type->klass_holder()); // keep the klass alive
372 oop obj = ArrayKlass::cast(elem_type)->multi_allocate(2, dims, THREAD);
373 deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
374 thread->set_vm_result(obj);
375 JRT_END
377 // multianewarray for 3 dimensions
378 JRT_ENTRY(void, OptoRuntime::multianewarray3_C(Klass* elem_type, int len1, int len2, int len3, JavaThread *thread))
379 #ifndef PRODUCT
380 SharedRuntime::_multi3_ctr++; // multianewarray for 1 dimension
381 #endif
382 assert(check_compiled_frame(thread), "incorrect caller");
383 assert(elem_type->is_klass(), "not a class");
384 jint dims[3];
385 dims[0] = len1;
386 dims[1] = len2;
387 dims[2] = len3;
388 Handle holder(THREAD, elem_type->klass_holder()); // keep the klass alive
389 oop obj = ArrayKlass::cast(elem_type)->multi_allocate(3, dims, THREAD);
390 deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
391 thread->set_vm_result(obj);
392 JRT_END
394 // multianewarray for 4 dimensions
395 JRT_ENTRY(void, OptoRuntime::multianewarray4_C(Klass* elem_type, int len1, int len2, int len3, int len4, JavaThread *thread))
396 #ifndef PRODUCT
397 SharedRuntime::_multi4_ctr++; // multianewarray for 1 dimension
398 #endif
399 assert(check_compiled_frame(thread), "incorrect caller");
400 assert(elem_type->is_klass(), "not a class");
401 jint dims[4];
402 dims[0] = len1;
403 dims[1] = len2;
404 dims[2] = len3;
405 dims[3] = len4;
406 Handle holder(THREAD, elem_type->klass_holder()); // keep the klass alive
407 oop obj = ArrayKlass::cast(elem_type)->multi_allocate(4, dims, THREAD);
408 deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
409 thread->set_vm_result(obj);
410 JRT_END
412 // multianewarray for 5 dimensions
413 JRT_ENTRY(void, OptoRuntime::multianewarray5_C(Klass* elem_type, int len1, int len2, int len3, int len4, int len5, JavaThread *thread))
414 #ifndef PRODUCT
415 SharedRuntime::_multi5_ctr++; // multianewarray for 1 dimension
416 #endif
417 assert(check_compiled_frame(thread), "incorrect caller");
418 assert(elem_type->is_klass(), "not a class");
419 jint dims[5];
420 dims[0] = len1;
421 dims[1] = len2;
422 dims[2] = len3;
423 dims[3] = len4;
424 dims[4] = len5;
425 Handle holder(THREAD, elem_type->klass_holder()); // keep the klass alive
426 oop obj = ArrayKlass::cast(elem_type)->multi_allocate(5, dims, THREAD);
427 deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
428 thread->set_vm_result(obj);
429 JRT_END
431 JRT_ENTRY(void, OptoRuntime::multianewarrayN_C(Klass* elem_type, arrayOopDesc* dims, JavaThread *thread))
432 assert(check_compiled_frame(thread), "incorrect caller");
433 assert(elem_type->is_klass(), "not a class");
434 assert(oop(dims)->is_typeArray(), "not an array");
436 ResourceMark rm;
437 jint len = dims->length();
438 assert(len > 0, "Dimensions array should contain data");
439 jint *j_dims = typeArrayOop(dims)->int_at_addr(0);
440 jint *c_dims = NEW_RESOURCE_ARRAY(jint, len);
441 Copy::conjoint_jints_atomic(j_dims, c_dims, len);
443 Handle holder(THREAD, elem_type->klass_holder()); // keep the klass alive
444 oop obj = ArrayKlass::cast(elem_type)->multi_allocate(len, c_dims, THREAD);
445 deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
446 thread->set_vm_result(obj);
447 JRT_END
450 const TypeFunc *OptoRuntime::new_instance_Type() {
451 // create input type (domain)
452 const Type **fields = TypeTuple::fields(1);
453 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated
454 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
456 // create result type (range)
457 fields = TypeTuple::fields(1);
458 fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
460 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
462 return TypeFunc::make(domain, range);
463 }
466 const TypeFunc *OptoRuntime::athrow_Type() {
467 // create input type (domain)
468 const Type **fields = TypeTuple::fields(1);
469 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated
470 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
472 // create result type (range)
473 fields = TypeTuple::fields(0);
475 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
477 return TypeFunc::make(domain, range);
478 }
481 const TypeFunc *OptoRuntime::new_array_Type() {
482 // create input type (domain)
483 const Type **fields = TypeTuple::fields(2);
484 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // element klass
485 fields[TypeFunc::Parms+1] = TypeInt::INT; // array size
486 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
488 // create result type (range)
489 fields = TypeTuple::fields(1);
490 fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
492 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
494 return TypeFunc::make(domain, range);
495 }
497 const TypeFunc *OptoRuntime::multianewarray_Type(int ndim) {
498 // create input type (domain)
499 const int nargs = ndim + 1;
500 const Type **fields = TypeTuple::fields(nargs);
501 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // element klass
502 for( int i = 1; i < nargs; i++ )
503 fields[TypeFunc::Parms + i] = TypeInt::INT; // array size
504 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+nargs, fields);
506 // create result type (range)
507 fields = TypeTuple::fields(1);
508 fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
509 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
511 return TypeFunc::make(domain, range);
512 }
514 const TypeFunc *OptoRuntime::multianewarray2_Type() {
515 return multianewarray_Type(2);
516 }
518 const TypeFunc *OptoRuntime::multianewarray3_Type() {
519 return multianewarray_Type(3);
520 }
522 const TypeFunc *OptoRuntime::multianewarray4_Type() {
523 return multianewarray_Type(4);
524 }
526 const TypeFunc *OptoRuntime::multianewarray5_Type() {
527 return multianewarray_Type(5);
528 }
530 const TypeFunc *OptoRuntime::multianewarrayN_Type() {
531 // create input type (domain)
532 const Type **fields = TypeTuple::fields(2);
533 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // element klass
534 fields[TypeFunc::Parms+1] = TypeInstPtr::NOTNULL; // array of dim sizes
535 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
537 // create result type (range)
538 fields = TypeTuple::fields(1);
539 fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
540 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
542 return TypeFunc::make(domain, range);
543 }
545 const TypeFunc *OptoRuntime::g1_wb_pre_Type() {
546 const Type **fields = TypeTuple::fields(2);
547 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // original field value
548 fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL; // thread
549 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
551 // create result type (range)
552 fields = TypeTuple::fields(0);
553 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
555 return TypeFunc::make(domain, range);
556 }
558 const TypeFunc *OptoRuntime::g1_wb_post_Type() {
560 const Type **fields = TypeTuple::fields(2);
561 fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Card addr
562 fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL; // thread
563 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
565 // create result type (range)
566 fields = TypeTuple::fields(0);
567 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
569 return TypeFunc::make(domain, range);
570 }
572 const TypeFunc *OptoRuntime::uncommon_trap_Type() {
573 // create input type (domain)
574 const Type **fields = TypeTuple::fields(1);
575 // Symbol* name of class to be loaded
576 fields[TypeFunc::Parms+0] = TypeInt::INT;
577 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
579 // create result type (range)
580 fields = TypeTuple::fields(0);
581 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
583 return TypeFunc::make(domain, range);
584 }
586 # ifdef ENABLE_ZAP_DEAD_LOCALS
587 // Type used for stub generation for zap_dead_locals.
588 // No inputs or outputs
589 const TypeFunc *OptoRuntime::zap_dead_locals_Type() {
590 // create input type (domain)
591 const Type **fields = TypeTuple::fields(0);
592 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms,fields);
594 // create result type (range)
595 fields = TypeTuple::fields(0);
596 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms,fields);
598 return TypeFunc::make(domain,range);
599 }
600 # endif
603 //-----------------------------------------------------------------------------
604 // Monitor Handling
605 const TypeFunc *OptoRuntime::complete_monitor_enter_Type() {
606 // create input type (domain)
607 const Type **fields = TypeTuple::fields(2);
608 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked
609 fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // Address of stack location for lock
610 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
612 // create result type (range)
613 fields = TypeTuple::fields(0);
615 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
617 return TypeFunc::make(domain,range);
618 }
621 //-----------------------------------------------------------------------------
622 const TypeFunc *OptoRuntime::complete_monitor_exit_Type() {
623 // create input type (domain)
624 const Type **fields = TypeTuple::fields(2);
625 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked
626 fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // Address of stack location for lock
627 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
629 // create result type (range)
630 fields = TypeTuple::fields(0);
632 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
634 return TypeFunc::make(domain,range);
635 }
637 const TypeFunc* OptoRuntime::flush_windows_Type() {
638 // create input type (domain)
639 const Type** fields = TypeTuple::fields(1);
640 fields[TypeFunc::Parms+0] = NULL; // void
641 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms, fields);
643 // create result type
644 fields = TypeTuple::fields(1);
645 fields[TypeFunc::Parms+0] = NULL; // void
646 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
648 return TypeFunc::make(domain, range);
649 }
651 const TypeFunc* OptoRuntime::l2f_Type() {
652 // create input type (domain)
653 const Type **fields = TypeTuple::fields(2);
654 fields[TypeFunc::Parms+0] = TypeLong::LONG;
655 fields[TypeFunc::Parms+1] = Type::HALF;
656 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
658 // create result type (range)
659 fields = TypeTuple::fields(1);
660 fields[TypeFunc::Parms+0] = Type::FLOAT;
661 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
663 return TypeFunc::make(domain, range);
664 }
666 const TypeFunc* OptoRuntime::modf_Type() {
667 const Type **fields = TypeTuple::fields(2);
668 fields[TypeFunc::Parms+0] = Type::FLOAT;
669 fields[TypeFunc::Parms+1] = Type::FLOAT;
670 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
672 // create result type (range)
673 fields = TypeTuple::fields(1);
674 fields[TypeFunc::Parms+0] = Type::FLOAT;
676 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
678 return TypeFunc::make(domain, range);
679 }
681 const TypeFunc *OptoRuntime::Math_D_D_Type() {
682 // create input type (domain)
683 const Type **fields = TypeTuple::fields(2);
684 // Symbol* name of class to be loaded
685 fields[TypeFunc::Parms+0] = Type::DOUBLE;
686 fields[TypeFunc::Parms+1] = Type::HALF;
687 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
689 // create result type (range)
690 fields = TypeTuple::fields(2);
691 fields[TypeFunc::Parms+0] = Type::DOUBLE;
692 fields[TypeFunc::Parms+1] = Type::HALF;
693 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+2, fields);
695 return TypeFunc::make(domain, range);
696 }
698 const TypeFunc* OptoRuntime::Math_DD_D_Type() {
699 const Type **fields = TypeTuple::fields(4);
700 fields[TypeFunc::Parms+0] = Type::DOUBLE;
701 fields[TypeFunc::Parms+1] = Type::HALF;
702 fields[TypeFunc::Parms+2] = Type::DOUBLE;
703 fields[TypeFunc::Parms+3] = Type::HALF;
704 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+4, fields);
706 // create result type (range)
707 fields = TypeTuple::fields(2);
708 fields[TypeFunc::Parms+0] = Type::DOUBLE;
709 fields[TypeFunc::Parms+1] = Type::HALF;
710 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+2, fields);
712 return TypeFunc::make(domain, range);
713 }
715 //-------------- currentTimeMillis, currentTimeNanos, etc
717 const TypeFunc* OptoRuntime::void_long_Type() {
718 // create input type (domain)
719 const Type **fields = TypeTuple::fields(0);
720 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+0, fields);
722 // create result type (range)
723 fields = TypeTuple::fields(2);
724 fields[TypeFunc::Parms+0] = TypeLong::LONG;
725 fields[TypeFunc::Parms+1] = Type::HALF;
726 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+2, fields);
728 return TypeFunc::make(domain, range);
729 }
731 // arraycopy stub variations:
732 enum ArrayCopyType {
733 ac_fast, // void(ptr, ptr, size_t)
734 ac_checkcast, // int(ptr, ptr, size_t, size_t, ptr)
735 ac_slow, // void(ptr, int, ptr, int, int)
736 ac_generic // int(ptr, int, ptr, int, int)
737 };
739 static const TypeFunc* make_arraycopy_Type(ArrayCopyType act) {
740 // create input type (domain)
741 int num_args = (act == ac_fast ? 3 : 5);
742 int num_size_args = (act == ac_fast ? 1 : act == ac_checkcast ? 2 : 0);
743 int argcnt = num_args;
744 LP64_ONLY(argcnt += num_size_args); // halfwords for lengths
745 const Type** fields = TypeTuple::fields(argcnt);
746 int argp = TypeFunc::Parms;
747 fields[argp++] = TypePtr::NOTNULL; // src
748 if (num_size_args == 0) {
749 fields[argp++] = TypeInt::INT; // src_pos
750 }
751 fields[argp++] = TypePtr::NOTNULL; // dest
752 if (num_size_args == 0) {
753 fields[argp++] = TypeInt::INT; // dest_pos
754 fields[argp++] = TypeInt::INT; // length
755 }
756 while (num_size_args-- > 0) {
757 fields[argp++] = TypeX_X; // size in whatevers (size_t)
758 LP64_ONLY(fields[argp++] = Type::HALF); // other half of long length
759 }
760 if (act == ac_checkcast) {
761 fields[argp++] = TypePtr::NOTNULL; // super_klass
762 }
763 assert(argp == TypeFunc::Parms+argcnt, "correct decoding of act");
764 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
766 // create result type if needed
767 int retcnt = (act == ac_checkcast || act == ac_generic ? 1 : 0);
768 fields = TypeTuple::fields(1);
769 if (retcnt == 0)
770 fields[TypeFunc::Parms+0] = NULL; // void
771 else
772 fields[TypeFunc::Parms+0] = TypeInt::INT; // status result, if needed
773 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+retcnt, fields);
774 return TypeFunc::make(domain, range);
775 }
777 const TypeFunc* OptoRuntime::fast_arraycopy_Type() {
778 // This signature is simple: Two base pointers and a size_t.
779 return make_arraycopy_Type(ac_fast);
780 }
782 const TypeFunc* OptoRuntime::checkcast_arraycopy_Type() {
783 // An extension of fast_arraycopy_Type which adds type checking.
784 return make_arraycopy_Type(ac_checkcast);
785 }
787 const TypeFunc* OptoRuntime::slow_arraycopy_Type() {
788 // This signature is exactly the same as System.arraycopy.
789 // There are no intptr_t (int/long) arguments.
790 return make_arraycopy_Type(ac_slow);
791 }
793 const TypeFunc* OptoRuntime::generic_arraycopy_Type() {
794 // This signature is like System.arraycopy, except that it returns status.
795 return make_arraycopy_Type(ac_generic);
796 }
799 const TypeFunc* OptoRuntime::array_fill_Type() {
800 const Type** fields;
801 int argp = TypeFunc::Parms;
802 if (CCallingConventionRequiresIntsAsLongs) {
803 // create input type (domain): pointer, int, size_t
804 fields = TypeTuple::fields(3 LP64_ONLY( + 2));
805 fields[argp++] = TypePtr::NOTNULL;
806 fields[argp++] = TypeLong::LONG;
807 fields[argp++] = Type::HALF;
808 } else {
809 // create input type (domain): pointer, int, size_t
810 fields = TypeTuple::fields(3 LP64_ONLY( + 1));
811 fields[argp++] = TypePtr::NOTNULL;
812 fields[argp++] = TypeInt::INT;
813 }
814 fields[argp++] = TypeX_X; // size in whatevers (size_t)
815 LP64_ONLY(fields[argp++] = Type::HALF); // other half of long length
816 const TypeTuple *domain = TypeTuple::make(argp, fields);
818 // create result type
819 fields = TypeTuple::fields(1);
820 fields[TypeFunc::Parms+0] = NULL; // void
821 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
823 return TypeFunc::make(domain, range);
824 }
826 // for aescrypt encrypt/decrypt operations, just three pointers returning void (length is constant)
827 const TypeFunc* OptoRuntime::aescrypt_block_Type() {
828 // create input type (domain)
829 int num_args = 3;
830 if (Matcher::pass_original_key_for_aes()) {
831 num_args = 4;
832 }
833 int argcnt = num_args;
834 const Type** fields = TypeTuple::fields(argcnt);
835 int argp = TypeFunc::Parms;
836 fields[argp++] = TypePtr::NOTNULL; // src
837 fields[argp++] = TypePtr::NOTNULL; // dest
838 fields[argp++] = TypePtr::NOTNULL; // k array
839 if (Matcher::pass_original_key_for_aes()) {
840 fields[argp++] = TypePtr::NOTNULL; // original k array
841 }
842 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
843 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
845 // no result type needed
846 fields = TypeTuple::fields(1);
847 fields[TypeFunc::Parms+0] = NULL; // void
848 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
849 return TypeFunc::make(domain, range);
850 }
852 /**
853 * int updateBytesCRC32(int crc, byte* b, int len)
854 */
855 const TypeFunc* OptoRuntime::updateBytesCRC32_Type() {
856 // create input type (domain)
857 int num_args = 3;
858 int argcnt = num_args;
859 if (CCallingConventionRequiresIntsAsLongs) {
860 argcnt += 2;
861 }
862 const Type** fields = TypeTuple::fields(argcnt);
863 int argp = TypeFunc::Parms;
864 if (CCallingConventionRequiresIntsAsLongs) {
865 fields[argp++] = TypeLong::LONG; // crc
866 fields[argp++] = Type::HALF;
867 fields[argp++] = TypePtr::NOTNULL; // src
868 fields[argp++] = TypeLong::LONG; // len
869 fields[argp++] = Type::HALF;
870 } else {
871 fields[argp++] = TypeInt::INT; // crc
872 fields[argp++] = TypePtr::NOTNULL; // src
873 fields[argp++] = TypeInt::INT; // len
874 }
875 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
876 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
878 // result type needed
879 fields = TypeTuple::fields(1);
880 fields[TypeFunc::Parms+0] = TypeInt::INT; // crc result
881 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
882 return TypeFunc::make(domain, range);
883 }
885 // for cipherBlockChaining calls of aescrypt encrypt/decrypt, four pointers and a length, returning int
886 const TypeFunc* OptoRuntime::cipherBlockChaining_aescrypt_Type() {
887 // create input type (domain)
888 int num_args = 5;
889 if (Matcher::pass_original_key_for_aes()) {
890 num_args = 6;
891 }
892 int argcnt = num_args;
893 const Type** fields = TypeTuple::fields(argcnt);
894 int argp = TypeFunc::Parms;
895 fields[argp++] = TypePtr::NOTNULL; // src
896 fields[argp++] = TypePtr::NOTNULL; // dest
897 fields[argp++] = TypePtr::NOTNULL; // k array
898 fields[argp++] = TypePtr::NOTNULL; // r array
899 fields[argp++] = TypeInt::INT; // src len
900 if (Matcher::pass_original_key_for_aes()) {
901 fields[argp++] = TypePtr::NOTNULL; // original k array
902 }
903 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
904 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
906 // returning cipher len (int)
907 fields = TypeTuple::fields(1);
908 fields[TypeFunc::Parms+0] = TypeInt::INT;
909 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
910 return TypeFunc::make(domain, range);
911 }
913 /*
914 * void implCompress(byte[] buf, int ofs)
915 */
916 const TypeFunc* OptoRuntime::sha_implCompress_Type() {
917 // create input type (domain)
918 int num_args = 2;
919 int argcnt = num_args;
920 const Type** fields = TypeTuple::fields(argcnt);
921 int argp = TypeFunc::Parms;
922 fields[argp++] = TypePtr::NOTNULL; // buf
923 fields[argp++] = TypePtr::NOTNULL; // state
924 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
925 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
927 // no result type needed
928 fields = TypeTuple::fields(1);
929 fields[TypeFunc::Parms+0] = NULL; // void
930 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
931 return TypeFunc::make(domain, range);
932 }
934 /*
935 * int implCompressMultiBlock(byte[] b, int ofs, int limit)
936 */
937 const TypeFunc* OptoRuntime::digestBase_implCompressMB_Type() {
938 // create input type (domain)
939 int num_args = 4;
940 int argcnt = num_args;
941 if(CCallingConventionRequiresIntsAsLongs) {
942 argcnt += 2;
943 }
944 const Type** fields = TypeTuple::fields(argcnt);
945 int argp = TypeFunc::Parms;
946 if(CCallingConventionRequiresIntsAsLongs) {
947 fields[argp++] = TypePtr::NOTNULL; // buf
948 fields[argp++] = TypePtr::NOTNULL; // state
949 fields[argp++] = TypeLong::LONG; // ofs
950 fields[argp++] = Type::HALF;
951 fields[argp++] = TypeLong::LONG; // limit
952 fields[argp++] = Type::HALF;
953 } else {
954 fields[argp++] = TypePtr::NOTNULL; // buf
955 fields[argp++] = TypePtr::NOTNULL; // state
956 fields[argp++] = TypeInt::INT; // ofs
957 fields[argp++] = TypeInt::INT; // limit
958 }
959 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
960 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
962 // returning ofs (int)
963 fields = TypeTuple::fields(1);
964 fields[TypeFunc::Parms+0] = TypeInt::INT; // ofs
965 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
966 return TypeFunc::make(domain, range);
967 }
969 const TypeFunc* OptoRuntime::multiplyToLen_Type() {
970 // create input type (domain)
971 int num_args = 6;
972 int argcnt = num_args;
973 const Type** fields = TypeTuple::fields(argcnt);
974 int argp = TypeFunc::Parms;
975 fields[argp++] = TypePtr::NOTNULL; // x
976 fields[argp++] = TypeInt::INT; // xlen
977 fields[argp++] = TypePtr::NOTNULL; // y
978 fields[argp++] = TypeInt::INT; // ylen
979 fields[argp++] = TypePtr::NOTNULL; // z
980 fields[argp++] = TypeInt::INT; // zlen
981 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
982 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
984 // no result type needed
985 fields = TypeTuple::fields(1);
986 fields[TypeFunc::Parms+0] = NULL;
987 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
988 return TypeFunc::make(domain, range);
989 }
991 const TypeFunc* OptoRuntime::squareToLen_Type() {
992 // create input type (domain)
993 int num_args = 4;
994 int argcnt = num_args;
995 const Type** fields = TypeTuple::fields(argcnt);
996 int argp = TypeFunc::Parms;
997 fields[argp++] = TypePtr::NOTNULL; // x
998 fields[argp++] = TypeInt::INT; // len
999 fields[argp++] = TypePtr::NOTNULL; // z
1000 fields[argp++] = TypeInt::INT; // zlen
1001 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1002 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1004 // no result type needed
1005 fields = TypeTuple::fields(1);
1006 fields[TypeFunc::Parms+0] = NULL;
1007 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
1008 return TypeFunc::make(domain, range);
1009 }
1011 // for mulAdd calls, 2 pointers and 3 ints, returning int
1012 const TypeFunc* OptoRuntime::mulAdd_Type() {
1013 // create input type (domain)
1014 int num_args = 5;
1015 int argcnt = num_args;
1016 const Type** fields = TypeTuple::fields(argcnt);
1017 int argp = TypeFunc::Parms;
1018 fields[argp++] = TypePtr::NOTNULL; // out
1019 fields[argp++] = TypePtr::NOTNULL; // in
1020 fields[argp++] = TypeInt::INT; // offset
1021 fields[argp++] = TypeInt::INT; // len
1022 fields[argp++] = TypeInt::INT; // k
1023 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1024 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1026 // returning carry (int)
1027 fields = TypeTuple::fields(1);
1028 fields[TypeFunc::Parms+0] = TypeInt::INT;
1029 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
1030 return TypeFunc::make(domain, range);
1031 }
1033 const TypeFunc* OptoRuntime::montgomeryMultiply_Type() {
1034 // create input type (domain)
1035 int num_args = 7;
1036 int argcnt = num_args;
1037 if (CCallingConventionRequiresIntsAsLongs) {
1038 argcnt++; // additional placeholder
1039 }
1040 const Type** fields = TypeTuple::fields(argcnt);
1041 int argp = TypeFunc::Parms;
1042 fields[argp++] = TypePtr::NOTNULL; // a
1043 fields[argp++] = TypePtr::NOTNULL; // b
1044 fields[argp++] = TypePtr::NOTNULL; // n
1045 if (CCallingConventionRequiresIntsAsLongs) {
1046 fields[argp++] = TypeLong::LONG; // len
1047 fields[argp++] = TypeLong::HALF; // placeholder
1048 } else {
1049 fields[argp++] = TypeInt::INT; // len
1050 }
1051 fields[argp++] = TypeLong::LONG; // inv
1052 fields[argp++] = Type::HALF;
1053 fields[argp++] = TypePtr::NOTNULL; // result
1054 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1055 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1057 // result type needed
1058 fields = TypeTuple::fields(1);
1059 fields[TypeFunc::Parms+0] = TypePtr::NOTNULL;
1061 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
1062 return TypeFunc::make(domain, range);
1063 }
1065 const TypeFunc* OptoRuntime::montgomerySquare_Type() {
1066 // create input type (domain)
1067 int num_args = 6;
1068 int argcnt = num_args;
1069 if (CCallingConventionRequiresIntsAsLongs) {
1070 argcnt++; // additional placeholder
1071 }
1072 const Type** fields = TypeTuple::fields(argcnt);
1073 int argp = TypeFunc::Parms;
1074 fields[argp++] = TypePtr::NOTNULL; // a
1075 fields[argp++] = TypePtr::NOTNULL; // n
1076 if (CCallingConventionRequiresIntsAsLongs) {
1077 fields[argp++] = TypeLong::LONG; // len
1078 fields[argp++] = TypeLong::HALF; // placeholder
1079 } else {
1080 fields[argp++] = TypeInt::INT; // len
1081 }
1082 fields[argp++] = TypeLong::LONG; // inv
1083 fields[argp++] = Type::HALF;
1084 fields[argp++] = TypePtr::NOTNULL; // result
1085 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1086 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1088 // result type needed
1089 fields = TypeTuple::fields(1);
1090 fields[TypeFunc::Parms+0] = TypePtr::NOTNULL;
1092 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
1093 return TypeFunc::make(domain, range);
1094 }
1097 //------------- Interpreter state access for on stack replacement
1098 const TypeFunc* OptoRuntime::osr_end_Type() {
1099 // create input type (domain)
1100 const Type **fields = TypeTuple::fields(1);
1101 fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // OSR temp buf
1102 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
1104 // create result type
1105 fields = TypeTuple::fields(1);
1106 // fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // locked oop
1107 fields[TypeFunc::Parms+0] = NULL; // void
1108 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
1109 return TypeFunc::make(domain, range);
1110 }
1112 //-------------- methodData update helpers
1114 const TypeFunc* OptoRuntime::profile_receiver_type_Type() {
1115 // create input type (domain)
1116 const Type **fields = TypeTuple::fields(2);
1117 fields[TypeFunc::Parms+0] = TypeAryPtr::NOTNULL; // methodData pointer
1118 fields[TypeFunc::Parms+1] = TypeInstPtr::BOTTOM; // receiver oop
1119 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
1121 // create result type
1122 fields = TypeTuple::fields(1);
1123 fields[TypeFunc::Parms+0] = NULL; // void
1124 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
1125 return TypeFunc::make(domain,range);
1126 }
1128 JRT_LEAF(void, OptoRuntime::profile_receiver_type_C(DataLayout* data, oopDesc* receiver))
1129 if (receiver == NULL) return;
1130 Klass* receiver_klass = receiver->klass();
1132 intptr_t* mdp = ((intptr_t*)(data)) + DataLayout::header_size_in_cells();
1133 int empty_row = -1; // free row, if any is encountered
1135 // ReceiverTypeData* vc = new ReceiverTypeData(mdp);
1136 for (uint row = 0; row < ReceiverTypeData::row_limit(); row++) {
1137 // if (vc->receiver(row) == receiver_klass)
1138 int receiver_off = ReceiverTypeData::receiver_cell_index(row);
1139 intptr_t row_recv = *(mdp + receiver_off);
1140 if (row_recv == (intptr_t) receiver_klass) {
1141 // vc->set_receiver_count(row, vc->receiver_count(row) + DataLayout::counter_increment);
1142 int count_off = ReceiverTypeData::receiver_count_cell_index(row);
1143 *(mdp + count_off) += DataLayout::counter_increment;
1144 return;
1145 } else if (row_recv == 0) {
1146 // else if (vc->receiver(row) == NULL)
1147 empty_row = (int) row;
1148 }
1149 }
1151 if (empty_row != -1) {
1152 int receiver_off = ReceiverTypeData::receiver_cell_index(empty_row);
1153 // vc->set_receiver(empty_row, receiver_klass);
1154 *(mdp + receiver_off) = (intptr_t) receiver_klass;
1155 // vc->set_receiver_count(empty_row, DataLayout::counter_increment);
1156 int count_off = ReceiverTypeData::receiver_count_cell_index(empty_row);
1157 *(mdp + count_off) = DataLayout::counter_increment;
1158 } else {
1159 // Receiver did not match any saved receiver and there is no empty row for it.
1160 // Increment total counter to indicate polymorphic case.
1161 intptr_t* count_p = (intptr_t*)(((byte*)(data)) + in_bytes(CounterData::count_offset()));
1162 *count_p += DataLayout::counter_increment;
1163 }
1164 JRT_END
1166 //-------------------------------------------------------------------------------------
1167 // register policy
1169 bool OptoRuntime::is_callee_saved_register(MachRegisterNumbers reg) {
1170 assert(reg >= 0 && reg < _last_Mach_Reg, "must be a machine register");
1171 switch (register_save_policy[reg]) {
1172 case 'C': return false; //SOC
1173 case 'E': return true ; //SOE
1174 case 'N': return false; //NS
1175 case 'A': return false; //AS
1176 }
1177 ShouldNotReachHere();
1178 return false;
1179 }
1181 //-----------------------------------------------------------------------
1182 // Exceptions
1183 //
1185 static void trace_exception(oop exception_oop, address exception_pc, const char* msg) PRODUCT_RETURN;
1187 // The method is an entry that is always called by a C++ method not
1188 // directly from compiled code. Compiled code will call the C++ method following.
1189 // We can't allow async exception to be installed during exception processing.
1190 JRT_ENTRY_NO_ASYNC(address, OptoRuntime::handle_exception_C_helper(JavaThread* thread, nmethod* &nm))
1192 // Do not confuse exception_oop with pending_exception. The exception_oop
1193 // is only used to pass arguments into the method. Not for general
1194 // exception handling. DO NOT CHANGE IT to use pending_exception, since
1195 // the runtime stubs checks this on exit.
1196 assert(thread->exception_oop() != NULL, "exception oop is found");
1197 address handler_address = NULL;
1199 Handle exception(thread, thread->exception_oop());
1200 address pc = thread->exception_pc();
1202 // Clear out the exception oop and pc since looking up an
1203 // exception handler can cause class loading, which might throw an
1204 // exception and those fields are expected to be clear during
1205 // normal bytecode execution.
1206 thread->clear_exception_oop_and_pc();
1208 if (TraceExceptions) {
1209 trace_exception(exception(), pc, "");
1210 }
1212 // for AbortVMOnException flag
1213 NOT_PRODUCT(Exceptions::debug_check_abort(exception));
1215 #ifdef ASSERT
1216 if (!(exception->is_a(SystemDictionary::Throwable_klass()))) {
1217 // should throw an exception here
1218 ShouldNotReachHere();
1219 }
1220 #endif
1222 // new exception handling: this method is entered only from adapters
1223 // exceptions from compiled java methods are handled in compiled code
1224 // using rethrow node
1226 nm = CodeCache::find_nmethod(pc);
1227 assert(nm != NULL, "No NMethod found");
1228 if (nm->is_native_method()) {
1229 fatal("Native method should not have path to exception handling");
1230 } else {
1231 // we are switching to old paradigm: search for exception handler in caller_frame
1232 // instead in exception handler of caller_frame.sender()
1234 if (JvmtiExport::can_post_on_exceptions()) {
1235 // "Full-speed catching" is not necessary here,
1236 // since we're notifying the VM on every catch.
1237 // Force deoptimization and the rest of the lookup
1238 // will be fine.
1239 deoptimize_caller_frame(thread);
1240 }
1242 // Check the stack guard pages. If enabled, look for handler in this frame;
1243 // otherwise, forcibly unwind the frame.
1244 //
1245 // 4826555: use default current sp for reguard_stack instead of &nm: it's more accurate.
1246 bool force_unwind = !thread->reguard_stack();
1247 bool deopting = false;
1248 if (nm->is_deopt_pc(pc)) {
1249 deopting = true;
1250 RegisterMap map(thread, false);
1251 frame deoptee = thread->last_frame().sender(&map);
1252 assert(deoptee.is_deoptimized_frame(), "must be deopted");
1253 // Adjust the pc back to the original throwing pc
1254 pc = deoptee.pc();
1255 }
1257 // If we are forcing an unwind because of stack overflow then deopt is
1258 // irrelevant since we are throwing the frame away anyway.
1260 if (deopting && !force_unwind) {
1261 handler_address = SharedRuntime::deopt_blob()->unpack_with_exception();
1262 } else {
1264 handler_address =
1265 force_unwind ? NULL : nm->handler_for_exception_and_pc(exception, pc);
1267 if (handler_address == NULL) {
1268 bool recursive_exception = false;
1269 handler_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true, recursive_exception);
1270 assert (handler_address != NULL, "must have compiled handler");
1271 // Update the exception cache only when the unwind was not forced
1272 // and there didn't happen another exception during the computation of the
1273 // compiled exception handler. Checking for exception oop equality is not
1274 // sufficient because some exceptions are pre-allocated and reused.
1275 if (!force_unwind && !recursive_exception) {
1276 nm->add_handler_for_exception_and_pc(exception,pc,handler_address);
1277 }
1278 } else {
1279 #ifdef ASSERT
1280 bool recursive_exception = false;
1281 address computed_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true, recursive_exception);
1282 assert(recursive_exception || (handler_address == computed_address), err_msg("Handler address inconsistency: " PTR_FORMAT " != " PTR_FORMAT,
1283 p2i(handler_address), p2i(computed_address)));
1284 #endif
1285 }
1286 }
1288 thread->set_exception_pc(pc);
1289 thread->set_exception_handler_pc(handler_address);
1291 // Check if the exception PC is a MethodHandle call site.
1292 thread->set_is_method_handle_return(nm->is_method_handle_return(pc));
1293 }
1295 // Restore correct return pc. Was saved above.
1296 thread->set_exception_oop(exception());
1297 return handler_address;
1299 JRT_END
1301 // We are entering here from exception_blob
1302 // If there is a compiled exception handler in this method, we will continue there;
1303 // otherwise we will unwind the stack and continue at the caller of top frame method
1304 // Note we enter without the usual JRT wrapper. We will call a helper routine that
1305 // will do the normal VM entry. We do it this way so that we can see if the nmethod
1306 // we looked up the handler for has been deoptimized in the meantime. If it has been
1307 // we must not use the handler and instead return the deopt blob.
1308 address OptoRuntime::handle_exception_C(JavaThread* thread) {
1309 //
1310 // We are in Java not VM and in debug mode we have a NoHandleMark
1311 //
1312 #ifndef PRODUCT
1313 SharedRuntime::_find_handler_ctr++; // find exception handler
1314 #endif
1315 debug_only(NoHandleMark __hm;)
1316 nmethod* nm = NULL;
1317 address handler_address = NULL;
1318 {
1319 // Enter the VM
1321 ResetNoHandleMark rnhm;
1322 handler_address = handle_exception_C_helper(thread, nm);
1323 }
1325 // Back in java: Use no oops, DON'T safepoint
1327 // Now check to see if the handler we are returning is in a now
1328 // deoptimized frame
1330 if (nm != NULL) {
1331 RegisterMap map(thread, false);
1332 frame caller = thread->last_frame().sender(&map);
1333 #ifdef ASSERT
1334 assert(caller.is_compiled_frame(), "must be");
1335 #endif // ASSERT
1336 if (caller.is_deoptimized_frame()) {
1337 handler_address = SharedRuntime::deopt_blob()->unpack_with_exception();
1338 }
1339 }
1340 return handler_address;
1341 }
1343 //------------------------------rethrow----------------------------------------
1344 // We get here after compiled code has executed a 'RethrowNode'. The callee
1345 // is either throwing or rethrowing an exception. The callee-save registers
1346 // have been restored, synchronized objects have been unlocked and the callee
1347 // stack frame has been removed. The return address was passed in.
1348 // Exception oop is passed as the 1st argument. This routine is then called
1349 // from the stub. On exit, we know where to jump in the caller's code.
1350 // After this C code exits, the stub will pop his frame and end in a jump
1351 // (instead of a return). We enter the caller's default handler.
1352 //
1353 // This must be JRT_LEAF:
1354 // - caller will not change its state as we cannot block on exit,
1355 // therefore raw_exception_handler_for_return_address is all it takes
1356 // to handle deoptimized blobs
1357 //
1358 // However, there needs to be a safepoint check in the middle! So compiled
1359 // safepoints are completely watertight.
1360 //
1361 // Thus, it cannot be a leaf since it contains the No_GC_Verifier.
1362 //
1363 // *THIS IS NOT RECOMMENDED PROGRAMMING STYLE*
1364 //
1365 address OptoRuntime::rethrow_C(oopDesc* exception, JavaThread* thread, address ret_pc) {
1366 #ifndef PRODUCT
1367 SharedRuntime::_rethrow_ctr++; // count rethrows
1368 #endif
1369 assert (exception != NULL, "should have thrown a NULLPointerException");
1370 #ifdef ASSERT
1371 if (!(exception->is_a(SystemDictionary::Throwable_klass()))) {
1372 // should throw an exception here
1373 ShouldNotReachHere();
1374 }
1375 #endif
1377 thread->set_vm_result(exception);
1378 // Frame not compiled (handles deoptimization blob)
1379 return SharedRuntime::raw_exception_handler_for_return_address(thread, ret_pc);
1380 }
1383 const TypeFunc *OptoRuntime::rethrow_Type() {
1384 // create input type (domain)
1385 const Type **fields = TypeTuple::fields(1);
1386 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Exception oop
1387 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1,fields);
1389 // create result type (range)
1390 fields = TypeTuple::fields(1);
1391 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Exception oop
1392 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
1394 return TypeFunc::make(domain, range);
1395 }
1398 void OptoRuntime::deoptimize_caller_frame(JavaThread *thread, bool doit) {
1399 // Deoptimize the caller before continuing, as the compiled
1400 // exception handler table may not be valid.
1401 if (!StressCompiledExceptionHandlers && doit) {
1402 deoptimize_caller_frame(thread);
1403 }
1404 }
1406 void OptoRuntime::deoptimize_caller_frame(JavaThread *thread) {
1407 // Called from within the owner thread, so no need for safepoint
1408 RegisterMap reg_map(thread);
1409 frame stub_frame = thread->last_frame();
1410 assert(stub_frame.is_runtime_frame() || exception_blob()->contains(stub_frame.pc()), "sanity check");
1411 frame caller_frame = stub_frame.sender(®_map);
1413 // Deoptimize the caller frame.
1414 Deoptimization::deoptimize_frame(thread, caller_frame.id());
1415 }
1418 bool OptoRuntime::is_deoptimized_caller_frame(JavaThread *thread) {
1419 // Called from within the owner thread, so no need for safepoint
1420 RegisterMap reg_map(thread);
1421 frame stub_frame = thread->last_frame();
1422 assert(stub_frame.is_runtime_frame() || exception_blob()->contains(stub_frame.pc()), "sanity check");
1423 frame caller_frame = stub_frame.sender(®_map);
1424 return caller_frame.is_deoptimized_frame();
1425 }
1428 const TypeFunc *OptoRuntime::register_finalizer_Type() {
1429 // create input type (domain)
1430 const Type **fields = TypeTuple::fields(1);
1431 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // oop; Receiver
1432 // // The JavaThread* is passed to each routine as the last argument
1433 // fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL; // JavaThread *; Executing thread
1434 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1,fields);
1436 // create result type (range)
1437 fields = TypeTuple::fields(0);
1439 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
1441 return TypeFunc::make(domain,range);
1442 }
1445 //-----------------------------------------------------------------------------
1446 // Dtrace support. entry and exit probes have the same signature
1447 const TypeFunc *OptoRuntime::dtrace_method_entry_exit_Type() {
1448 // create input type (domain)
1449 const Type **fields = TypeTuple::fields(2);
1450 fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage
1451 fields[TypeFunc::Parms+1] = TypeMetadataPtr::BOTTOM; // Method*; Method we are entering
1452 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
1454 // create result type (range)
1455 fields = TypeTuple::fields(0);
1457 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
1459 return TypeFunc::make(domain,range);
1460 }
1462 const TypeFunc *OptoRuntime::dtrace_object_alloc_Type() {
1463 // create input type (domain)
1464 const Type **fields = TypeTuple::fields(2);
1465 fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage
1466 fields[TypeFunc::Parms+1] = TypeInstPtr::NOTNULL; // oop; newly allocated object
1468 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
1470 // create result type (range)
1471 fields = TypeTuple::fields(0);
1473 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
1475 return TypeFunc::make(domain,range);
1476 }
1479 JRT_ENTRY_NO_ASYNC(void, OptoRuntime::register_finalizer(oopDesc* obj, JavaThread* thread))
1480 assert(obj->is_oop(), "must be a valid oop");
1481 assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise");
1482 InstanceKlass::register_finalizer(instanceOop(obj), CHECK);
1483 JRT_END
1485 //-----------------------------------------------------------------------------
1487 NamedCounter * volatile OptoRuntime::_named_counters = NULL;
1489 //
1490 // dump the collected NamedCounters.
1491 //
1492 void OptoRuntime::print_named_counters() {
1493 int total_lock_count = 0;
1494 int eliminated_lock_count = 0;
1496 NamedCounter* c = _named_counters;
1497 while (c) {
1498 if (c->tag() == NamedCounter::LockCounter || c->tag() == NamedCounter::EliminatedLockCounter) {
1499 int count = c->count();
1500 if (count > 0) {
1501 bool eliminated = c->tag() == NamedCounter::EliminatedLockCounter;
1502 if (Verbose) {
1503 tty->print_cr("%d %s%s", count, c->name(), eliminated ? " (eliminated)" : "");
1504 }
1505 total_lock_count += count;
1506 if (eliminated) {
1507 eliminated_lock_count += count;
1508 }
1509 }
1510 } else if (c->tag() == NamedCounter::BiasedLockingCounter) {
1511 BiasedLockingCounters* blc = ((BiasedLockingNamedCounter*)c)->counters();
1512 if (blc->nonzero()) {
1513 tty->print_cr("%s", c->name());
1514 blc->print_on(tty);
1515 }
1516 #if INCLUDE_RTM_OPT
1517 } else if (c->tag() == NamedCounter::RTMLockingCounter) {
1518 RTMLockingCounters* rlc = ((RTMLockingNamedCounter*)c)->counters();
1519 if (rlc->nonzero()) {
1520 tty->print_cr("%s", c->name());
1521 rlc->print_on(tty);
1522 }
1523 #endif
1524 }
1525 c = c->next();
1526 }
1527 if (total_lock_count > 0) {
1528 tty->print_cr("dynamic locks: %d", total_lock_count);
1529 if (eliminated_lock_count) {
1530 tty->print_cr("eliminated locks: %d (%d%%)", eliminated_lock_count,
1531 (int)(eliminated_lock_count * 100.0 / total_lock_count));
1532 }
1533 }
1534 }
1536 //
1537 // Allocate a new NamedCounter. The JVMState is used to generate the
1538 // name which consists of method@line for the inlining tree.
1539 //
1541 NamedCounter* OptoRuntime::new_named_counter(JVMState* youngest_jvms, NamedCounter::CounterTag tag) {
1542 int max_depth = youngest_jvms->depth();
1544 // Visit scopes from youngest to oldest.
1545 bool first = true;
1546 stringStream st;
1547 for (int depth = max_depth; depth >= 1; depth--) {
1548 JVMState* jvms = youngest_jvms->of_depth(depth);
1549 ciMethod* m = jvms->has_method() ? jvms->method() : NULL;
1550 if (!first) {
1551 st.print(" ");
1552 } else {
1553 first = false;
1554 }
1555 int bci = jvms->bci();
1556 if (bci < 0) bci = 0;
1557 st.print("%s.%s@%d", m->holder()->name()->as_utf8(), m->name()->as_utf8(), bci);
1558 // To print linenumbers instead of bci use: m->line_number_from_bci(bci)
1559 }
1560 NamedCounter* c;
1561 if (tag == NamedCounter::BiasedLockingCounter) {
1562 c = new BiasedLockingNamedCounter(strdup(st.as_string()));
1563 } else if (tag == NamedCounter::RTMLockingCounter) {
1564 c = new RTMLockingNamedCounter(strdup(st.as_string()));
1565 } else {
1566 c = new NamedCounter(strdup(st.as_string()), tag);
1567 }
1569 // atomically add the new counter to the head of the list. We only
1570 // add counters so this is safe.
1571 NamedCounter* head;
1572 do {
1573 c->set_next(NULL);
1574 head = _named_counters;
1575 c->set_next(head);
1576 } while (Atomic::cmpxchg_ptr(c, &_named_counters, head) != head);
1577 return c;
1578 }
1580 //-----------------------------------------------------------------------------
1581 // Non-product code
1582 #ifndef PRODUCT
1584 int trace_exception_counter = 0;
1585 static void trace_exception(oop exception_oop, address exception_pc, const char* msg) {
1586 ttyLocker ttyl;
1587 trace_exception_counter++;
1588 tty->print("%d [Exception (%s): ", trace_exception_counter, msg);
1589 exception_oop->print_value();
1590 tty->print(" in ");
1591 CodeBlob* blob = CodeCache::find_blob(exception_pc);
1592 if (blob->is_nmethod()) {
1593 nmethod* nm = blob->as_nmethod_or_null();
1594 nm->method()->print_value();
1595 } else if (blob->is_runtime_stub()) {
1596 tty->print("<runtime-stub>");
1597 } else {
1598 tty->print("<unknown>");
1599 }
1600 tty->print(" at " INTPTR_FORMAT, p2i(exception_pc));
1601 tty->print_cr("]");
1602 }
1604 #endif // PRODUCT
1607 # ifdef ENABLE_ZAP_DEAD_LOCALS
1608 // Called from call sites in compiled code with oop maps (actually safepoints)
1609 // Zaps dead locals in first java frame.
1610 // Is entry because may need to lock to generate oop maps
1611 // Currently, only used for compiler frames, but someday may be used
1612 // for interpreter frames, too.
1614 int OptoRuntime::ZapDeadCompiledLocals_count = 0;
1616 // avoid pointers to member funcs with these helpers
1617 static bool is_java_frame( frame* f) { return f->is_java_frame(); }
1618 static bool is_native_frame(frame* f) { return f->is_native_frame(); }
1621 void OptoRuntime::zap_dead_java_or_native_locals(JavaThread* thread,
1622 bool (*is_this_the_right_frame_to_zap)(frame*)) {
1623 assert(JavaThread::current() == thread, "is this needed?");
1625 if ( !ZapDeadCompiledLocals ) return;
1627 bool skip = false;
1629 if ( ZapDeadCompiledLocalsFirst == 0 ) ; // nothing special
1630 else if ( ZapDeadCompiledLocalsFirst > ZapDeadCompiledLocals_count ) skip = true;
1631 else if ( ZapDeadCompiledLocalsFirst == ZapDeadCompiledLocals_count )
1632 warning("starting zapping after skipping");
1634 if ( ZapDeadCompiledLocalsLast == -1 ) ; // nothing special
1635 else if ( ZapDeadCompiledLocalsLast < ZapDeadCompiledLocals_count ) skip = true;
1636 else if ( ZapDeadCompiledLocalsLast == ZapDeadCompiledLocals_count )
1637 warning("about to zap last zap");
1639 ++ZapDeadCompiledLocals_count; // counts skipped zaps, too
1641 if ( skip ) return;
1643 // find java frame and zap it
1645 for (StackFrameStream sfs(thread); !sfs.is_done(); sfs.next()) {
1646 if (is_this_the_right_frame_to_zap(sfs.current()) ) {
1647 sfs.current()->zap_dead_locals(thread, sfs.register_map());
1648 return;
1649 }
1650 }
1651 warning("no frame found to zap in zap_dead_Java_locals_C");
1652 }
1654 JRT_LEAF(void, OptoRuntime::zap_dead_Java_locals_C(JavaThread* thread))
1655 zap_dead_java_or_native_locals(thread, is_java_frame);
1656 JRT_END
1658 // The following does not work because for one thing, the
1659 // thread state is wrong; it expects java, but it is native.
1660 // Also, the invariants in a native stub are different and
1661 // I'm not sure it is safe to have a MachCalRuntimeDirectNode
1662 // in there.
1663 // So for now, we do not zap in native stubs.
1665 JRT_LEAF(void, OptoRuntime::zap_dead_native_locals_C(JavaThread* thread))
1666 zap_dead_java_or_native_locals(thread, is_native_frame);
1667 JRT_END
1669 # endif