Thu, 27 Dec 2018 11:43:33 +0800
Merge
1 /*
2 * Copyright (c) 1998, 2018, 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 const Type** fields = TypeTuple::fields(argcnt);
860 int argp = TypeFunc::Parms;
861 fields[argp++] = TypeInt::INT; // crc
862 fields[argp++] = TypePtr::NOTNULL; // src
863 fields[argp++] = TypeInt::INT; // len
864 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
865 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
867 // result type needed
868 fields = TypeTuple::fields(1);
869 fields[TypeFunc::Parms+0] = TypeInt::INT; // crc result
870 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
871 return TypeFunc::make(domain, range);
872 }
874 // for cipherBlockChaining calls of aescrypt encrypt/decrypt, four pointers and a length, returning int
875 const TypeFunc* OptoRuntime::cipherBlockChaining_aescrypt_Type() {
876 // create input type (domain)
877 int num_args = 5;
878 if (Matcher::pass_original_key_for_aes()) {
879 num_args = 6;
880 }
881 int argcnt = num_args;
882 const Type** fields = TypeTuple::fields(argcnt);
883 int argp = TypeFunc::Parms;
884 fields[argp++] = TypePtr::NOTNULL; // src
885 fields[argp++] = TypePtr::NOTNULL; // dest
886 fields[argp++] = TypePtr::NOTNULL; // k array
887 fields[argp++] = TypePtr::NOTNULL; // r array
888 fields[argp++] = TypeInt::INT; // src len
889 if (Matcher::pass_original_key_for_aes()) {
890 fields[argp++] = TypePtr::NOTNULL; // original k array
891 }
892 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
893 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
895 // returning cipher len (int)
896 fields = TypeTuple::fields(1);
897 fields[TypeFunc::Parms+0] = TypeInt::INT;
898 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
899 return TypeFunc::make(domain, range);
900 }
902 /*
903 * void implCompress(byte[] buf, int ofs)
904 */
905 const TypeFunc* OptoRuntime::sha_implCompress_Type() {
906 // create input type (domain)
907 int num_args = 2;
908 int argcnt = num_args;
909 const Type** fields = TypeTuple::fields(argcnt);
910 int argp = TypeFunc::Parms;
911 fields[argp++] = TypePtr::NOTNULL; // buf
912 fields[argp++] = TypePtr::NOTNULL; // state
913 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
914 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
916 // no result type needed
917 fields = TypeTuple::fields(1);
918 fields[TypeFunc::Parms+0] = NULL; // void
919 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
920 return TypeFunc::make(domain, range);
921 }
923 /*
924 * int implCompressMultiBlock(byte[] b, int ofs, int limit)
925 */
926 const TypeFunc* OptoRuntime::digestBase_implCompressMB_Type() {
927 // create input type (domain)
928 int num_args = 4;
929 int argcnt = num_args;
930 const Type** fields = TypeTuple::fields(argcnt);
931 int argp = TypeFunc::Parms;
932 fields[argp++] = TypePtr::NOTNULL; // buf
933 fields[argp++] = TypePtr::NOTNULL; // state
934 fields[argp++] = TypeInt::INT; // ofs
935 fields[argp++] = TypeInt::INT; // limit
936 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
937 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
939 // returning ofs (int)
940 fields = TypeTuple::fields(1);
941 fields[TypeFunc::Parms+0] = TypeInt::INT; // ofs
942 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
943 return TypeFunc::make(domain, range);
944 }
946 const TypeFunc* OptoRuntime::multiplyToLen_Type() {
947 // create input type (domain)
948 int num_args = 6;
949 int argcnt = num_args;
950 const Type** fields = TypeTuple::fields(argcnt);
951 int argp = TypeFunc::Parms;
952 fields[argp++] = TypePtr::NOTNULL; // x
953 fields[argp++] = TypeInt::INT; // xlen
954 fields[argp++] = TypePtr::NOTNULL; // y
955 fields[argp++] = TypeInt::INT; // ylen
956 fields[argp++] = TypePtr::NOTNULL; // z
957 fields[argp++] = TypeInt::INT; // zlen
958 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
959 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
961 // no result type needed
962 fields = TypeTuple::fields(1);
963 fields[TypeFunc::Parms+0] = NULL;
964 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
965 return TypeFunc::make(domain, range);
966 }
968 const TypeFunc* OptoRuntime::squareToLen_Type() {
969 // create input type (domain)
970 int num_args = 4;
971 int argcnt = num_args;
972 const Type** fields = TypeTuple::fields(argcnt);
973 int argp = TypeFunc::Parms;
974 fields[argp++] = TypePtr::NOTNULL; // x
975 fields[argp++] = TypeInt::INT; // len
976 fields[argp++] = TypePtr::NOTNULL; // z
977 fields[argp++] = TypeInt::INT; // zlen
978 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
979 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
981 // no result type needed
982 fields = TypeTuple::fields(1);
983 fields[TypeFunc::Parms+0] = NULL;
984 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
985 return TypeFunc::make(domain, range);
986 }
988 // for mulAdd calls, 2 pointers and 3 ints, returning int
989 const TypeFunc* OptoRuntime::mulAdd_Type() {
990 // create input type (domain)
991 int num_args = 5;
992 int argcnt = num_args;
993 const Type** fields = TypeTuple::fields(argcnt);
994 int argp = TypeFunc::Parms;
995 fields[argp++] = TypePtr::NOTNULL; // out
996 fields[argp++] = TypePtr::NOTNULL; // in
997 fields[argp++] = TypeInt::INT; // offset
998 fields[argp++] = TypeInt::INT; // len
999 fields[argp++] = TypeInt::INT; // k
1000 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1001 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1003 // returning carry (int)
1004 fields = TypeTuple::fields(1);
1005 fields[TypeFunc::Parms+0] = TypeInt::INT;
1006 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
1007 return TypeFunc::make(domain, range);
1008 }
1010 const TypeFunc* OptoRuntime::montgomeryMultiply_Type() {
1011 // create input type (domain)
1012 int num_args = 7;
1013 int argcnt = num_args;
1014 if (CCallingConventionRequiresIntsAsLongs) {
1015 argcnt++; // additional placeholder
1016 }
1017 const Type** fields = TypeTuple::fields(argcnt);
1018 int argp = TypeFunc::Parms;
1019 fields[argp++] = TypePtr::NOTNULL; // a
1020 fields[argp++] = TypePtr::NOTNULL; // b
1021 fields[argp++] = TypePtr::NOTNULL; // n
1022 if (CCallingConventionRequiresIntsAsLongs) {
1023 fields[argp++] = TypeLong::LONG; // len
1024 fields[argp++] = TypeLong::HALF; // placeholder
1025 } else {
1026 fields[argp++] = TypeInt::INT; // len
1027 }
1028 fields[argp++] = TypeLong::LONG; // inv
1029 fields[argp++] = Type::HALF;
1030 fields[argp++] = TypePtr::NOTNULL; // result
1031 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1032 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1034 // result type needed
1035 fields = TypeTuple::fields(1);
1036 fields[TypeFunc::Parms+0] = TypePtr::NOTNULL;
1038 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
1039 return TypeFunc::make(domain, range);
1040 }
1042 const TypeFunc* OptoRuntime::montgomerySquare_Type() {
1043 // create input type (domain)
1044 int num_args = 6;
1045 int argcnt = num_args;
1046 if (CCallingConventionRequiresIntsAsLongs) {
1047 argcnt++; // additional placeholder
1048 }
1049 const Type** fields = TypeTuple::fields(argcnt);
1050 int argp = TypeFunc::Parms;
1051 fields[argp++] = TypePtr::NOTNULL; // a
1052 fields[argp++] = TypePtr::NOTNULL; // n
1053 if (CCallingConventionRequiresIntsAsLongs) {
1054 fields[argp++] = TypeLong::LONG; // len
1055 fields[argp++] = TypeLong::HALF; // placeholder
1056 } else {
1057 fields[argp++] = TypeInt::INT; // len
1058 }
1059 fields[argp++] = TypeLong::LONG; // inv
1060 fields[argp++] = Type::HALF;
1061 fields[argp++] = TypePtr::NOTNULL; // result
1062 assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
1063 const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
1065 // result type needed
1066 fields = TypeTuple::fields(1);
1067 fields[TypeFunc::Parms+0] = TypePtr::NOTNULL;
1069 const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
1070 return TypeFunc::make(domain, range);
1071 }
1074 //------------- Interpreter state access for on stack replacement
1075 const TypeFunc* OptoRuntime::osr_end_Type() {
1076 // create input type (domain)
1077 const Type **fields = TypeTuple::fields(1);
1078 fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // OSR temp buf
1079 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1, fields);
1081 // create result type
1082 fields = TypeTuple::fields(1);
1083 // fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // locked oop
1084 fields[TypeFunc::Parms+0] = NULL; // void
1085 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
1086 return TypeFunc::make(domain, range);
1087 }
1089 //-------------- methodData update helpers
1091 const TypeFunc* OptoRuntime::profile_receiver_type_Type() {
1092 // create input type (domain)
1093 const Type **fields = TypeTuple::fields(2);
1094 fields[TypeFunc::Parms+0] = TypeAryPtr::NOTNULL; // methodData pointer
1095 fields[TypeFunc::Parms+1] = TypeInstPtr::BOTTOM; // receiver oop
1096 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields);
1098 // create result type
1099 fields = TypeTuple::fields(1);
1100 fields[TypeFunc::Parms+0] = NULL; // void
1101 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms, fields);
1102 return TypeFunc::make(domain,range);
1103 }
1105 JRT_LEAF(void, OptoRuntime::profile_receiver_type_C(DataLayout* data, oopDesc* receiver))
1106 if (receiver == NULL) return;
1107 Klass* receiver_klass = receiver->klass();
1109 intptr_t* mdp = ((intptr_t*)(data)) + DataLayout::header_size_in_cells();
1110 int empty_row = -1; // free row, if any is encountered
1112 // ReceiverTypeData* vc = new ReceiverTypeData(mdp);
1113 for (uint row = 0; row < ReceiverTypeData::row_limit(); row++) {
1114 // if (vc->receiver(row) == receiver_klass)
1115 int receiver_off = ReceiverTypeData::receiver_cell_index(row);
1116 intptr_t row_recv = *(mdp + receiver_off);
1117 if (row_recv == (intptr_t) receiver_klass) {
1118 // vc->set_receiver_count(row, vc->receiver_count(row) + DataLayout::counter_increment);
1119 int count_off = ReceiverTypeData::receiver_count_cell_index(row);
1120 *(mdp + count_off) += DataLayout::counter_increment;
1121 return;
1122 } else if (row_recv == 0) {
1123 // else if (vc->receiver(row) == NULL)
1124 empty_row = (int) row;
1125 }
1126 }
1128 if (empty_row != -1) {
1129 int receiver_off = ReceiverTypeData::receiver_cell_index(empty_row);
1130 // vc->set_receiver(empty_row, receiver_klass);
1131 *(mdp + receiver_off) = (intptr_t) receiver_klass;
1132 // vc->set_receiver_count(empty_row, DataLayout::counter_increment);
1133 int count_off = ReceiverTypeData::receiver_count_cell_index(empty_row);
1134 *(mdp + count_off) = DataLayout::counter_increment;
1135 } else {
1136 // Receiver did not match any saved receiver and there is no empty row for it.
1137 // Increment total counter to indicate polymorphic case.
1138 intptr_t* count_p = (intptr_t*)(((byte*)(data)) + in_bytes(CounterData::count_offset()));
1139 *count_p += DataLayout::counter_increment;
1140 }
1141 JRT_END
1143 //-------------------------------------------------------------------------------------
1144 // register policy
1146 bool OptoRuntime::is_callee_saved_register(MachRegisterNumbers reg) {
1147 assert(reg >= 0 && reg < _last_Mach_Reg, "must be a machine register");
1148 switch (register_save_policy[reg]) {
1149 case 'C': return false; //SOC
1150 case 'E': return true ; //SOE
1151 case 'N': return false; //NS
1152 case 'A': return false; //AS
1153 }
1154 ShouldNotReachHere();
1155 return false;
1156 }
1158 //-----------------------------------------------------------------------
1159 // Exceptions
1160 //
1162 static void trace_exception(oop exception_oop, address exception_pc, const char* msg) PRODUCT_RETURN;
1164 // The method is an entry that is always called by a C++ method not
1165 // directly from compiled code. Compiled code will call the C++ method following.
1166 // We can't allow async exception to be installed during exception processing.
1167 JRT_ENTRY_NO_ASYNC(address, OptoRuntime::handle_exception_C_helper(JavaThread* thread, nmethod* &nm))
1169 // Do not confuse exception_oop with pending_exception. The exception_oop
1170 // is only used to pass arguments into the method. Not for general
1171 // exception handling. DO NOT CHANGE IT to use pending_exception, since
1172 // the runtime stubs checks this on exit.
1173 assert(thread->exception_oop() != NULL, "exception oop is found");
1174 address handler_address = NULL;
1176 Handle exception(thread, thread->exception_oop());
1177 address pc = thread->exception_pc();
1179 // Clear out the exception oop and pc since looking up an
1180 // exception handler can cause class loading, which might throw an
1181 // exception and those fields are expected to be clear during
1182 // normal bytecode execution.
1183 thread->clear_exception_oop_and_pc();
1185 if (TraceExceptions) {
1186 trace_exception(exception(), pc, "");
1187 }
1189 // for AbortVMOnException flag
1190 NOT_PRODUCT(Exceptions::debug_check_abort(exception));
1192 #ifdef ASSERT
1193 if (!(exception->is_a(SystemDictionary::Throwable_klass()))) {
1194 // should throw an exception here
1195 ShouldNotReachHere();
1196 }
1197 #endif
1199 // new exception handling: this method is entered only from adapters
1200 // exceptions from compiled java methods are handled in compiled code
1201 // using rethrow node
1203 nm = CodeCache::find_nmethod(pc);
1204 assert(nm != NULL, "No NMethod found");
1205 if (nm->is_native_method()) {
1206 fatal("Native method should not have path to exception handling");
1207 } else {
1208 // we are switching to old paradigm: search for exception handler in caller_frame
1209 // instead in exception handler of caller_frame.sender()
1211 if (JvmtiExport::can_post_on_exceptions()) {
1212 // "Full-speed catching" is not necessary here,
1213 // since we're notifying the VM on every catch.
1214 // Force deoptimization and the rest of the lookup
1215 // will be fine.
1216 deoptimize_caller_frame(thread);
1217 }
1219 // Check the stack guard pages. If enabled, look for handler in this frame;
1220 // otherwise, forcibly unwind the frame.
1221 //
1222 // 4826555: use default current sp for reguard_stack instead of &nm: it's more accurate.
1223 bool force_unwind = !thread->reguard_stack();
1224 bool deopting = false;
1225 if (nm->is_deopt_pc(pc)) {
1226 deopting = true;
1227 RegisterMap map(thread, false);
1228 frame deoptee = thread->last_frame().sender(&map);
1229 assert(deoptee.is_deoptimized_frame(), "must be deopted");
1230 // Adjust the pc back to the original throwing pc
1231 pc = deoptee.pc();
1232 }
1234 // If we are forcing an unwind because of stack overflow then deopt is
1235 // irrelevant since we are throwing the frame away anyway.
1237 if (deopting && !force_unwind) {
1238 handler_address = SharedRuntime::deopt_blob()->unpack_with_exception();
1239 } else {
1241 handler_address =
1242 force_unwind ? NULL : nm->handler_for_exception_and_pc(exception, pc);
1244 if (handler_address == NULL) {
1245 bool recursive_exception = false;
1246 handler_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true, recursive_exception);
1247 assert (handler_address != NULL, "must have compiled handler");
1248 // Update the exception cache only when the unwind was not forced
1249 // and there didn't happen another exception during the computation of the
1250 // compiled exception handler. Checking for exception oop equality is not
1251 // sufficient because some exceptions are pre-allocated and reused.
1252 if (!force_unwind && !recursive_exception) {
1253 nm->add_handler_for_exception_and_pc(exception,pc,handler_address);
1254 }
1255 } else {
1256 #ifdef ASSERT
1257 bool recursive_exception = false;
1258 address computed_address = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, force_unwind, true, recursive_exception);
1259 assert(recursive_exception || (handler_address == computed_address), err_msg("Handler address inconsistency: " PTR_FORMAT " != " PTR_FORMAT,
1260 p2i(handler_address), p2i(computed_address)));
1261 #endif
1262 }
1263 }
1265 thread->set_exception_pc(pc);
1266 thread->set_exception_handler_pc(handler_address);
1268 // Check if the exception PC is a MethodHandle call site.
1269 thread->set_is_method_handle_return(nm->is_method_handle_return(pc));
1270 }
1272 // Restore correct return pc. Was saved above.
1273 thread->set_exception_oop(exception());
1274 return handler_address;
1276 JRT_END
1278 // We are entering here from exception_blob
1279 // If there is a compiled exception handler in this method, we will continue there;
1280 // otherwise we will unwind the stack and continue at the caller of top frame method
1281 // Note we enter without the usual JRT wrapper. We will call a helper routine that
1282 // will do the normal VM entry. We do it this way so that we can see if the nmethod
1283 // we looked up the handler for has been deoptimized in the meantime. If it has been
1284 // we must not use the handler and instead return the deopt blob.
1285 address OptoRuntime::handle_exception_C(JavaThread* thread) {
1286 //
1287 // We are in Java not VM and in debug mode we have a NoHandleMark
1288 //
1289 #ifndef PRODUCT
1290 SharedRuntime::_find_handler_ctr++; // find exception handler
1291 #endif
1292 debug_only(NoHandleMark __hm;)
1293 nmethod* nm = NULL;
1294 address handler_address = NULL;
1295 {
1296 // Enter the VM
1298 ResetNoHandleMark rnhm;
1299 handler_address = handle_exception_C_helper(thread, nm);
1300 }
1302 // Back in java: Use no oops, DON'T safepoint
1304 // Now check to see if the handler we are returning is in a now
1305 // deoptimized frame
1307 if (nm != NULL) {
1308 RegisterMap map(thread, false);
1309 frame caller = thread->last_frame().sender(&map);
1310 #ifdef ASSERT
1311 assert(caller.is_compiled_frame(), "must be");
1312 #endif // ASSERT
1313 if (caller.is_deoptimized_frame()) {
1314 handler_address = SharedRuntime::deopt_blob()->unpack_with_exception();
1315 }
1316 }
1317 return handler_address;
1318 }
1320 //------------------------------rethrow----------------------------------------
1321 // We get here after compiled code has executed a 'RethrowNode'. The callee
1322 // is either throwing or rethrowing an exception. The callee-save registers
1323 // have been restored, synchronized objects have been unlocked and the callee
1324 // stack frame has been removed. The return address was passed in.
1325 // Exception oop is passed as the 1st argument. This routine is then called
1326 // from the stub. On exit, we know where to jump in the caller's code.
1327 // After this C code exits, the stub will pop his frame and end in a jump
1328 // (instead of a return). We enter the caller's default handler.
1329 //
1330 // This must be JRT_LEAF:
1331 // - caller will not change its state as we cannot block on exit,
1332 // therefore raw_exception_handler_for_return_address is all it takes
1333 // to handle deoptimized blobs
1334 //
1335 // However, there needs to be a safepoint check in the middle! So compiled
1336 // safepoints are completely watertight.
1337 //
1338 // Thus, it cannot be a leaf since it contains the No_GC_Verifier.
1339 //
1340 // *THIS IS NOT RECOMMENDED PROGRAMMING STYLE*
1341 //
1342 address OptoRuntime::rethrow_C(oopDesc* exception, JavaThread* thread, address ret_pc) {
1343 #ifndef PRODUCT
1344 SharedRuntime::_rethrow_ctr++; // count rethrows
1345 #endif
1346 assert (exception != NULL, "should have thrown a NULLPointerException");
1347 #ifdef ASSERT
1348 if (!(exception->is_a(SystemDictionary::Throwable_klass()))) {
1349 // should throw an exception here
1350 ShouldNotReachHere();
1351 }
1352 #endif
1354 thread->set_vm_result(exception);
1355 // Frame not compiled (handles deoptimization blob)
1356 return SharedRuntime::raw_exception_handler_for_return_address(thread, ret_pc);
1357 }
1360 const TypeFunc *OptoRuntime::rethrow_Type() {
1361 // create input type (domain)
1362 const Type **fields = TypeTuple::fields(1);
1363 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Exception oop
1364 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1,fields);
1366 // create result type (range)
1367 fields = TypeTuple::fields(1);
1368 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // Exception oop
1369 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields);
1371 return TypeFunc::make(domain, range);
1372 }
1375 void OptoRuntime::deoptimize_caller_frame(JavaThread *thread, bool doit) {
1376 // Deoptimize the caller before continuing, as the compiled
1377 // exception handler table may not be valid.
1378 if (!StressCompiledExceptionHandlers && doit) {
1379 deoptimize_caller_frame(thread);
1380 }
1381 }
1383 void OptoRuntime::deoptimize_caller_frame(JavaThread *thread) {
1384 // Called from within the owner thread, so no need for safepoint
1385 RegisterMap reg_map(thread);
1386 frame stub_frame = thread->last_frame();
1387 assert(stub_frame.is_runtime_frame() || exception_blob()->contains(stub_frame.pc()), "sanity check");
1388 frame caller_frame = stub_frame.sender(®_map);
1390 // Deoptimize the caller frame.
1391 Deoptimization::deoptimize_frame(thread, caller_frame.id());
1392 }
1395 bool OptoRuntime::is_deoptimized_caller_frame(JavaThread *thread) {
1396 // Called from within the owner thread, so no need for safepoint
1397 RegisterMap reg_map(thread);
1398 frame stub_frame = thread->last_frame();
1399 assert(stub_frame.is_runtime_frame() || exception_blob()->contains(stub_frame.pc()), "sanity check");
1400 frame caller_frame = stub_frame.sender(®_map);
1401 return caller_frame.is_deoptimized_frame();
1402 }
1405 const TypeFunc *OptoRuntime::register_finalizer_Type() {
1406 // create input type (domain)
1407 const Type **fields = TypeTuple::fields(1);
1408 fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // oop; Receiver
1409 // // The JavaThread* is passed to each routine as the last argument
1410 // fields[TypeFunc::Parms+1] = TypeRawPtr::NOTNULL; // JavaThread *; Executing thread
1411 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+1,fields);
1413 // create result type (range)
1414 fields = TypeTuple::fields(0);
1416 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
1418 return TypeFunc::make(domain,range);
1419 }
1422 //-----------------------------------------------------------------------------
1423 // Dtrace support. entry and exit probes have the same signature
1424 const TypeFunc *OptoRuntime::dtrace_method_entry_exit_Type() {
1425 // create input type (domain)
1426 const Type **fields = TypeTuple::fields(2);
1427 fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage
1428 fields[TypeFunc::Parms+1] = TypeMetadataPtr::BOTTOM; // Method*; Method we are entering
1429 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
1431 // create result type (range)
1432 fields = TypeTuple::fields(0);
1434 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
1436 return TypeFunc::make(domain,range);
1437 }
1439 const TypeFunc *OptoRuntime::dtrace_object_alloc_Type() {
1440 // create input type (domain)
1441 const Type **fields = TypeTuple::fields(2);
1442 fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // Thread-local storage
1443 fields[TypeFunc::Parms+1] = TypeInstPtr::NOTNULL; // oop; newly allocated object
1445 const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2,fields);
1447 // create result type (range)
1448 fields = TypeTuple::fields(0);
1450 const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+0,fields);
1452 return TypeFunc::make(domain,range);
1453 }
1456 JRT_ENTRY_NO_ASYNC(void, OptoRuntime::register_finalizer(oopDesc* obj, JavaThread* thread))
1457 assert(obj->is_oop(), "must be a valid oop");
1458 assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise");
1459 InstanceKlass::register_finalizer(instanceOop(obj), CHECK);
1460 JRT_END
1462 //-----------------------------------------------------------------------------
1464 NamedCounter * volatile OptoRuntime::_named_counters = NULL;
1466 //
1467 // dump the collected NamedCounters.
1468 //
1469 void OptoRuntime::print_named_counters() {
1470 int total_lock_count = 0;
1471 int eliminated_lock_count = 0;
1473 NamedCounter* c = _named_counters;
1474 while (c) {
1475 if (c->tag() == NamedCounter::LockCounter || c->tag() == NamedCounter::EliminatedLockCounter) {
1476 int count = c->count();
1477 if (count > 0) {
1478 bool eliminated = c->tag() == NamedCounter::EliminatedLockCounter;
1479 if (Verbose) {
1480 tty->print_cr("%d %s%s", count, c->name(), eliminated ? " (eliminated)" : "");
1481 }
1482 total_lock_count += count;
1483 if (eliminated) {
1484 eliminated_lock_count += count;
1485 }
1486 }
1487 } else if (c->tag() == NamedCounter::BiasedLockingCounter) {
1488 BiasedLockingCounters* blc = ((BiasedLockingNamedCounter*)c)->counters();
1489 if (blc->nonzero()) {
1490 tty->print_cr("%s", c->name());
1491 blc->print_on(tty);
1492 }
1493 #if INCLUDE_RTM_OPT
1494 } else if (c->tag() == NamedCounter::RTMLockingCounter) {
1495 RTMLockingCounters* rlc = ((RTMLockingNamedCounter*)c)->counters();
1496 if (rlc->nonzero()) {
1497 tty->print_cr("%s", c->name());
1498 rlc->print_on(tty);
1499 }
1500 #endif
1501 }
1502 c = c->next();
1503 }
1504 if (total_lock_count > 0) {
1505 tty->print_cr("dynamic locks: %d", total_lock_count);
1506 if (eliminated_lock_count) {
1507 tty->print_cr("eliminated locks: %d (%d%%)", eliminated_lock_count,
1508 (int)(eliminated_lock_count * 100.0 / total_lock_count));
1509 }
1510 }
1511 }
1513 //
1514 // Allocate a new NamedCounter. The JVMState is used to generate the
1515 // name which consists of method@line for the inlining tree.
1516 //
1518 NamedCounter* OptoRuntime::new_named_counter(JVMState* youngest_jvms, NamedCounter::CounterTag tag) {
1519 int max_depth = youngest_jvms->depth();
1521 // Visit scopes from youngest to oldest.
1522 bool first = true;
1523 stringStream st;
1524 for (int depth = max_depth; depth >= 1; depth--) {
1525 JVMState* jvms = youngest_jvms->of_depth(depth);
1526 ciMethod* m = jvms->has_method() ? jvms->method() : NULL;
1527 if (!first) {
1528 st.print(" ");
1529 } else {
1530 first = false;
1531 }
1532 int bci = jvms->bci();
1533 if (bci < 0) bci = 0;
1534 st.print("%s.%s@%d", m->holder()->name()->as_utf8(), m->name()->as_utf8(), bci);
1535 // To print linenumbers instead of bci use: m->line_number_from_bci(bci)
1536 }
1537 NamedCounter* c;
1538 if (tag == NamedCounter::BiasedLockingCounter) {
1539 c = new BiasedLockingNamedCounter(strdup(st.as_string()));
1540 } else if (tag == NamedCounter::RTMLockingCounter) {
1541 c = new RTMLockingNamedCounter(strdup(st.as_string()));
1542 } else {
1543 c = new NamedCounter(strdup(st.as_string()), tag);
1544 }
1546 // atomically add the new counter to the head of the list. We only
1547 // add counters so this is safe.
1548 NamedCounter* head;
1549 do {
1550 c->set_next(NULL);
1551 head = _named_counters;
1552 c->set_next(head);
1553 } while (Atomic::cmpxchg_ptr(c, &_named_counters, head) != head);
1554 return c;
1555 }
1557 //-----------------------------------------------------------------------------
1558 // Non-product code
1559 #ifndef PRODUCT
1561 int trace_exception_counter = 0;
1562 static void trace_exception(oop exception_oop, address exception_pc, const char* msg) {
1563 ttyLocker ttyl;
1564 trace_exception_counter++;
1565 tty->print("%d [Exception (%s): ", trace_exception_counter, msg);
1566 exception_oop->print_value();
1567 tty->print(" in ");
1568 CodeBlob* blob = CodeCache::find_blob(exception_pc);
1569 if (blob->is_nmethod()) {
1570 nmethod* nm = blob->as_nmethod_or_null();
1571 nm->method()->print_value();
1572 } else if (blob->is_runtime_stub()) {
1573 tty->print("<runtime-stub>");
1574 } else {
1575 tty->print("<unknown>");
1576 }
1577 tty->print(" at " INTPTR_FORMAT, p2i(exception_pc));
1578 tty->print_cr("]");
1579 }
1581 #endif // PRODUCT
1584 # ifdef ENABLE_ZAP_DEAD_LOCALS
1585 // Called from call sites in compiled code with oop maps (actually safepoints)
1586 // Zaps dead locals in first java frame.
1587 // Is entry because may need to lock to generate oop maps
1588 // Currently, only used for compiler frames, but someday may be used
1589 // for interpreter frames, too.
1591 int OptoRuntime::ZapDeadCompiledLocals_count = 0;
1593 // avoid pointers to member funcs with these helpers
1594 static bool is_java_frame( frame* f) { return f->is_java_frame(); }
1595 static bool is_native_frame(frame* f) { return f->is_native_frame(); }
1598 void OptoRuntime::zap_dead_java_or_native_locals(JavaThread* thread,
1599 bool (*is_this_the_right_frame_to_zap)(frame*)) {
1600 assert(JavaThread::current() == thread, "is this needed?");
1602 if ( !ZapDeadCompiledLocals ) return;
1604 bool skip = false;
1606 if ( ZapDeadCompiledLocalsFirst == 0 ) ; // nothing special
1607 else if ( ZapDeadCompiledLocalsFirst > ZapDeadCompiledLocals_count ) skip = true;
1608 else if ( ZapDeadCompiledLocalsFirst == ZapDeadCompiledLocals_count )
1609 warning("starting zapping after skipping");
1611 if ( ZapDeadCompiledLocalsLast == -1 ) ; // nothing special
1612 else if ( ZapDeadCompiledLocalsLast < ZapDeadCompiledLocals_count ) skip = true;
1613 else if ( ZapDeadCompiledLocalsLast == ZapDeadCompiledLocals_count )
1614 warning("about to zap last zap");
1616 ++ZapDeadCompiledLocals_count; // counts skipped zaps, too
1618 if ( skip ) return;
1620 // find java frame and zap it
1622 for (StackFrameStream sfs(thread); !sfs.is_done(); sfs.next()) {
1623 if (is_this_the_right_frame_to_zap(sfs.current()) ) {
1624 sfs.current()->zap_dead_locals(thread, sfs.register_map());
1625 return;
1626 }
1627 }
1628 warning("no frame found to zap in zap_dead_Java_locals_C");
1629 }
1631 JRT_LEAF(void, OptoRuntime::zap_dead_Java_locals_C(JavaThread* thread))
1632 zap_dead_java_or_native_locals(thread, is_java_frame);
1633 JRT_END
1635 // The following does not work because for one thing, the
1636 // thread state is wrong; it expects java, but it is native.
1637 // Also, the invariants in a native stub are different and
1638 // I'm not sure it is safe to have a MachCalRuntimeDirectNode
1639 // in there.
1640 // So for now, we do not zap in native stubs.
1642 JRT_LEAF(void, OptoRuntime::zap_dead_native_locals_C(JavaThread* thread))
1643 zap_dead_java_or_native_locals(thread, is_native_frame);
1644 JRT_END
1646 # endif