Sat, 07 Nov 2020 10:30:02 +0800
Added tag mips-jdk8u275-b01 for changeset d3b4d62f391f
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
103 // GHASH block processing
104 const TypeFunc* OptoRuntime::ghash_processBlocks_Type() {
105 int argcnt = 4;
107 const Type** fields = TypeTuple::fields(argcnt);
108 int argp = TypeFunc::Parms;
109 fields[argp++] = TypePtr::NOTNULL; // state
110 fields[argp++] = TypePtr::NOTNULL; // subkeyH
111 fields[argp++] = TypePtr::NOTNULL; // data
112 fields[argp++] = TypeInt::INT; // blocks
113 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
114 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
116 // result type needed
117 fields = TypeTuple::fields(1);
118 fields[TypeFunc::Parms+0] = NULL; // void
119 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
120 return TypeFunc::make(domain, range);
121 }
123 // Compiled code entry points
124 address OptoRuntime::_new_instance_Java = NULL;
125 address OptoRuntime::_new_array_Java = NULL;
126 address OptoRuntime::_new_array_nozero_Java = NULL;
127 address OptoRuntime::_multianewarray2_Java = NULL;
128 address OptoRuntime::_multianewarray3_Java = NULL;
129 address OptoRuntime::_multianewarray4_Java = NULL;
130 address OptoRuntime::_multianewarray5_Java = NULL;
131 address OptoRuntime::_multianewarrayN_Java = NULL;
132 address OptoRuntime::_g1_wb_pre_Java = NULL;
133 address OptoRuntime::_g1_wb_post_Java = NULL;
134 address OptoRuntime::_vtable_must_compile_Java = NULL;
135 address OptoRuntime::_complete_monitor_locking_Java = NULL;
136 address OptoRuntime::_rethrow_Java = NULL;
138 address OptoRuntime::_slow_arraycopy_Java = NULL;
139 address OptoRuntime::_register_finalizer_Java = NULL;
141 # ifdef ENABLE_ZAP_DEAD_LOCALS
142 address OptoRuntime::_zap_dead_Java_locals_Java = NULL;
143 address OptoRuntime::_zap_dead_native_locals_Java = NULL;
144 # endif
146 ExceptionBlob* OptoRuntime::_exception_blob;
148 // This should be called in an assertion at the start of OptoRuntime routines
149 // which are entered from compiled code (all of them)
150 #ifdef ASSERT
151 static bool check_compiled_frame(JavaThread* thread) {
152 assert(thread->last_frame().is_runtime_frame(), "cannot call runtime directly from compiled code");
153 RegisterMap map(thread, false);
154 frame caller = thread->last_frame().sender(&map);
155 assert(caller.is_compiled_frame(), "not being called from compiled like code");
156 return true;
157 }
158 #endif // ASSERT
161 #define gen(env, var, type_func_gen, c_func, fancy_jump, pass_tls, save_arg_regs, return_pc) \
162 var = generate_stub(env, type_func_gen, CAST_FROM_FN_PTR(address, c_func), #var, fancy_jump, pass_tls, save_arg_regs, return_pc); \
163 if (var == NULL) { return false; }
165 bool OptoRuntime::generate(ciEnv* env) {
167 generate_exception_blob();
169 // Note: tls: Means fetching the return oop out of the thread-local storage
170 //
171 // variable/name type-function-gen , runtime method ,fncy_jp, tls,save_args,retpc
172 // -------------------------------------------------------------------------------------------------------------------------------
173 gen(env, _new_instance_Java , new_instance_Type , new_instance_C , 0 , true , false, false);
174 gen(env, _new_array_Java , new_array_Type , new_array_C , 0 , true , false, false);
175 gen(env, _new_array_nozero_Java , new_array_Type , new_array_nozero_C , 0 , true , false, false);
176 gen(env, _multianewarray2_Java , multianewarray2_Type , multianewarray2_C , 0 , true , false, false);
177 gen(env, _multianewarray3_Java , multianewarray3_Type , multianewarray3_C , 0 , true , false, false);
178 gen(env, _multianewarray4_Java , multianewarray4_Type , multianewarray4_C , 0 , true , false, false);
179 gen(env, _multianewarray5_Java , multianewarray5_Type , multianewarray5_C , 0 , true , false, false);
180 gen(env, _multianewarrayN_Java , multianewarrayN_Type , multianewarrayN_C , 0 , true , false, false);
181 gen(env, _g1_wb_pre_Java , g1_wb_pre_Type , SharedRuntime::g1_wb_pre , 0 , false, false, false);
182 gen(env, _g1_wb_post_Java , g1_wb_post_Type , SharedRuntime::g1_wb_post , 0 , false, false, false);
183 gen(env, _complete_monitor_locking_Java , complete_monitor_enter_Type , SharedRuntime::complete_monitor_locking_C, 0, false, false, false);
184 gen(env, _rethrow_Java , rethrow_Type , rethrow_C , 2 , true , false, true );
186 gen(env, _slow_arraycopy_Java , slow_arraycopy_Type , SharedRuntime::slow_arraycopy_C , 0 , false, false, false);
187 gen(env, _register_finalizer_Java , register_finalizer_Type , register_finalizer , 0 , false, false, false);
189 # ifdef ENABLE_ZAP_DEAD_LOCALS
190 gen(env, _zap_dead_Java_locals_Java , zap_dead_locals_Type , zap_dead_Java_locals_C , 0 , false, true , false );
191 gen(env, _zap_dead_native_locals_Java , zap_dead_locals_Type , zap_dead_native_locals_C , 0 , false, true , false );
192 # endif
193 return true;
194 }
196 #undef gen
199 // Helper method to do generation of RunTimeStub's
200 address OptoRuntime::generate_stub( ciEnv* env,
201 TypeFunc_generator gen, address C_function,
202 const char *name, int is_fancy_jump,
203 bool pass_tls,
204 bool save_argument_registers,
205 bool return_pc ) {
206 ResourceMark rm;
207 Compile C( env, gen, C_function, name, is_fancy_jump, pass_tls, save_argument_registers, return_pc );
208 return C.stub_entry_point();
209 }
211 const char* OptoRuntime::stub_name(address entry) {
212 #ifndef PRODUCT
213 CodeBlob* cb = CodeCache::find_blob(entry);
214 RuntimeStub* rs =(RuntimeStub *)cb;
215 assert(rs != NULL && rs->is_runtime_stub(), "not a runtime stub");
216 return rs->name();
217 #else
218 // Fast implementation for product mode (maybe it should be inlined too)
219 return "runtime stub";
220 #endif
221 }
224 //=============================================================================
225 // Opto compiler runtime routines
226 //=============================================================================
229 //=============================allocation======================================
230 // We failed the fast-path allocation. Now we need to do a scavenge or GC
231 // and try allocation again.
233 void OptoRuntime::new_store_pre_barrier(JavaThread* thread) {
234 // After any safepoint, just before going back to compiled code,
235 // we inform the GC that we will be doing initializing writes to
236 // this object in the future without emitting card-marks, so
237 // GC may take any compensating steps.
238 // NOTE: Keep this code consistent with GraphKit::store_barrier.
240 oop new_obj = thread->vm_result();
241 if (new_obj == NULL) return;
243 assert(Universe::heap()->can_elide_tlab_store_barriers(),
244 "compiler must check this first");
245 // GC may decide to give back a safer copy of new_obj.
246 new_obj = Universe::heap()->new_store_pre_barrier(thread, new_obj);
247 thread->set_vm_result(new_obj);
248 }
250 // object allocation
251 JRT_BLOCK_ENTRY(void, OptoRuntime::new_instance_C(Klass* klass, JavaThread* thread))
252 JRT_BLOCK;
253 #ifndef PRODUCT
254 SharedRuntime::_new_instance_ctr++; // new instance requires GC
255 #endif
256 assert(check_compiled_frame(thread), "incorrect caller");
258 // These checks are cheap to make and support reflective allocation.
259 int lh = klass->layout_helper();
260 if (Klass::layout_helper_needs_slow_path(lh) || !InstanceKlass::cast(klass)->is_initialized()) {
261 Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
262 klass->check_valid_for_instantiation(false, THREAD);
263 if (!HAS_PENDING_EXCEPTION) {
264 InstanceKlass::cast(klass)->initialize(THREAD);
265 }
266 }
268 if (!HAS_PENDING_EXCEPTION) {
269 // Scavenge and allocate an instance.
270 Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
271 oop result = InstanceKlass::cast(klass)->allocate_instance(THREAD);
272 thread->set_vm_result(result);
274 // Pass oops back through thread local storage. Our apparent type to Java
275 // is that we return an oop, but we can block on exit from this routine and
276 // a GC can trash the oop in C's return register. The generated stub will
277 // fetch the oop from TLS after any possible GC.
278 }
280 deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
281 JRT_BLOCK_END;
283 if (GraphKit::use_ReduceInitialCardMarks()) {
284 // inform GC that we won't do card marks for initializing writes.
285 new_store_pre_barrier(thread);
286 }
287 JRT_END
290 // array allocation
291 JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_C(Klass* array_type, int len, JavaThread *thread))
292 JRT_BLOCK;
293 #ifndef PRODUCT
294 SharedRuntime::_new_array_ctr++; // new array requires GC
295 #endif
296 assert(check_compiled_frame(thread), "incorrect caller");
298 // Scavenge and allocate an instance.
299 oop result;
301 if (array_type->oop_is_typeArray()) {
302 // The oopFactory likes to work with the element type.
303 // (We could bypass the oopFactory, since it doesn't add much value.)
304 BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
305 result = oopFactory::new_typeArray(elem_type, len, THREAD);
306 } else {
307 // Although the oopFactory likes to work with the elem_type,
308 // the compiler prefers the array_type, since it must already have
309 // that latter value in hand for the fast path.
310 Handle holder(THREAD, array_type->klass_holder()); // keep the array klass alive
311 Klass* elem_type = ObjArrayKlass::cast(array_type)->element_klass();
312 result = oopFactory::new_objArray(elem_type, len, THREAD);
313 }
315 // Pass oops back through thread local storage. Our apparent type to Java
316 // is that we return an oop, but we can block on exit from this routine and
317 // a GC can trash the oop in C's return register. The generated stub will
318 // fetch the oop from TLS after any possible GC.
319 deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
320 thread->set_vm_result(result);
321 JRT_BLOCK_END;
323 if (GraphKit::use_ReduceInitialCardMarks()) {
324 // inform GC that we won't do card marks for initializing writes.
325 new_store_pre_barrier(thread);
326 }
327 JRT_END
329 // array allocation without zeroing
330 JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_nozero_C(Klass* array_type, int len, JavaThread *thread))
331 JRT_BLOCK;
332 #ifndef PRODUCT
333 SharedRuntime::_new_array_ctr++; // new array requires GC
334 #endif
335 assert(check_compiled_frame(thread), "incorrect caller");
337 // Scavenge and allocate an instance.
338 oop result;
340 assert(array_type->oop_is_typeArray(), "should be called only for type array");
341 // The oopFactory likes to work with the element type.
342 BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
343 result = oopFactory::new_typeArray_nozero(elem_type, len, THREAD);
345 // Pass oops back through thread local storage. Our apparent type to Java
346 // is that we return an oop, but we can block on exit from this routine and
347 // a GC can trash the oop in C's return register. The generated stub will
348 // fetch the oop from TLS after any possible GC.
349 deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
350 thread->set_vm_result(result);
351 JRT_BLOCK_END;
353 if (GraphKit::use_ReduceInitialCardMarks()) {
354 // inform GC that we won't do card marks for initializing writes.
355 new_store_pre_barrier(thread);
356 }
358 oop result = thread->vm_result();
359 if ((len > 0) && (result != NULL) &&
360 is_deoptimized_caller_frame(thread)) {
361 // Zero array here if the caller is deoptimized.
362 int size = ((typeArrayOop)result)->object_size();
363 BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
364 const size_t hs = arrayOopDesc::header_size(elem_type);
365 // Align to next 8 bytes to avoid trashing arrays's length.
366 const size_t aligned_hs = align_object_offset(hs);
367 HeapWord* obj = (HeapWord*)result;
368 if (aligned_hs > hs) {
369 Copy::zero_to_words(obj+hs, aligned_hs-hs);
370 }
371 // Optimized zeroing.
372 Copy::fill_to_aligned_words(obj+aligned_hs, size-aligned_hs);
373 }
375 JRT_END
377 // Note: multianewarray for one dimension is handled inline by GraphKit::new_array.
379 // multianewarray for 2 dimensions
380 JRT_ENTRY(void, OptoRuntime::multianewarray2_C(Klass* elem_type, int len1, int len2, JavaThread *thread))
381 #ifndef PRODUCT
382 SharedRuntime::_multi2_ctr++; // multianewarray for 1 dimension
383 #endif
384 assert(check_compiled_frame(thread), "incorrect caller");
385 assert(elem_type->is_klass(), "not a class");
386 jint dims[2];
387 dims[0] = len1;
388 dims[1] = len2;
389 Handle holder(THREAD, elem_type->klass_holder()); // keep the klass alive
390 oop obj = ArrayKlass::cast(elem_type)->multi_allocate(2, dims, THREAD);
391 deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
392 thread->set_vm_result(obj);
393 JRT_END
395 // multianewarray for 3 dimensions
396 JRT_ENTRY(void, OptoRuntime::multianewarray3_C(Klass* elem_type, int len1, int len2, int len3, JavaThread *thread))
397 #ifndef PRODUCT
398 SharedRuntime::_multi3_ctr++; // multianewarray for 1 dimension
399 #endif
400 assert(check_compiled_frame(thread), "incorrect caller");
401 assert(elem_type->is_klass(), "not a class");
402 jint dims[3];
403 dims[0] = len1;
404 dims[1] = len2;
405 dims[2] = len3;
406 Handle holder(THREAD, elem_type->klass_holder()); // keep the klass alive
407 oop obj = ArrayKlass::cast(elem_type)->multi_allocate(3, dims, THREAD);
408 deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
409 thread->set_vm_result(obj);
410 JRT_END
412 // multianewarray for 4 dimensions
413 JRT_ENTRY(void, OptoRuntime::multianewarray4_C(Klass* elem_type, int len1, int len2, int len3, int len4, JavaThread *thread))
414 #ifndef PRODUCT
415 SharedRuntime::_multi4_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[4];
420 dims[0] = len1;
421 dims[1] = len2;
422 dims[2] = len3;
423 dims[3] = len4;
424 Handle holder(THREAD, elem_type->klass_holder()); // keep the klass alive
425 oop obj = ArrayKlass::cast(elem_type)->multi_allocate(4, dims, THREAD);
426 deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
427 thread->set_vm_result(obj);
428 JRT_END
430 // multianewarray for 5 dimensions
431 JRT_ENTRY(void, OptoRuntime::multianewarray5_C(Klass* elem_type, int len1, int len2, int len3, int len4, int len5, JavaThread *thread))
432 #ifndef PRODUCT
433 SharedRuntime::_multi5_ctr++; // multianewarray for 1 dimension
434 #endif
435 assert(check_compiled_frame(thread), "incorrect caller");
436 assert(elem_type->is_klass(), "not a class");
437 jint dims[5];
438 dims[0] = len1;
439 dims[1] = len2;
440 dims[2] = len3;
441 dims[3] = len4;
442 dims[4] = len5;
443 Handle holder(THREAD, elem_type->klass_holder()); // keep the klass alive
444 oop obj = ArrayKlass::cast(elem_type)->multi_allocate(5, dims, THREAD);
445 deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
446 thread->set_vm_result(obj);
447 JRT_END
449 JRT_ENTRY(void, OptoRuntime::multianewarrayN_C(Klass* elem_type, arrayOopDesc* dims, JavaThread *thread))
450 assert(check_compiled_frame(thread), "incorrect caller");
451 assert(elem_type->is_klass(), "not a class");
452 assert(oop(dims)->is_typeArray(), "not an array");
454 ResourceMark rm;
455 jint len = dims->length();
456 assert(len > 0, "Dimensions array should contain data");
457 jint *j_dims = typeArrayOop(dims)->int_at_addr(0);
458 jint *c_dims = NEW_RESOURCE_ARRAY(jint, len);
459 Copy::conjoint_jints_atomic(j_dims, c_dims, len);
461 Handle holder(THREAD, elem_type->klass_holder()); // keep the klass alive
462 oop obj = ArrayKlass::cast(elem_type)->multi_allocate(len, c_dims, THREAD);
463 deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
464 thread->set_vm_result(obj);
465 JRT_END
468 const TypeFunc *OptoRuntime::new_instance_Type() {
469 // create input type (domain)
470 const Type **fields = TypeTuple::fields(1);
471 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated
472 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
474 // create result type (range)
475 fields = TypeTuple::fields(1);
476 fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
478 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
480 return TypeFunc::make(domain, range);
481 }
484 const TypeFunc *OptoRuntime::athrow_Type() {
485 // create input type (domain)
486 const Type **fields = TypeTuple::fields(1);
487 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Klass to be allocated
488 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
490 // create result type (range)
491 fields = TypeTuple::fields(0);
493 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
495 return TypeFunc::make(domain, range);
496 }
499 const TypeFunc *OptoRuntime::new_array_Type() {
500 // create input type (domain)
501 const Type **fields = TypeTuple::fields(2);
502 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // element klass
503 fields[TypeFunc::Parms+1] = TypeInt::INT; // array size
504 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
506 // create result type (range)
507 fields = TypeTuple::fields(1);
508 fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
510 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
512 return TypeFunc::make(domain, range);
513 }
515 const TypeFunc *OptoRuntime::multianewarray_Type(int ndim) {
516 // create input type (domain)
517 const int nargs = ndim + 1;
518 const Type **fields = TypeTuple::fields(nargs);
519 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // element klass
520 for( int i = 1; i < nargs; i++ )
521 fields[TypeFunc::Parms + i] = TypeInt::INT; // array size
522 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+nargs, fields);
524 // create result type (range)
525 fields = TypeTuple::fields(1);
526 fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
527 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
529 return TypeFunc::make(domain, range);
530 }
532 const TypeFunc *OptoRuntime::multianewarray2_Type() {
533 return multianewarray_Type(2);
534 }
536 const TypeFunc *OptoRuntime::multianewarray3_Type() {
537 return multianewarray_Type(3);
538 }
540 const TypeFunc *OptoRuntime::multianewarray4_Type() {
541 return multianewarray_Type(4);
542 }
544 const TypeFunc *OptoRuntime::multianewarray5_Type() {
545 return multianewarray_Type(5);
546 }
548 const TypeFunc *OptoRuntime::multianewarrayN_Type() {
549 // create input type (domain)
550 const Type **fields = TypeTuple::fields(2);
551 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // element klass
552 fields[TypeFunc::Parms+1] = TypeInstPtr::NOTNULL; // array of dim sizes
553 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
555 // create result type (range)
556 fields = TypeTuple::fields(1);
557 fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Returned oop
558 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
560 return TypeFunc::make(domain, range);
561 }
563 const TypeFunc *OptoRuntime::g1_wb_pre_Type() {
564 const Type **fields = TypeTuple::fields(2);
565 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // original field value
566 fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL; // thread
567 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
569 // create result type (range)
570 fields = TypeTuple::fields(0);
571 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
573 return TypeFunc::make(domain, range);
574 }
576 const TypeFunc *OptoRuntime::g1_wb_post_Type() {
578 const Type **fields = TypeTuple::fields(2);
579 fields[TypeFunc::Parms+0] = TypeRawPtr::NOTNULL; // Card addr
580 fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL; // thread
581 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
583 // create result type (range)
584 fields = TypeTuple::fields(0);
585 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
587 return TypeFunc::make(domain, range);
588 }
590 const TypeFunc *OptoRuntime::uncommon_trap_Type() {
591 // create input type (domain)
592 const Type **fields = TypeTuple::fields(1);
593 // Symbol* name of class to be loaded
594 fields[TypeFunc::Parms+0] = TypeInt::INT;
595 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
597 // create result type (range)
598 fields = TypeTuple::fields(0);
599 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0, fields);
601 return TypeFunc::make(domain, range);
602 }
604 # ifdef ENABLE_ZAP_DEAD_LOCALS
605 // Type used for stub generation for zap_dead_locals.
606 // No inputs or outputs
607 const TypeFunc *OptoRuntime::zap_dead_locals_Type() {
608 // create input type (domain)
609 const Type **fields = TypeTuple::fields(0);
610 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms,fields);
612 // create result type (range)
613 fields = TypeTuple::fields(0);
614 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms,fields);
616 return TypeFunc::make(domain,range);
617 }
618 # endif
621 //-----------------------------------------------------------------------------
622 // Monitor Handling
623 const TypeFunc *OptoRuntime::complete_monitor_enter_Type() {
624 // create input type (domain)
625 const Type **fields = TypeTuple::fields(2);
626 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked
627 fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // Address of stack location for lock
628 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
630 // create result type (range)
631 fields = TypeTuple::fields(0);
633 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
635 return TypeFunc::make(domain,range);
636 }
639 //-----------------------------------------------------------------------------
640 const TypeFunc *OptoRuntime::complete_monitor_exit_Type() {
641 // create input type (domain)
642 const Type **fields = TypeTuple::fields(2);
643 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Object to be Locked
644 fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // Address of stack location for lock
645 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
647 // create result type (range)
648 fields = TypeTuple::fields(0);
650 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
652 return TypeFunc::make(domain,range);
653 }
655 const TypeFunc* OptoRuntime::flush_windows_Type() {
656 // create input type (domain)
657 const Type** fields = TypeTuple::fields(1);
658 fields[TypeFunc::Parms+0] = NULL; // void
659 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms, fields);
661 // create result type
662 fields = TypeTuple::fields(1);
663 fields[TypeFunc::Parms+0] = NULL; // void
664 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
666 return TypeFunc::make(domain, range);
667 }
669 const TypeFunc* OptoRuntime::l2f_Type() {
670 // create input type (domain)
671 const Type **fields = TypeTuple::fields(2);
672 fields[TypeFunc::Parms+0] = TypeLong::LONG;
673 fields[TypeFunc::Parms+1] = Type::HALF;
674 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
676 // create result type (range)
677 fields = TypeTuple::fields(1);
678 fields[TypeFunc::Parms+0] = Type::FLOAT;
679 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
681 return TypeFunc::make(domain, range);
682 }
684 const TypeFunc* OptoRuntime::modf_Type() {
685 const Type **fields = TypeTuple::fields(2);
686 fields[TypeFunc::Parms+0] = Type::FLOAT;
687 fields[TypeFunc::Parms+1] = Type::FLOAT;
688 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
690 // create result type (range)
691 fields = TypeTuple::fields(1);
692 fields[TypeFunc::Parms+0] = Type::FLOAT;
694 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
696 return TypeFunc::make(domain, range);
697 }
699 const TypeFunc *OptoRuntime::Math_D_D_Type() {
700 // create input type (domain)
701 const Type **fields = TypeTuple::fields(2);
702 // Symbol* name of class to be loaded
703 fields[TypeFunc::Parms+0] = Type::DOUBLE;
704 fields[TypeFunc::Parms+1] = Type::HALF;
705 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
707 // create result type (range)
708 fields = TypeTuple::fields(2);
709 fields[TypeFunc::Parms+0] = Type::DOUBLE;
710 fields[TypeFunc::Parms+1] = Type::HALF;
711 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+2, fields);
713 return TypeFunc::make(domain, range);
714 }
716 const TypeFunc* OptoRuntime::Math_DD_D_Type() {
717 const Type **fields = TypeTuple::fields(4);
718 fields[TypeFunc::Parms+0] = Type::DOUBLE;
719 fields[TypeFunc::Parms+1] = Type::HALF;
720 fields[TypeFunc::Parms+2] = Type::DOUBLE;
721 fields[TypeFunc::Parms+3] = Type::HALF;
722 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+4, fields);
724 // create result type (range)
725 fields = TypeTuple::fields(2);
726 fields[TypeFunc::Parms+0] = Type::DOUBLE;
727 fields[TypeFunc::Parms+1] = Type::HALF;
728 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+2, fields);
730 return TypeFunc::make(domain, range);
731 }
733 //-------------- currentTimeMillis, currentTimeNanos, etc
735 const TypeFunc* OptoRuntime::void_long_Type() {
736 // create input type (domain)
737 const Type **fields = TypeTuple::fields(0);
738 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+0, fields);
740 // create result type (range)
741 fields = TypeTuple::fields(2);
742 fields[TypeFunc::Parms+0] = TypeLong::LONG;
743 fields[TypeFunc::Parms+1] = Type::HALF;
744 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+2, fields);
746 return TypeFunc::make(domain, range);
747 }
749 // arraycopy stub variations:
750 enum ArrayCopyType {
751 ac_fast, // void(ptr, ptr, size_t)
752 ac_checkcast, // int(ptr, ptr, size_t, size_t, ptr)
753 ac_slow, // void(ptr, int, ptr, int, int)
754 ac_generic // int(ptr, int, ptr, int, int)
755 };
757 static const TypeFunc* make_arraycopy_Type(ArrayCopyType act) {
758 // create input type (domain)
759 int num_args = (act == ac_fast ? 3 : 5);
760 int num_size_args = (act == ac_fast ? 1 : act == ac_checkcast ? 2 : 0);
761 int argcnt = num_args;
762 LP64_ONLY(argcnt += num_size_args); // halfwords for lengths
763 const Type** fields = TypeTuple::fields(argcnt);
764 int argp = TypeFunc::Parms;
765 fields[argp++] = TypePtr::NOTNULL; // src
766 if (num_size_args == 0) {
767 fields[argp++] = TypeInt::INT; // src_pos
768 }
769 fields[argp++] = TypePtr::NOTNULL; // dest
770 if (num_size_args == 0) {
771 fields[argp++] = TypeInt::INT; // dest_pos
772 fields[argp++] = TypeInt::INT; // length
773 }
774 while (num_size_args-- > 0) {
775 fields[argp++] = TypeX_X; // size in whatevers (size_t)
776 LP64_ONLY(fields[argp++] = Type::HALF); // other half of long length
777 }
778 if (act == ac_checkcast) {
779 fields[argp++] = TypePtr::NOTNULL; // super_klass
780 }
781 assert(argp == TypeFunc::Parms+argcnt, "correct decoding of act");
782 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
784 // create result type if needed
785 int retcnt = (act == ac_checkcast || act == ac_generic ? 1 : 0);
786 fields = TypeTuple::fields(1);
787 if (retcnt == 0)
788 fields[TypeFunc::Parms+0] = NULL; // void
789 else
790 fields[TypeFunc::Parms+0] = TypeInt::INT; // status result, if needed
791 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+retcnt, fields);
792 return TypeFunc::make(domain, range);
793 }
795 const TypeFunc* OptoRuntime::fast_arraycopy_Type() {
796 // This signature is simple: Two base pointers and a size_t.
797 return make_arraycopy_Type(ac_fast);
798 }
800 const TypeFunc* OptoRuntime::checkcast_arraycopy_Type() {
801 // An extension of fast_arraycopy_Type which adds type checking.
802 return make_arraycopy_Type(ac_checkcast);
803 }
805 const TypeFunc* OptoRuntime::slow_arraycopy_Type() {
806 // This signature is exactly the same as System.arraycopy.
807 // There are no intptr_t (int/long) arguments.
808 return make_arraycopy_Type(ac_slow);
809 }
811 const TypeFunc* OptoRuntime::generic_arraycopy_Type() {
812 // This signature is like System.arraycopy, except that it returns status.
813 return make_arraycopy_Type(ac_generic);
814 }
817 const TypeFunc* OptoRuntime::array_fill_Type() {
818 const Type** fields;
819 int argp = TypeFunc::Parms;
820 if (CCallingConventionRequiresIntsAsLongs) {
821 // create input type (domain): pointer, int, size_t
822 fields = TypeTuple::fields(3 LP64_ONLY( + 2));
823 fields[argp++] = TypePtr::NOTNULL;
824 fields[argp++] = TypeLong::LONG;
825 fields[argp++] = Type::HALF;
826 } else {
827 // create input type (domain): pointer, int, size_t
828 fields = TypeTuple::fields(3 LP64_ONLY( + 1));
829 fields[argp++] = TypePtr::NOTNULL;
830 fields[argp++] = TypeInt::INT;
831 }
832 fields[argp++] = TypeX_X; // size in whatevers (size_t)
833 LP64_ONLY(fields[argp++] = Type::HALF); // other half of long length
834 const TypeTuple *domain = TypeTuple::make(argp, fields);
836 // create result type
837 fields = TypeTuple::fields(1);
838 fields[TypeFunc::Parms+0] = NULL; // void
839 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
841 return TypeFunc::make(domain, range);
842 }
844 // for aescrypt encrypt/decrypt operations, just three pointers returning void (length is constant)
845 const TypeFunc* OptoRuntime::aescrypt_block_Type() {
846 // create input type (domain)
847 int num_args = 3;
848 if (Matcher::pass_original_key_for_aes()) {
849 num_args = 4;
850 }
851 int argcnt = num_args;
852 const Type** fields = TypeTuple::fields(argcnt);
853 int argp = TypeFunc::Parms;
854 fields[argp++] = TypePtr::NOTNULL; // src
855 fields[argp++] = TypePtr::NOTNULL; // dest
856 fields[argp++] = TypePtr::NOTNULL; // k array
857 if (Matcher::pass_original_key_for_aes()) {
858 fields[argp++] = TypePtr::NOTNULL; // original k array
859 }
860 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
861 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
863 // no result type needed
864 fields = TypeTuple::fields(1);
865 fields[TypeFunc::Parms+0] = NULL; // void
866 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
867 return TypeFunc::make(domain, range);
868 }
870 /**
871 * int updateBytesCRC32(int crc, byte* b, int len)
872 */
873 const TypeFunc* OptoRuntime::updateBytesCRC32_Type() {
874 // create input type (domain)
875 int num_args = 3;
876 int argcnt = num_args;
877 if (CCallingConventionRequiresIntsAsLongs) {
878 argcnt += 2;
879 }
880 const Type** fields = TypeTuple::fields(argcnt);
881 int argp = TypeFunc::Parms;
882 if (CCallingConventionRequiresIntsAsLongs) {
883 fields[argp++] = TypeLong::LONG; // crc
884 fields[argp++] = Type::HALF;
885 fields[argp++] = TypePtr::NOTNULL; // src
886 fields[argp++] = TypeLong::LONG; // len
887 fields[argp++] = Type::HALF;
888 } else {
889 fields[argp++] = TypeInt::INT; // crc
890 fields[argp++] = TypePtr::NOTNULL; // src
891 fields[argp++] = TypeInt::INT; // len
892 }
893 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
894 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
896 // result type needed
897 fields = TypeTuple::fields(1);
898 fields[TypeFunc::Parms+0] = TypeInt::INT; // crc result
899 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
900 return TypeFunc::make(domain, range);
901 }
903 // for cipherBlockChaining calls of aescrypt encrypt/decrypt, four pointers and a length, returning int
904 const TypeFunc* OptoRuntime::cipherBlockChaining_aescrypt_Type() {
905 // create input type (domain)
906 int num_args = 5;
907 if (Matcher::pass_original_key_for_aes()) {
908 num_args = 6;
909 }
910 int argcnt = num_args;
911 const Type** fields = TypeTuple::fields(argcnt);
912 int argp = TypeFunc::Parms;
913 fields[argp++] = TypePtr::NOTNULL; // src
914 fields[argp++] = TypePtr::NOTNULL; // dest
915 fields[argp++] = TypePtr::NOTNULL; // k array
916 fields[argp++] = TypePtr::NOTNULL; // r array
917 fields[argp++] = TypeInt::INT; // src len
918 if (Matcher::pass_original_key_for_aes()) {
919 fields[argp++] = TypePtr::NOTNULL; // original k array
920 }
921 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
922 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
924 // returning cipher len (int)
925 fields = TypeTuple::fields(1);
926 fields[TypeFunc::Parms+0] = TypeInt::INT;
927 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
928 return TypeFunc::make(domain, range);
929 }
931 /*
932 * void implCompress(byte[] buf, int ofs)
933 */
934 const TypeFunc* OptoRuntime::sha_implCompress_Type() {
935 // create input type (domain)
936 int num_args = 2;
937 int argcnt = num_args;
938 const Type** fields = TypeTuple::fields(argcnt);
939 int argp = TypeFunc::Parms;
940 fields[argp++] = TypePtr::NOTNULL; // buf
941 fields[argp++] = TypePtr::NOTNULL; // state
942 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
943 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
945 // no result type needed
946 fields = TypeTuple::fields(1);
947 fields[TypeFunc::Parms+0] = NULL; // void
948 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
949 return TypeFunc::make(domain, range);
950 }
952 /*
953 * int implCompressMultiBlock(byte[] b, int ofs, int limit)
954 */
955 const TypeFunc* OptoRuntime::digestBase_implCompressMB_Type() {
956 // create input type (domain)
957 int num_args = 4;
958 int argcnt = num_args;
959 if(CCallingConventionRequiresIntsAsLongs) {
960 argcnt += 2;
961 }
962 const Type** fields = TypeTuple::fields(argcnt);
963 int argp = TypeFunc::Parms;
964 if(CCallingConventionRequiresIntsAsLongs) {
965 fields[argp++] = TypePtr::NOTNULL; // buf
966 fields[argp++] = TypePtr::NOTNULL; // state
967 fields[argp++] = TypeLong::LONG; // ofs
968 fields[argp++] = Type::HALF;
969 fields[argp++] = TypeLong::LONG; // limit
970 fields[argp++] = Type::HALF;
971 } else {
972 fields[argp++] = TypePtr::NOTNULL; // buf
973 fields[argp++] = TypePtr::NOTNULL; // state
974 fields[argp++] = TypeInt::INT; // ofs
975 fields[argp++] = TypeInt::INT; // limit
976 }
977 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
978 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
980 // returning ofs (int)
981 fields = TypeTuple::fields(1);
982 fields[TypeFunc::Parms+0] = TypeInt::INT; // ofs
983 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
984 return TypeFunc::make(domain, range);
985 }
987 const TypeFunc* OptoRuntime::multiplyToLen_Type() {
988 // create input type (domain)
989 int num_args = 6;
990 int argcnt = num_args;
991 const Type** fields = TypeTuple::fields(argcnt);
992 int argp = TypeFunc::Parms;
993 fields[argp++] = TypePtr::NOTNULL; // x
994 fields[argp++] = TypeInt::INT; // xlen
995 fields[argp++] = TypePtr::NOTNULL; // y
996 fields[argp++] = TypeInt::INT; // ylen
997 fields[argp++] = TypePtr::NOTNULL; // z
998 fields[argp++] = TypeInt::INT; // zlen
999 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1000 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1002 // no result type needed
1003 fields = TypeTuple::fields(1);
1004 fields[TypeFunc::Parms+0] = NULL;
1005 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
1006 return TypeFunc::make(domain, range);
1007 }
1009 const TypeFunc* OptoRuntime::squareToLen_Type() {
1010 // create input type (domain)
1011 int num_args = 4;
1012 int argcnt = num_args;
1013 const Type** fields = TypeTuple::fields(argcnt);
1014 int argp = TypeFunc::Parms;
1015 fields[argp++] = TypePtr::NOTNULL; // x
1016 fields[argp++] = TypeInt::INT; // len
1017 fields[argp++] = TypePtr::NOTNULL; // z
1018 fields[argp++] = TypeInt::INT; // zlen
1019 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1020 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1022 // no result type needed
1023 fields = TypeTuple::fields(1);
1024 fields[TypeFunc::Parms+0] = NULL;
1025 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
1026 return TypeFunc::make(domain, range);
1027 }
1029 // for mulAdd calls, 2 pointers and 3 ints, returning int
1030 const TypeFunc* OptoRuntime::mulAdd_Type() {
1031 // create input type (domain)
1032 int num_args = 5;
1033 int argcnt = num_args;
1034 const Type** fields = TypeTuple::fields(argcnt);
1035 int argp = TypeFunc::Parms;
1036 fields[argp++] = TypePtr::NOTNULL; // out
1037 fields[argp++] = TypePtr::NOTNULL; // in
1038 fields[argp++] = TypeInt::INT; // offset
1039 fields[argp++] = TypeInt::INT; // len
1040 fields[argp++] = TypeInt::INT; // k
1041 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1042 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1044 // returning carry (int)
1045 fields = TypeTuple::fields(1);
1046 fields[TypeFunc::Parms+0] = TypeInt::INT;
1047 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
1048 return TypeFunc::make(domain, range);
1049 }
1051 const TypeFunc* OptoRuntime::montgomeryMultiply_Type() {
1052 // create input type (domain)
1053 int num_args = 7;
1054 int argcnt = num_args;
1055 if (CCallingConventionRequiresIntsAsLongs) {
1056 argcnt++; // additional placeholder
1057 }
1058 const Type** fields = TypeTuple::fields(argcnt);
1059 int argp = TypeFunc::Parms;
1060 fields[argp++] = TypePtr::NOTNULL; // a
1061 fields[argp++] = TypePtr::NOTNULL; // b
1062 fields[argp++] = TypePtr::NOTNULL; // n
1063 if (CCallingConventionRequiresIntsAsLongs) {
1064 fields[argp++] = TypeLong::LONG; // len
1065 fields[argp++] = TypeLong::HALF; // placeholder
1066 } else {
1067 fields[argp++] = TypeInt::INT; // len
1068 }
1069 fields[argp++] = TypeLong::LONG; // inv
1070 fields[argp++] = Type::HALF;
1071 fields[argp++] = TypePtr::NOTNULL; // result
1072 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1073 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1075 // result type needed
1076 fields = TypeTuple::fields(1);
1077 fields[TypeFunc::Parms+0] = TypePtr::NOTNULL;
1079 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
1080 return TypeFunc::make(domain, range);
1081 }
1083 const TypeFunc* OptoRuntime::montgomerySquare_Type() {
1084 // create input type (domain)
1085 int num_args = 6;
1086 int argcnt = num_args;
1087 if (CCallingConventionRequiresIntsAsLongs) {
1088 argcnt++; // additional placeholder
1089 }
1090 const Type** fields = TypeTuple::fields(argcnt);
1091 int argp = TypeFunc::Parms;
1092 fields[argp++] = TypePtr::NOTNULL; // a
1093 fields[argp++] = TypePtr::NOTNULL; // n
1094 if (CCallingConventionRequiresIntsAsLongs) {
1095 fields[argp++] = TypeLong::LONG; // len
1096 fields[argp++] = TypeLong::HALF; // placeholder
1097 } else {
1098 fields[argp++] = TypeInt::INT; // len
1099 }
1100 fields[argp++] = TypeLong::LONG; // inv
1101 fields[argp++] = Type::HALF;
1102 fields[argp++] = TypePtr::NOTNULL; // result
1103 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1104 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1106 // result type needed
1107 fields = TypeTuple::fields(1);
1108 fields[TypeFunc::Parms+0] = TypePtr::NOTNULL;
1110 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
1111 return TypeFunc::make(domain, range);
1112 }
1115 //------------- Interpreter state access for on stack replacement
1116 const TypeFunc* OptoRuntime::osr_end_Type() {
1117 // create input type (domain)
1118 const Type **fields = TypeTuple::fields(1);
1119 fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // OSR temp buf
1120 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
1122 // create result type
1123 fields = TypeTuple::fields(1);
1124 // fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // locked oop
1125 fields[TypeFunc::Parms+0] = NULL; // void
1126 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
1127 return TypeFunc::make(domain, range);
1128 }
1130 //-------------- methodData update helpers
1132 const TypeFunc* OptoRuntime::profile_receiver_type_Type() {
1133 // create input type (domain)
1134 const Type **fields = TypeTuple::fields(2);
1135 fields[TypeFunc::Parms+0] = TypeAryPtr::NOTNULL; // methodData pointer
1136 fields[TypeFunc::Parms+1] = TypeInstPtr::BOTTOM; // receiver oop
1137 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
1139 // create result type
1140 fields = TypeTuple::fields(1);
1141 fields[TypeFunc::Parms+0] = NULL; // void
1142 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
1143 return TypeFunc::make(domain,range);
1144 }
1146 JRT_LEAF(void, OptoRuntime::profile_receiver_type_C(DataLayout* data, oopDesc* receiver))
1147 if (receiver == NULL) return;
1148 Klass* receiver_klass = receiver->klass();
1150 intptr_t* mdp = ((intptr_t*)(data)) + DataLayout::header_size_in_cells();
1151 int empty_row = -1; // free row, if any is encountered
1153 // ReceiverTypeData* vc = new ReceiverTypeData(mdp);
1154 for (uint row = 0; row < ReceiverTypeData::row_limit(); row++) {
1155 // if (vc->receiver(row) == receiver_klass)
1156 int receiver_off = ReceiverTypeData::receiver_cell_index(row);
1157 intptr_t row_recv = *(mdp + receiver_off);
1158 if (row_recv == (intptr_t) receiver_klass) {
1159 // vc->set_receiver_count(row, vc->receiver_count(row) + DataLayout::counter_increment);
1160 int count_off = ReceiverTypeData::receiver_count_cell_index(row);
1161 *(mdp + count_off) += DataLayout::counter_increment;
1162 return;
1163 } else if (row_recv == 0) {
1164 // else if (vc->receiver(row) == NULL)
1165 empty_row = (int) row;
1166 }
1167 }
1169 if (empty_row != -1) {
1170 int receiver_off = ReceiverTypeData::receiver_cell_index(empty_row);
1171 // vc->set_receiver(empty_row, receiver_klass);
1172 *(mdp + receiver_off) = (intptr_t) receiver_klass;
1173 // vc->set_receiver_count(empty_row, DataLayout::counter_increment);
1174 int count_off = ReceiverTypeData::receiver_count_cell_index(empty_row);
1175 *(mdp + count_off) = DataLayout::counter_increment;
1176 } else {
1177 // Receiver did not match any saved receiver and there is no empty row for it.
1178 // Increment total counter to indicate polymorphic case.
1179 intptr_t* count_p = (intptr_t*)(((byte*)(data)) + in_bytes(CounterData::count_offset()));
1180 *count_p += DataLayout::counter_increment;
1181 }
1182 JRT_END
1184 //-------------------------------------------------------------------------------------
1185 // register policy
1187 bool OptoRuntime::is_callee_saved_register(MachRegisterNumbers reg) {
1188 assert(reg >= 0 && reg < _last_Mach_Reg, "must be a machine register");
1189 switch (register_save_policy[reg]) {
1190 case 'C': return false; //SOC
1191 case 'E': return true ; //SOE
1192 case 'N': return false; //NS
1193 case 'A': return false; //AS
1194 }
1195 ShouldNotReachHere();
1196 return false;
1197 }
1199 //-----------------------------------------------------------------------
1200 // Exceptions
1201 //
1203 static void trace_exception(oop exception_oop, address exception_pc, const char* msg) PRODUCT_RETURN;
1205 // The method is an entry that is always called by a C++ method not
1206 // directly from compiled code. Compiled code will call the C++ method following.
1207 // We can't allow async exception to be installed during exception processing.
1208 JRT_ENTRY_NO_ASYNC(address, OptoRuntime::handle_exception_C_helper(JavaThread* thread, nmethod* &nm))
1210 // Do not confuse exception_oop with pending_exception. The exception_oop
1211 // is only used to pass arguments into the method. Not for general
1212 // exception handling. DO NOT CHANGE IT to use pending_exception, since
1213 // the runtime stubs checks this on exit.
1214 assert(thread->exception_oop() != NULL, "exception oop is found");
1215 address handler_address = NULL;
1217 Handle exception(thread, thread->exception_oop());
1218 address pc = thread->exception_pc();
1220 // Clear out the exception oop and pc since looking up an
1221 // exception handler can cause class loading, which might throw an
1222 // exception and those fields are expected to be clear during
1223 // normal bytecode execution.
1224 thread->clear_exception_oop_and_pc();
1226 if (TraceExceptions) {
1227 trace_exception(exception(), pc, "");
1228 }
1230 // for AbortVMOnException flag
1231 NOT_PRODUCT(Exceptions::debug_check_abort(exception));
1233 #ifdef ASSERT
1234 if (!(exception->is_a(SystemDictionary::Throwable_klass()))) {
1235 // should throw an exception here
1236 ShouldNotReachHere();
1237 }
1238 #endif
1240 // new exception handling: this method is entered only from adapters
1241 // exceptions from compiled java methods are handled in compiled code
1242 // using rethrow node
1244 nm = CodeCache::find_nmethod(pc);
1245 assert(nm != NULL, "No NMethod found");
1246 if (nm->is_native_method()) {
1247 fatal("Native method should not have path to exception handling");
1248 } else {
1249 // we are switching to old paradigm: search for exception handler in caller_frame
1250 // instead in exception handler of caller_frame.sender()
1252 if (JvmtiExport::can_post_on_exceptions()) {
1253 // "Full-speed catching" is not necessary here,
1254 // since we're notifying the VM on every catch.
1255 // Force deoptimization and the rest of the lookup
1256 // will be fine.
1257 deoptimize_caller_frame(thread);
1258 }
1260 // Check the stack guard pages. If enabled, look for handler in this frame;
1261 // otherwise, forcibly unwind the frame.
1262 //
1263 // 4826555: use default current sp for reguard_stack instead of &nm: it's more accurate.
1264 bool force_unwind = !thread->reguard_stack();
1265 bool deopting = false;
1266 if (nm->is_deopt_pc(pc)) {
1267 deopting = true;
1268 RegisterMap map(thread, false);
1269 frame deoptee = thread->last_frame().sender(&map);
1270 assert(deoptee.is_deoptimized_frame(), "must be deopted");
1271 // Adjust the pc back to the original throwing pc
1272 pc = deoptee.pc();
1273 }
1275 // If we are forcing an unwind because of stack overflow then deopt is
1276 // irrelevant since we are throwing the frame away anyway.
1278 if (deopting && !force_unwind) {
1279 handler_address = SharedRuntime::deopt_blob()->unpack_with_exception();
1280 } else {
1282 handler_address =
1283 force_unwind ? NULL : nm->handler_for_exception_and_pc(exception, pc);
1285 if (handler_address == NULL) {
1286 bool recursive_exception = false;
1287 handler_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true, recursive_exception);
1288 assert (handler_address != NULL, "must have compiled handler");
1289 // Update the exception cache only when the unwind was not forced
1290 // and there didn't happen another exception during the computation of the
1291 // compiled exception handler. Checking for exception oop equality is not
1292 // sufficient because some exceptions are pre-allocated and reused.
1293 if (!force_unwind && !recursive_exception) {
1294 nm->add_handler_for_exception_and_pc(exception,pc,handler_address);
1295 }
1296 } else {
1297 #ifdef ASSERT
1298 bool recursive_exception = false;
1299 address computed_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true, recursive_exception);
1300 assert(recursive_exception || (handler_address == computed_address), err_msg("Handler address inconsistency: " PTR_FORMAT " != " PTR_FORMAT,
1301 p2i(handler_address), p2i(computed_address)));
1302 #endif
1303 }
1304 }
1306 thread->set_exception_pc(pc);
1307 thread->set_exception_handler_pc(handler_address);
1309 // Check if the exception PC is a MethodHandle call site.
1310 thread->set_is_method_handle_return(nm->is_method_handle_return(pc));
1311 }
1313 // Restore correct return pc. Was saved above.
1314 thread->set_exception_oop(exception());
1315 return handler_address;
1317 JRT_END
1319 // We are entering here from exception_blob
1320 // If there is a compiled exception handler in this method, we will continue there;
1321 // otherwise we will unwind the stack and continue at the caller of top frame method
1322 // Note we enter without the usual JRT wrapper. We will call a helper routine that
1323 // will do the normal VM entry. We do it this way so that we can see if the nmethod
1324 // we looked up the handler for has been deoptimized in the meantime. If it has been
1325 // we must not use the handler and instead return the deopt blob.
1326 address OptoRuntime::handle_exception_C(JavaThread* thread) {
1327 //
1328 // We are in Java not VM and in debug mode we have a NoHandleMark
1329 //
1330 #ifndef PRODUCT
1331 SharedRuntime::_find_handler_ctr++; // find exception handler
1332 #endif
1333 debug_only(NoHandleMark __hm;)
1334 nmethod* nm = NULL;
1335 address handler_address = NULL;
1336 {
1337 // Enter the VM
1339 ResetNoHandleMark rnhm;
1340 handler_address = handle_exception_C_helper(thread, nm);
1341 }
1343 // Back in java: Use no oops, DON'T safepoint
1345 // Now check to see if the handler we are returning is in a now
1346 // deoptimized frame
1348 if (nm != NULL) {
1349 RegisterMap map(thread, false);
1350 frame caller = thread->last_frame().sender(&map);
1351 #ifdef ASSERT
1352 assert(caller.is_compiled_frame(), "must be");
1353 #endif // ASSERT
1354 if (caller.is_deoptimized_frame()) {
1355 handler_address = SharedRuntime::deopt_blob()->unpack_with_exception();
1356 }
1357 }
1358 return handler_address;
1359 }
1361 //------------------------------rethrow----------------------------------------
1362 // We get here after compiled code has executed a 'RethrowNode'. The callee
1363 // is either throwing or rethrowing an exception. The callee-save registers
1364 // have been restored, synchronized objects have been unlocked and the callee
1365 // stack frame has been removed. The return address was passed in.
1366 // Exception oop is passed as the 1st argument. This routine is then called
1367 // from the stub. On exit, we know where to jump in the caller's code.
1368 // After this C code exits, the stub will pop his frame and end in a jump
1369 // (instead of a return). We enter the caller's default handler.
1370 //
1371 // This must be JRT_LEAF:
1372 // - caller will not change its state as we cannot block on exit,
1373 // therefore raw_exception_handler_for_return_address is all it takes
1374 // to handle deoptimized blobs
1375 //
1376 // However, there needs to be a safepoint check in the middle! So compiled
1377 // safepoints are completely watertight.
1378 //
1379 // Thus, it cannot be a leaf since it contains the No_GC_Verifier.
1380 //
1381 // *THIS IS NOT RECOMMENDED PROGRAMMING STYLE*
1382 //
1383 address OptoRuntime::rethrow_C(oopDesc* exception, JavaThread* thread, address ret_pc) {
1384 #ifndef PRODUCT
1385 SharedRuntime::_rethrow_ctr++; // count rethrows
1386 #endif
1387 assert (exception != NULL, "should have thrown a NULLPointerException");
1388 #ifdef ASSERT
1389 if (!(exception->is_a(SystemDictionary::Throwable_klass()))) {
1390 // should throw an exception here
1391 ShouldNotReachHere();
1392 }
1393 #endif
1395 thread->set_vm_result(exception);
1396 // Frame not compiled (handles deoptimization blob)
1397 return SharedRuntime::raw_exception_handler_for_return_address(thread, ret_pc);
1398 }
1401 const TypeFunc *OptoRuntime::rethrow_Type() {
1402 // create input type (domain)
1403 const Type **fields = TypeTuple::fields(1);
1404 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Exception oop
1405 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1,fields);
1407 // create result type (range)
1408 fields = TypeTuple::fields(1);
1409 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Exception oop
1410 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
1412 return TypeFunc::make(domain, range);
1413 }
1416 void OptoRuntime::deoptimize_caller_frame(JavaThread *thread, bool doit) {
1417 // Deoptimize the caller before continuing, as the compiled
1418 // exception handler table may not be valid.
1419 if (!StressCompiledExceptionHandlers && doit) {
1420 deoptimize_caller_frame(thread);
1421 }
1422 }
1424 void OptoRuntime::deoptimize_caller_frame(JavaThread *thread) {
1425 // Called from within the owner thread, so no need for safepoint
1426 RegisterMap reg_map(thread);
1427 frame stub_frame = thread->last_frame();
1428 assert(stub_frame.is_runtime_frame() || exception_blob()->contains(stub_frame.pc()), "sanity check");
1429 frame caller_frame = stub_frame.sender(®_map);
1431 // Deoptimize the caller frame.
1432 Deoptimization::deoptimize_frame(thread, caller_frame.id());
1433 }
1436 bool OptoRuntime::is_deoptimized_caller_frame(JavaThread *thread) {
1437 // Called from within the owner thread, so no need for safepoint
1438 RegisterMap reg_map(thread);
1439 frame stub_frame = thread->last_frame();
1440 assert(stub_frame.is_runtime_frame() || exception_blob()->contains(stub_frame.pc()), "sanity check");
1441 frame caller_frame = stub_frame.sender(®_map);
1442 return caller_frame.is_deoptimized_frame();
1443 }
1446 const TypeFunc *OptoRuntime::register_finalizer_Type() {
1447 // create input type (domain)
1448 const Type **fields = TypeTuple::fields(1);
1449 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // oop; Receiver
1450 // // The JavaThread* is passed to each routine as the last argument
1451 // fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL; // JavaThread *; Executing thread
1452 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1,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 }
1463 //-----------------------------------------------------------------------------
1464 // Dtrace support. entry and exit probes have the same signature
1465 const TypeFunc *OptoRuntime::dtrace_method_entry_exit_Type() {
1466 // create input type (domain)
1467 const Type **fields = TypeTuple::fields(2);
1468 fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage
1469 fields[TypeFunc::Parms+1] = TypeMetadataPtr::BOTTOM; // Method*; Method we are entering
1470 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
1472 // create result type (range)
1473 fields = TypeTuple::fields(0);
1475 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
1477 return TypeFunc::make(domain,range);
1478 }
1480 const TypeFunc *OptoRuntime::dtrace_object_alloc_Type() {
1481 // create input type (domain)
1482 const Type **fields = TypeTuple::fields(2);
1483 fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage
1484 fields[TypeFunc::Parms+1] = TypeInstPtr::NOTNULL; // oop; newly allocated object
1486 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
1488 // create result type (range)
1489 fields = TypeTuple::fields(0);
1491 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
1493 return TypeFunc::make(domain,range);
1494 }
1497 JRT_ENTRY_NO_ASYNC(void, OptoRuntime::register_finalizer(oopDesc* obj, JavaThread* thread))
1498 assert(obj->is_oop(), "must be a valid oop");
1499 assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise");
1500 InstanceKlass::register_finalizer(instanceOop(obj), CHECK);
1501 JRT_END
1503 //-----------------------------------------------------------------------------
1505 NamedCounter * volatile OptoRuntime::_named_counters = NULL;
1507 //
1508 // dump the collected NamedCounters.
1509 //
1510 void OptoRuntime::print_named_counters() {
1511 int total_lock_count = 0;
1512 int eliminated_lock_count = 0;
1514 NamedCounter* c = _named_counters;
1515 while (c) {
1516 if (c->tag() == NamedCounter::LockCounter || c->tag() == NamedCounter::EliminatedLockCounter) {
1517 int count = c->count();
1518 if (count > 0) {
1519 bool eliminated = c->tag() == NamedCounter::EliminatedLockCounter;
1520 if (Verbose) {
1521 tty->print_cr("%d %s%s", count, c->name(), eliminated ? " (eliminated)" : "");
1522 }
1523 total_lock_count += count;
1524 if (eliminated) {
1525 eliminated_lock_count += count;
1526 }
1527 }
1528 } else if (c->tag() == NamedCounter::BiasedLockingCounter) {
1529 BiasedLockingCounters* blc = ((BiasedLockingNamedCounter*)c)->counters();
1530 if (blc->nonzero()) {
1531 tty->print_cr("%s", c->name());
1532 blc->print_on(tty);
1533 }
1534 #if INCLUDE_RTM_OPT
1535 } else if (c->tag() == NamedCounter::RTMLockingCounter) {
1536 RTMLockingCounters* rlc = ((RTMLockingNamedCounter*)c)->counters();
1537 if (rlc->nonzero()) {
1538 tty->print_cr("%s", c->name());
1539 rlc->print_on(tty);
1540 }
1541 #endif
1542 }
1543 c = c->next();
1544 }
1545 if (total_lock_count > 0) {
1546 tty->print_cr("dynamic locks: %d", total_lock_count);
1547 if (eliminated_lock_count) {
1548 tty->print_cr("eliminated locks: %d (%d%%)", eliminated_lock_count,
1549 (int)(eliminated_lock_count * 100.0 / total_lock_count));
1550 }
1551 }
1552 }
1554 //
1555 // Allocate a new NamedCounter. The JVMState is used to generate the
1556 // name which consists of method@line for the inlining tree.
1557 //
1559 NamedCounter* OptoRuntime::new_named_counter(JVMState* youngest_jvms, NamedCounter::CounterTag tag) {
1560 int max_depth = youngest_jvms->depth();
1562 // Visit scopes from youngest to oldest.
1563 bool first = true;
1564 stringStream st;
1565 for (int depth = max_depth; depth >= 1; depth--) {
1566 JVMState* jvms = youngest_jvms->of_depth(depth);
1567 ciMethod* m = jvms->has_method() ? jvms->method() : NULL;
1568 if (!first) {
1569 st.print(" ");
1570 } else {
1571 first = false;
1572 }
1573 int bci = jvms->bci();
1574 if (bci < 0) bci = 0;
1575 st.print("%s.%s@%d", m->holder()->name()->as_utf8(), m->name()->as_utf8(), bci);
1576 // To print linenumbers instead of bci use: m->line_number_from_bci(bci)
1577 }
1578 NamedCounter* c;
1579 if (tag == NamedCounter::BiasedLockingCounter) {
1580 c = new BiasedLockingNamedCounter(strdup(st.as_string()));
1581 } else if (tag == NamedCounter::RTMLockingCounter) {
1582 c = new RTMLockingNamedCounter(strdup(st.as_string()));
1583 } else {
1584 c = new NamedCounter(strdup(st.as_string()), tag);
1585 }
1587 // atomically add the new counter to the head of the list. We only
1588 // add counters so this is safe.
1589 NamedCounter* head;
1590 do {
1591 c->set_next(NULL);
1592 head = _named_counters;
1593 c->set_next(head);
1594 } while (Atomic::cmpxchg_ptr(c, &_named_counters, head) != head);
1595 return c;
1596 }
1598 //-----------------------------------------------------------------------------
1599 // Non-product code
1600 #ifndef PRODUCT
1602 int trace_exception_counter = 0;
1603 static void trace_exception(oop exception_oop, address exception_pc, const char* msg) {
1604 ttyLocker ttyl;
1605 trace_exception_counter++;
1606 tty->print("%d [Exception (%s): ", trace_exception_counter, msg);
1607 exception_oop->print_value();
1608 tty->print(" in ");
1609 CodeBlob* blob = CodeCache::find_blob(exception_pc);
1610 if (blob->is_nmethod()) {
1611 nmethod* nm = blob->as_nmethod_or_null();
1612 nm->method()->print_value();
1613 } else if (blob->is_runtime_stub()) {
1614 tty->print("<runtime-stub>");
1615 } else {
1616 tty->print("<unknown>");
1617 }
1618 tty->print(" at " INTPTR_FORMAT, p2i(exception_pc));
1619 tty->print_cr("]");
1620 }
1622 #endif // PRODUCT
1625 # ifdef ENABLE_ZAP_DEAD_LOCALS
1626 // Called from call sites in compiled code with oop maps (actually safepoints)
1627 // Zaps dead locals in first java frame.
1628 // Is entry because may need to lock to generate oop maps
1629 // Currently, only used for compiler frames, but someday may be used
1630 // for interpreter frames, too.
1632 int OptoRuntime::ZapDeadCompiledLocals_count = 0;
1634 // avoid pointers to member funcs with these helpers
1635 static bool is_java_frame( frame* f) { return f->is_java_frame(); }
1636 static bool is_native_frame(frame* f) { return f->is_native_frame(); }
1639 void OptoRuntime::zap_dead_java_or_native_locals(JavaThread* thread,
1640 bool (*is_this_the_right_frame_to_zap)(frame*)) {
1641 assert(JavaThread::current() == thread, "is this needed?");
1643 if ( !ZapDeadCompiledLocals ) return;
1645 bool skip = false;
1647 if ( ZapDeadCompiledLocalsFirst == 0 ) ; // nothing special
1648 else if ( ZapDeadCompiledLocalsFirst > ZapDeadCompiledLocals_count ) skip = true;
1649 else if ( ZapDeadCompiledLocalsFirst == ZapDeadCompiledLocals_count )
1650 warning("starting zapping after skipping");
1652 if ( ZapDeadCompiledLocalsLast == -1 ) ; // nothing special
1653 else if ( ZapDeadCompiledLocalsLast < ZapDeadCompiledLocals_count ) skip = true;
1654 else if ( ZapDeadCompiledLocalsLast == ZapDeadCompiledLocals_count )
1655 warning("about to zap last zap");
1657 ++ZapDeadCompiledLocals_count; // counts skipped zaps, too
1659 if ( skip ) return;
1661 // find java frame and zap it
1663 for (StackFrameStream sfs(thread); !sfs.is_done(); sfs.next()) {
1664 if (is_this_the_right_frame_to_zap(sfs.current()) ) {
1665 sfs.current()->zap_dead_locals(thread, sfs.register_map());
1666 return;
1667 }
1668 }
1669 warning("no frame found to zap in zap_dead_Java_locals_C");
1670 }
1672 JRT_LEAF(void, OptoRuntime::zap_dead_Java_locals_C(JavaThread* thread))
1673 zap_dead_java_or_native_locals(thread, is_java_frame);
1674 JRT_END
1676 // The following does not work because for one thing, the
1677 // thread state is wrong; it expects java, but it is native.
1678 // Also, the invariants in a native stub are different and
1679 // I'm not sure it is safe to have a MachCalRuntimeDirectNode
1680 // in there.
1681 // So for now, we do not zap in native stubs.
1683 JRT_LEAF(void, OptoRuntime::zap_dead_native_locals_C(JavaThread* thread))
1684 zap_dead_java_or_native_locals(thread, is_native_frame);
1685 JRT_END
1687 # endif