Wed, 25 Aug 2010 05:27:54 -0700
6978355: renaming for 6961697
Summary: This is the renaming part of 6961697 to keep the actual changes small for review.
Reviewed-by: kvn, never
1 /*
2 * Copyright (c) 1999, 2010, 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 #include "incls/_precompiled.incl"
26 #include "incls/_c1_Runtime1.cpp.incl"
29 // Implementation of StubAssembler
31 StubAssembler::StubAssembler(CodeBuffer* code, const char * name, int stub_id) : C1_MacroAssembler(code) {
32 _name = name;
33 _must_gc_arguments = false;
34 _frame_size = no_frame_size;
35 _num_rt_args = 0;
36 _stub_id = stub_id;
37 }
40 void StubAssembler::set_info(const char* name, bool must_gc_arguments) {
41 _name = name;
42 _must_gc_arguments = must_gc_arguments;
43 }
46 void StubAssembler::set_frame_size(int size) {
47 if (_frame_size == no_frame_size) {
48 _frame_size = size;
49 }
50 assert(_frame_size == size, "can't change the frame size");
51 }
54 void StubAssembler::set_num_rt_args(int args) {
55 if (_num_rt_args == 0) {
56 _num_rt_args = args;
57 }
58 assert(_num_rt_args == args, "can't change the number of args");
59 }
61 // Implementation of Runtime1
63 CodeBlob* Runtime1::_blobs[Runtime1::number_of_ids];
64 const char *Runtime1::_blob_names[] = {
65 RUNTIME1_STUBS(STUB_NAME, LAST_STUB_NAME)
66 };
68 #ifndef PRODUCT
69 // statistics
70 int Runtime1::_generic_arraycopy_cnt = 0;
71 int Runtime1::_primitive_arraycopy_cnt = 0;
72 int Runtime1::_oop_arraycopy_cnt = 0;
73 int Runtime1::_arraycopy_slowcase_cnt = 0;
74 int Runtime1::_new_type_array_slowcase_cnt = 0;
75 int Runtime1::_new_object_array_slowcase_cnt = 0;
76 int Runtime1::_new_instance_slowcase_cnt = 0;
77 int Runtime1::_new_multi_array_slowcase_cnt = 0;
78 int Runtime1::_monitorenter_slowcase_cnt = 0;
79 int Runtime1::_monitorexit_slowcase_cnt = 0;
80 int Runtime1::_patch_code_slowcase_cnt = 0;
81 int Runtime1::_throw_range_check_exception_count = 0;
82 int Runtime1::_throw_index_exception_count = 0;
83 int Runtime1::_throw_div0_exception_count = 0;
84 int Runtime1::_throw_null_pointer_exception_count = 0;
85 int Runtime1::_throw_class_cast_exception_count = 0;
86 int Runtime1::_throw_incompatible_class_change_error_count = 0;
87 int Runtime1::_throw_array_store_exception_count = 0;
88 int Runtime1::_throw_count = 0;
89 #endif
91 // Simple helper to see if the caller of a runtime stub which
92 // entered the VM has been deoptimized
94 static bool caller_is_deopted() {
95 JavaThread* thread = JavaThread::current();
96 RegisterMap reg_map(thread, false);
97 frame runtime_frame = thread->last_frame();
98 frame caller_frame = runtime_frame.sender(®_map);
99 assert(caller_frame.is_compiled_frame(), "must be compiled");
100 return caller_frame.is_deoptimized_frame();
101 }
103 // Stress deoptimization
104 static void deopt_caller() {
105 if ( !caller_is_deopted()) {
106 JavaThread* thread = JavaThread::current();
107 RegisterMap reg_map(thread, false);
108 frame runtime_frame = thread->last_frame();
109 frame caller_frame = runtime_frame.sender(®_map);
110 // bypass VM_DeoptimizeFrame and deoptimize the frame directly
111 Deoptimization::deoptimize_frame(thread, caller_frame.id());
112 assert(caller_is_deopted(), "Must be deoptimized");
113 }
114 }
117 void Runtime1::generate_blob_for(BufferBlob* buffer_blob, StubID id) {
118 assert(0 <= id && id < number_of_ids, "illegal stub id");
119 ResourceMark rm;
120 // create code buffer for code storage
121 CodeBuffer code(buffer_blob);
123 Compilation::setup_code_buffer(&code, 0);
125 // create assembler for code generation
126 StubAssembler* sasm = new StubAssembler(&code, name_for(id), id);
127 // generate code for runtime stub
128 OopMapSet* oop_maps;
129 oop_maps = generate_code_for(id, sasm);
130 assert(oop_maps == NULL || sasm->frame_size() != no_frame_size,
131 "if stub has an oop map it must have a valid frame size");
133 #ifdef ASSERT
134 // Make sure that stubs that need oopmaps have them
135 switch (id) {
136 // These stubs don't need to have an oopmap
137 case dtrace_object_alloc_id:
138 case g1_pre_barrier_slow_id:
139 case g1_post_barrier_slow_id:
140 case slow_subtype_check_id:
141 case fpu2long_stub_id:
142 case unwind_exception_id:
143 #ifndef TIERED
144 case counter_overflow_id: // Not generated outside the tiered world
145 #endif
146 #if defined(SPARC) || defined(PPC)
147 case handle_exception_nofpu_id: // Unused on sparc
148 #endif
149 break;
151 // All other stubs should have oopmaps
152 default:
153 assert(oop_maps != NULL, "must have an oopmap");
154 }
155 #endif
157 // align so printing shows nop's instead of random code at the end (SimpleStubs are aligned)
158 sasm->align(BytesPerWord);
159 // make sure all code is in code buffer
160 sasm->flush();
161 // create blob - distinguish a few special cases
162 CodeBlob* blob = RuntimeStub::new_runtime_stub(name_for(id),
163 &code,
164 CodeOffsets::frame_never_safe,
165 sasm->frame_size(),
166 oop_maps,
167 sasm->must_gc_arguments());
168 // install blob
169 assert(blob != NULL, "blob must exist");
170 _blobs[id] = blob;
171 }
174 void Runtime1::initialize(BufferBlob* blob) {
175 // platform-dependent initialization
176 initialize_pd();
177 // generate stubs
178 for (int id = 0; id < number_of_ids; id++) generate_blob_for(blob, (StubID)id);
179 // printing
180 #ifndef PRODUCT
181 if (PrintSimpleStubs) {
182 ResourceMark rm;
183 for (int id = 0; id < number_of_ids; id++) {
184 _blobs[id]->print();
185 if (_blobs[id]->oop_maps() != NULL) {
186 _blobs[id]->oop_maps()->print();
187 }
188 }
189 }
190 #endif
191 }
194 CodeBlob* Runtime1::blob_for(StubID id) {
195 assert(0 <= id && id < number_of_ids, "illegal stub id");
196 return _blobs[id];
197 }
200 const char* Runtime1::name_for(StubID id) {
201 assert(0 <= id && id < number_of_ids, "illegal stub id");
202 return _blob_names[id];
203 }
205 const char* Runtime1::name_for_address(address entry) {
206 for (int id = 0; id < number_of_ids; id++) {
207 if (entry == entry_for((StubID)id)) return name_for((StubID)id);
208 }
210 #define FUNCTION_CASE(a, f) \
211 if ((intptr_t)a == CAST_FROM_FN_PTR(intptr_t, f)) return #f
213 FUNCTION_CASE(entry, os::javaTimeMillis);
214 FUNCTION_CASE(entry, os::javaTimeNanos);
215 FUNCTION_CASE(entry, SharedRuntime::OSR_migration_end);
216 FUNCTION_CASE(entry, SharedRuntime::d2f);
217 FUNCTION_CASE(entry, SharedRuntime::d2i);
218 FUNCTION_CASE(entry, SharedRuntime::d2l);
219 FUNCTION_CASE(entry, SharedRuntime::dcos);
220 FUNCTION_CASE(entry, SharedRuntime::dexp);
221 FUNCTION_CASE(entry, SharedRuntime::dlog);
222 FUNCTION_CASE(entry, SharedRuntime::dlog10);
223 FUNCTION_CASE(entry, SharedRuntime::dpow);
224 FUNCTION_CASE(entry, SharedRuntime::drem);
225 FUNCTION_CASE(entry, SharedRuntime::dsin);
226 FUNCTION_CASE(entry, SharedRuntime::dtan);
227 FUNCTION_CASE(entry, SharedRuntime::f2i);
228 FUNCTION_CASE(entry, SharedRuntime::f2l);
229 FUNCTION_CASE(entry, SharedRuntime::frem);
230 FUNCTION_CASE(entry, SharedRuntime::l2d);
231 FUNCTION_CASE(entry, SharedRuntime::l2f);
232 FUNCTION_CASE(entry, SharedRuntime::ldiv);
233 FUNCTION_CASE(entry, SharedRuntime::lmul);
234 FUNCTION_CASE(entry, SharedRuntime::lrem);
235 FUNCTION_CASE(entry, SharedRuntime::lrem);
236 FUNCTION_CASE(entry, SharedRuntime::dtrace_method_entry);
237 FUNCTION_CASE(entry, SharedRuntime::dtrace_method_exit);
238 FUNCTION_CASE(entry, trace_block_entry);
240 #undef FUNCTION_CASE
242 // Soft float adds more runtime names.
243 return pd_name_for_address(entry);
244 }
247 JRT_ENTRY(void, Runtime1::new_instance(JavaThread* thread, klassOopDesc* klass))
248 NOT_PRODUCT(_new_instance_slowcase_cnt++;)
250 assert(oop(klass)->is_klass(), "not a class");
251 instanceKlassHandle h(thread, klass);
252 h->check_valid_for_instantiation(true, CHECK);
253 // make sure klass is initialized
254 h->initialize(CHECK);
255 // allocate instance and return via TLS
256 oop obj = h->allocate_instance(CHECK);
257 thread->set_vm_result(obj);
258 JRT_END
261 JRT_ENTRY(void, Runtime1::new_type_array(JavaThread* thread, klassOopDesc* klass, jint length))
262 NOT_PRODUCT(_new_type_array_slowcase_cnt++;)
263 // Note: no handle for klass needed since they are not used
264 // anymore after new_typeArray() and no GC can happen before.
265 // (This may have to change if this code changes!)
266 assert(oop(klass)->is_klass(), "not a class");
267 BasicType elt_type = typeArrayKlass::cast(klass)->element_type();
268 oop obj = oopFactory::new_typeArray(elt_type, length, CHECK);
269 thread->set_vm_result(obj);
270 // This is pretty rare but this runtime patch is stressful to deoptimization
271 // if we deoptimize here so force a deopt to stress the path.
272 if (DeoptimizeALot) {
273 deopt_caller();
274 }
276 JRT_END
279 JRT_ENTRY(void, Runtime1::new_object_array(JavaThread* thread, klassOopDesc* array_klass, jint length))
280 NOT_PRODUCT(_new_object_array_slowcase_cnt++;)
282 // Note: no handle for klass needed since they are not used
283 // anymore after new_objArray() and no GC can happen before.
284 // (This may have to change if this code changes!)
285 assert(oop(array_klass)->is_klass(), "not a class");
286 klassOop elem_klass = objArrayKlass::cast(array_klass)->element_klass();
287 objArrayOop obj = oopFactory::new_objArray(elem_klass, length, CHECK);
288 thread->set_vm_result(obj);
289 // This is pretty rare but this runtime patch is stressful to deoptimization
290 // if we deoptimize here so force a deopt to stress the path.
291 if (DeoptimizeALot) {
292 deopt_caller();
293 }
294 JRT_END
297 JRT_ENTRY(void, Runtime1::new_multi_array(JavaThread* thread, klassOopDesc* klass, int rank, jint* dims))
298 NOT_PRODUCT(_new_multi_array_slowcase_cnt++;)
300 assert(oop(klass)->is_klass(), "not a class");
301 assert(rank >= 1, "rank must be nonzero");
302 oop obj = arrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK);
303 thread->set_vm_result(obj);
304 JRT_END
307 JRT_ENTRY(void, Runtime1::unimplemented_entry(JavaThread* thread, StubID id))
308 tty->print_cr("Runtime1::entry_for(%d) returned unimplemented entry point", id);
309 JRT_END
312 JRT_ENTRY(void, Runtime1::throw_array_store_exception(JavaThread* thread))
313 THROW(vmSymbolHandles::java_lang_ArrayStoreException());
314 JRT_END
317 JRT_ENTRY(void, Runtime1::post_jvmti_exception_throw(JavaThread* thread))
318 if (JvmtiExport::can_post_on_exceptions()) {
319 vframeStream vfst(thread, true);
320 address bcp = vfst.method()->bcp_from(vfst.bci());
321 JvmtiExport::post_exception_throw(thread, vfst.method(), bcp, thread->exception_oop());
322 }
323 JRT_END
325 #ifdef TIERED
326 JRT_ENTRY(void, Runtime1::counter_overflow(JavaThread* thread, int bci))
327 RegisterMap map(thread, false);
328 frame fr = thread->last_frame().sender(&map);
329 nmethod* nm = (nmethod*) fr.cb();
330 assert(nm!= NULL && nm->is_nmethod(), "what?");
331 methodHandle method(thread, nm->method());
332 if (bci == 0) {
333 // invocation counter overflow
334 if (!Tier1CountOnly) {
335 CompilationPolicy::policy()->method_invocation_event(method, CHECK);
336 } else {
337 method()->invocation_counter()->reset();
338 }
339 } else {
340 if (!Tier1CountOnly) {
341 // Twe have a bci but not the destination bci and besides a backedge
342 // event is more for OSR which we don't want here.
343 CompilationPolicy::policy()->method_invocation_event(method, CHECK);
344 } else {
345 method()->backedge_counter()->reset();
346 }
347 }
348 JRT_END
349 #endif // TIERED
351 extern void vm_exit(int code);
353 // Enter this method from compiled code handler below. This is where we transition
354 // to VM mode. This is done as a helper routine so that the method called directly
355 // from compiled code does not have to transition to VM. This allows the entry
356 // method to see if the nmethod that we have just looked up a handler for has
357 // been deoptimized while we were in the vm. This simplifies the assembly code
358 // cpu directories.
359 //
360 // We are entering here from exception stub (via the entry method below)
361 // If there is a compiled exception handler in this method, we will continue there;
362 // otherwise we will unwind the stack and continue at the caller of top frame method
363 // Note: we enter in Java using a special JRT wrapper. This wrapper allows us to
364 // control the area where we can allow a safepoint. After we exit the safepoint area we can
365 // check to see if the handler we are going to return is now in a nmethod that has
366 // been deoptimized. If that is the case we return the deopt blob
367 // unpack_with_exception entry instead. This makes life for the exception blob easier
368 // because making that same check and diverting is painful from assembly language.
369 //
372 JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* thread, oopDesc* ex, address pc, nmethod*& nm))
374 Handle exception(thread, ex);
375 nm = CodeCache::find_nmethod(pc);
376 assert(nm != NULL, "this is not an nmethod");
377 // Adjust the pc as needed/
378 if (nm->is_deopt_pc(pc)) {
379 RegisterMap map(thread, false);
380 frame exception_frame = thread->last_frame().sender(&map);
381 // if the frame isn't deopted then pc must not correspond to the caller of last_frame
382 assert(exception_frame.is_deoptimized_frame(), "must be deopted");
383 pc = exception_frame.pc();
384 }
385 #ifdef ASSERT
386 assert(exception.not_null(), "NULL exceptions should be handled by throw_exception");
387 assert(exception->is_oop(), "just checking");
388 // Check that exception is a subclass of Throwable, otherwise we have a VerifyError
389 if (!(exception->is_a(SystemDictionary::Throwable_klass()))) {
390 if (ExitVMOnVerifyError) vm_exit(-1);
391 ShouldNotReachHere();
392 }
393 #endif
395 // Check the stack guard pages and reenable them if necessary and there is
396 // enough space on the stack to do so. Use fast exceptions only if the guard
397 // pages are enabled.
398 bool guard_pages_enabled = thread->stack_yellow_zone_enabled();
399 if (!guard_pages_enabled) guard_pages_enabled = thread->reguard_stack();
401 if (JvmtiExport::can_post_on_exceptions()) {
402 // To ensure correct notification of exception catches and throws
403 // we have to deoptimize here. If we attempted to notify the
404 // catches and throws during this exception lookup it's possible
405 // we could deoptimize on the way out of the VM and end back in
406 // the interpreter at the throw site. This would result in double
407 // notifications since the interpreter would also notify about
408 // these same catches and throws as it unwound the frame.
410 RegisterMap reg_map(thread);
411 frame stub_frame = thread->last_frame();
412 frame caller_frame = stub_frame.sender(®_map);
414 // We don't really want to deoptimize the nmethod itself since we
415 // can actually continue in the exception handler ourselves but I
416 // don't see an easy way to have the desired effect.
417 VM_DeoptimizeFrame deopt(thread, caller_frame.id());
418 VMThread::execute(&deopt);
420 return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls();
421 }
423 // ExceptionCache is used only for exceptions at call and not for implicit exceptions
424 if (guard_pages_enabled) {
425 address fast_continuation = nm->handler_for_exception_and_pc(exception, pc);
426 if (fast_continuation != NULL) {
427 if (fast_continuation == ExceptionCache::unwind_handler()) fast_continuation = NULL;
428 return fast_continuation;
429 }
430 }
432 // If the stack guard pages are enabled, check whether there is a handler in
433 // the current method. Otherwise (guard pages disabled), force an unwind and
434 // skip the exception cache update (i.e., just leave continuation==NULL).
435 address continuation = NULL;
436 if (guard_pages_enabled) {
438 // New exception handling mechanism can support inlined methods
439 // with exception handlers since the mappings are from PC to PC
441 // debugging support
442 // tracing
443 if (TraceExceptions) {
444 ttyLocker ttyl;
445 ResourceMark rm;
446 tty->print_cr("Exception <%s> (0x%x) thrown in compiled method <%s> at PC " PTR_FORMAT " for thread 0x%x",
447 exception->print_value_string(), (address)exception(), nm->method()->print_value_string(), pc, thread);
448 }
449 // for AbortVMOnException flag
450 NOT_PRODUCT(Exceptions::debug_check_abort(exception));
452 // Clear out the exception oop and pc since looking up an
453 // exception handler can cause class loading, which might throw an
454 // exception and those fields are expected to be clear during
455 // normal bytecode execution.
456 thread->set_exception_oop(NULL);
457 thread->set_exception_pc(NULL);
459 continuation = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, false, false);
460 // If an exception was thrown during exception dispatch, the exception oop may have changed
461 thread->set_exception_oop(exception());
462 thread->set_exception_pc(pc);
464 // the exception cache is used only by non-implicit exceptions
465 if (continuation == NULL) {
466 nm->add_handler_for_exception_and_pc(exception, pc, ExceptionCache::unwind_handler());
467 } else {
468 nm->add_handler_for_exception_and_pc(exception, pc, continuation);
469 }
470 }
472 thread->set_vm_result(exception());
474 if (TraceExceptions) {
475 ttyLocker ttyl;
476 ResourceMark rm;
477 tty->print_cr("Thread " PTR_FORMAT " continuing at PC " PTR_FORMAT " for exception thrown at PC " PTR_FORMAT,
478 thread, continuation, pc);
479 }
481 return continuation;
482 JRT_END
484 // Enter this method from compiled code only if there is a Java exception handler
485 // in the method handling the exception
486 // We are entering here from exception stub. We don't do a normal VM transition here.
487 // We do it in a helper. This is so we can check to see if the nmethod we have just
488 // searched for an exception handler has been deoptimized in the meantime.
489 address Runtime1::exception_handler_for_pc(JavaThread* thread) {
490 oop exception = thread->exception_oop();
491 address pc = thread->exception_pc();
492 // Still in Java mode
493 debug_only(ResetNoHandleMark rnhm);
494 nmethod* nm = NULL;
495 address continuation = NULL;
496 {
497 // Enter VM mode by calling the helper
499 ResetNoHandleMark rnhm;
500 continuation = exception_handler_for_pc_helper(thread, exception, pc, nm);
501 }
502 // Back in JAVA, use no oops DON'T safepoint
504 // Now check to see if the nmethod we were called from is now deoptimized.
505 // If so we must return to the deopt blob and deoptimize the nmethod
507 if (nm != NULL && caller_is_deopted()) {
508 continuation = SharedRuntime::deopt_blob()->unpack_with_exception_in_tls();
509 }
511 return continuation;
512 }
515 JRT_ENTRY(void, Runtime1::throw_range_check_exception(JavaThread* thread, int index))
516 NOT_PRODUCT(_throw_range_check_exception_count++;)
517 Events::log("throw_range_check");
518 char message[jintAsStringSize];
519 sprintf(message, "%d", index);
520 SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), message);
521 JRT_END
524 JRT_ENTRY(void, Runtime1::throw_index_exception(JavaThread* thread, int index))
525 NOT_PRODUCT(_throw_index_exception_count++;)
526 Events::log("throw_index");
527 char message[16];
528 sprintf(message, "%d", index);
529 SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_IndexOutOfBoundsException(), message);
530 JRT_END
533 JRT_ENTRY(void, Runtime1::throw_div0_exception(JavaThread* thread))
534 NOT_PRODUCT(_throw_div0_exception_count++;)
535 SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_ArithmeticException(), "/ by zero");
536 JRT_END
539 JRT_ENTRY(void, Runtime1::throw_null_pointer_exception(JavaThread* thread))
540 NOT_PRODUCT(_throw_null_pointer_exception_count++;)
541 SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_NullPointerException());
542 JRT_END
545 JRT_ENTRY(void, Runtime1::throw_class_cast_exception(JavaThread* thread, oopDesc* object))
546 NOT_PRODUCT(_throw_class_cast_exception_count++;)
547 ResourceMark rm(thread);
548 char* message = SharedRuntime::generate_class_cast_message(
549 thread, Klass::cast(object->klass())->external_name());
550 SharedRuntime::throw_and_post_jvmti_exception(
551 thread, vmSymbols::java_lang_ClassCastException(), message);
552 JRT_END
555 JRT_ENTRY(void, Runtime1::throw_incompatible_class_change_error(JavaThread* thread))
556 NOT_PRODUCT(_throw_incompatible_class_change_error_count++;)
557 ResourceMark rm(thread);
558 SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_IncompatibleClassChangeError());
559 JRT_END
562 JRT_ENTRY_NO_ASYNC(void, Runtime1::monitorenter(JavaThread* thread, oopDesc* obj, BasicObjectLock* lock))
563 NOT_PRODUCT(_monitorenter_slowcase_cnt++;)
564 if (PrintBiasedLockingStatistics) {
565 Atomic::inc(BiasedLocking::slow_path_entry_count_addr());
566 }
567 Handle h_obj(thread, obj);
568 assert(h_obj()->is_oop(), "must be NULL or an object");
569 if (UseBiasedLocking) {
570 // Retry fast entry if bias is revoked to avoid unnecessary inflation
571 ObjectSynchronizer::fast_enter(h_obj, lock->lock(), true, CHECK);
572 } else {
573 if (UseFastLocking) {
574 // When using fast locking, the compiled code has already tried the fast case
575 assert(obj == lock->obj(), "must match");
576 ObjectSynchronizer::slow_enter(h_obj, lock->lock(), THREAD);
577 } else {
578 lock->set_obj(obj);
579 ObjectSynchronizer::fast_enter(h_obj, lock->lock(), false, THREAD);
580 }
581 }
582 JRT_END
585 JRT_LEAF(void, Runtime1::monitorexit(JavaThread* thread, BasicObjectLock* lock))
586 NOT_PRODUCT(_monitorexit_slowcase_cnt++;)
587 assert(thread == JavaThread::current(), "threads must correspond");
588 assert(thread->last_Java_sp(), "last_Java_sp must be set");
589 // monitorexit is non-blocking (leaf routine) => no exceptions can be thrown
590 EXCEPTION_MARK;
592 oop obj = lock->obj();
593 assert(obj->is_oop(), "must be NULL or an object");
594 if (UseFastLocking) {
595 // When using fast locking, the compiled code has already tried the fast case
596 ObjectSynchronizer::slow_exit(obj, lock->lock(), THREAD);
597 } else {
598 ObjectSynchronizer::fast_exit(obj, lock->lock(), THREAD);
599 }
600 JRT_END
603 static klassOop resolve_field_return_klass(methodHandle caller, int bci, TRAPS) {
604 Bytecode_field* field_access = Bytecode_field_at(caller, bci);
605 // This can be static or non-static field access
606 Bytecodes::Code code = field_access->code();
608 // We must load class, initialize class and resolvethe field
609 FieldAccessInfo result; // initialize class if needed
610 constantPoolHandle constants(THREAD, caller->constants());
611 LinkResolver::resolve_field(result, constants, field_access->index(), Bytecodes::java_code(code), false, CHECK_NULL);
612 return result.klass()();
613 }
616 //
617 // This routine patches sites where a class wasn't loaded or
618 // initialized at the time the code was generated. It handles
619 // references to classes, fields and forcing of initialization. Most
620 // of the cases are straightforward and involving simply forcing
621 // resolution of a class, rewriting the instruction stream with the
622 // needed constant and replacing the call in this function with the
623 // patched code. The case for static field is more complicated since
624 // the thread which is in the process of initializing a class can
625 // access it's static fields but other threads can't so the code
626 // either has to deoptimize when this case is detected or execute a
627 // check that the current thread is the initializing thread. The
628 // current
629 //
630 // Patches basically look like this:
631 //
632 //
633 // patch_site: jmp patch stub ;; will be patched
634 // continue: ...
635 // ...
636 // ...
637 // ...
638 //
639 // They have a stub which looks like this:
640 //
641 // ;; patch body
642 // movl <const>, reg (for class constants)
643 // <or> movl [reg1 + <const>], reg (for field offsets)
644 // <or> movl reg, [reg1 + <const>] (for field offsets)
645 // <being_init offset> <bytes to copy> <bytes to skip>
646 // patch_stub: call Runtime1::patch_code (through a runtime stub)
647 // jmp patch_site
648 //
649 //
650 // A normal patch is done by rewriting the patch body, usually a move,
651 // and then copying it into place over top of the jmp instruction
652 // being careful to flush caches and doing it in an MP-safe way. The
653 // constants following the patch body are used to find various pieces
654 // of the patch relative to the call site for Runtime1::patch_code.
655 // The case for getstatic and putstatic is more complicated because
656 // getstatic and putstatic have special semantics when executing while
657 // the class is being initialized. getstatic/putstatic on a class
658 // which is being_initialized may be executed by the initializing
659 // thread but other threads have to block when they execute it. This
660 // is accomplished in compiled code by executing a test of the current
661 // thread against the initializing thread of the class. It's emitted
662 // as boilerplate in their stub which allows the patched code to be
663 // executed before it's copied back into the main body of the nmethod.
664 //
665 // being_init: get_thread(<tmp reg>
666 // cmpl [reg1 + <init_thread_offset>], <tmp reg>
667 // jne patch_stub
668 // movl [reg1 + <const>], reg (for field offsets) <or>
669 // movl reg, [reg1 + <const>] (for field offsets)
670 // jmp continue
671 // <being_init offset> <bytes to copy> <bytes to skip>
672 // patch_stub: jmp Runtim1::patch_code (through a runtime stub)
673 // jmp patch_site
674 //
675 // If the class is being initialized the patch body is rewritten and
676 // the patch site is rewritten to jump to being_init, instead of
677 // patch_stub. Whenever this code is executed it checks the current
678 // thread against the intializing thread so other threads will enter
679 // the runtime and end up blocked waiting the class to finish
680 // initializing inside the calls to resolve_field below. The
681 // initializing class will continue on it's way. Once the class is
682 // fully_initialized, the intializing_thread of the class becomes
683 // NULL, so the next thread to execute this code will fail the test,
684 // call into patch_code and complete the patching process by copying
685 // the patch body back into the main part of the nmethod and resume
686 // executing.
687 //
688 //
690 JRT_ENTRY(void, Runtime1::patch_code(JavaThread* thread, Runtime1::StubID stub_id ))
691 NOT_PRODUCT(_patch_code_slowcase_cnt++;)
693 ResourceMark rm(thread);
694 RegisterMap reg_map(thread, false);
695 frame runtime_frame = thread->last_frame();
696 frame caller_frame = runtime_frame.sender(®_map);
698 // last java frame on stack
699 vframeStream vfst(thread, true);
700 assert(!vfst.at_end(), "Java frame must exist");
702 methodHandle caller_method(THREAD, vfst.method());
703 // Note that caller_method->code() may not be same as caller_code because of OSR's
704 // Note also that in the presence of inlining it is not guaranteed
705 // that caller_method() == caller_code->method()
708 int bci = vfst.bci();
710 Events::log("patch_code @ " INTPTR_FORMAT , caller_frame.pc());
712 Bytecodes::Code code = Bytecode_at(caller_method->bcp_from(bci))->java_code();
714 #ifndef PRODUCT
715 // this is used by assertions in the access_field_patching_id
716 BasicType patch_field_type = T_ILLEGAL;
717 #endif // PRODUCT
718 bool deoptimize_for_volatile = false;
719 int patch_field_offset = -1;
720 KlassHandle init_klass(THREAD, klassOop(NULL)); // klass needed by access_field_patching code
721 Handle load_klass(THREAD, NULL); // oop needed by load_klass_patching code
722 if (stub_id == Runtime1::access_field_patching_id) {
724 Bytecode_field* field_access = Bytecode_field_at(caller_method, bci);
725 FieldAccessInfo result; // initialize class if needed
726 Bytecodes::Code code = field_access->code();
727 constantPoolHandle constants(THREAD, caller_method->constants());
728 LinkResolver::resolve_field(result, constants, field_access->index(), Bytecodes::java_code(code), false, CHECK);
729 patch_field_offset = result.field_offset();
731 // If we're patching a field which is volatile then at compile it
732 // must not have been know to be volatile, so the generated code
733 // isn't correct for a volatile reference. The nmethod has to be
734 // deoptimized so that the code can be regenerated correctly.
735 // This check is only needed for access_field_patching since this
736 // is the path for patching field offsets. load_klass is only
737 // used for patching references to oops which don't need special
738 // handling in the volatile case.
739 deoptimize_for_volatile = result.access_flags().is_volatile();
741 #ifndef PRODUCT
742 patch_field_type = result.field_type();
743 #endif
744 } else if (stub_id == Runtime1::load_klass_patching_id) {
745 oop k;
746 switch (code) {
747 case Bytecodes::_putstatic:
748 case Bytecodes::_getstatic:
749 { klassOop klass = resolve_field_return_klass(caller_method, bci, CHECK);
750 // Save a reference to the class that has to be checked for initialization
751 init_klass = KlassHandle(THREAD, klass);
752 k = klass;
753 }
754 break;
755 case Bytecodes::_new:
756 { Bytecode_new* bnew = Bytecode_new_at(caller_method->bcp_from(bci));
757 k = caller_method->constants()->klass_at(bnew->index(), CHECK);
758 }
759 break;
760 case Bytecodes::_multianewarray:
761 { Bytecode_multianewarray* mna = Bytecode_multianewarray_at(caller_method->bcp_from(bci));
762 k = caller_method->constants()->klass_at(mna->index(), CHECK);
763 }
764 break;
765 case Bytecodes::_instanceof:
766 { Bytecode_instanceof* io = Bytecode_instanceof_at(caller_method->bcp_from(bci));
767 k = caller_method->constants()->klass_at(io->index(), CHECK);
768 }
769 break;
770 case Bytecodes::_checkcast:
771 { Bytecode_checkcast* cc = Bytecode_checkcast_at(caller_method->bcp_from(bci));
772 k = caller_method->constants()->klass_at(cc->index(), CHECK);
773 }
774 break;
775 case Bytecodes::_anewarray:
776 { Bytecode_anewarray* anew = Bytecode_anewarray_at(caller_method->bcp_from(bci));
777 klassOop ek = caller_method->constants()->klass_at(anew->index(), CHECK);
778 k = Klass::cast(ek)->array_klass(CHECK);
779 }
780 break;
781 case Bytecodes::_ldc:
782 case Bytecodes::_ldc_w:
783 {
784 Bytecode_loadconstant* cc = Bytecode_loadconstant_at(caller_method, bci);
785 k = cc->resolve_constant(CHECK);
786 assert(k != NULL && !k->is_klass(), "must be class mirror or other Java constant");
787 }
788 break;
789 default: Unimplemented();
790 }
791 // convert to handle
792 load_klass = Handle(THREAD, k);
793 } else {
794 ShouldNotReachHere();
795 }
797 if (deoptimize_for_volatile) {
798 // At compile time we assumed the field wasn't volatile but after
799 // loading it turns out it was volatile so we have to throw the
800 // compiled code out and let it be regenerated.
801 if (TracePatching) {
802 tty->print_cr("Deoptimizing for patching volatile field reference");
803 }
804 // It's possible the nmethod was invalidated in the last
805 // safepoint, but if it's still alive then make it not_entrant.
806 nmethod* nm = CodeCache::find_nmethod(caller_frame.pc());
807 if (nm != NULL) {
808 nm->make_not_entrant();
809 }
811 VM_DeoptimizeFrame deopt(thread, caller_frame.id());
812 VMThread::execute(&deopt);
814 // Return to the now deoptimized frame.
815 }
817 // If we are patching in a non-perm oop, make sure the nmethod
818 // is on the right list.
819 if (ScavengeRootsInCode && load_klass.not_null() && load_klass->is_scavengable()) {
820 MutexLockerEx ml_code (CodeCache_lock, Mutex::_no_safepoint_check_flag);
821 nmethod* nm = CodeCache::find_nmethod(caller_frame.pc());
822 guarantee(nm != NULL, "only nmethods can contain non-perm oops");
823 if (!nm->on_scavenge_root_list())
824 CodeCache::add_scavenge_root_nmethod(nm);
825 }
827 // Now copy code back
829 {
830 MutexLockerEx ml_patch (Patching_lock, Mutex::_no_safepoint_check_flag);
831 //
832 // Deoptimization may have happened while we waited for the lock.
833 // In that case we don't bother to do any patching we just return
834 // and let the deopt happen
835 if (!caller_is_deopted()) {
836 NativeGeneralJump* jump = nativeGeneralJump_at(caller_frame.pc());
837 address instr_pc = jump->jump_destination();
838 NativeInstruction* ni = nativeInstruction_at(instr_pc);
839 if (ni->is_jump() ) {
840 // the jump has not been patched yet
841 // The jump destination is slow case and therefore not part of the stubs
842 // (stubs are only for StaticCalls)
844 // format of buffer
845 // ....
846 // instr byte 0 <-- copy_buff
847 // instr byte 1
848 // ..
849 // instr byte n-1
850 // n
851 // .... <-- call destination
853 address stub_location = caller_frame.pc() + PatchingStub::patch_info_offset();
854 unsigned char* byte_count = (unsigned char*) (stub_location - 1);
855 unsigned char* byte_skip = (unsigned char*) (stub_location - 2);
856 unsigned char* being_initialized_entry_offset = (unsigned char*) (stub_location - 3);
857 address copy_buff = stub_location - *byte_skip - *byte_count;
858 address being_initialized_entry = stub_location - *being_initialized_entry_offset;
859 if (TracePatching) {
860 tty->print_cr(" Patching %s at bci %d at address 0x%x (%s)", Bytecodes::name(code), bci,
861 instr_pc, (stub_id == Runtime1::access_field_patching_id) ? "field" : "klass");
862 nmethod* caller_code = CodeCache::find_nmethod(caller_frame.pc());
863 assert(caller_code != NULL, "nmethod not found");
865 // NOTE we use pc() not original_pc() because we already know they are
866 // identical otherwise we'd have never entered this block of code
868 OopMap* map = caller_code->oop_map_for_return_address(caller_frame.pc());
869 assert(map != NULL, "null check");
870 map->print();
871 tty->cr();
873 Disassembler::decode(copy_buff, copy_buff + *byte_count, tty);
874 }
875 // depending on the code below, do_patch says whether to copy the patch body back into the nmethod
876 bool do_patch = true;
877 if (stub_id == Runtime1::access_field_patching_id) {
878 // The offset may not be correct if the class was not loaded at code generation time.
879 // Set it now.
880 NativeMovRegMem* n_move = nativeMovRegMem_at(copy_buff);
881 assert(n_move->offset() == 0 || (n_move->offset() == 4 && (patch_field_type == T_DOUBLE || patch_field_type == T_LONG)), "illegal offset for type");
882 assert(patch_field_offset >= 0, "illegal offset");
883 n_move->add_offset_in_bytes(patch_field_offset);
884 } else if (stub_id == Runtime1::load_klass_patching_id) {
885 // If a getstatic or putstatic is referencing a klass which
886 // isn't fully initialized, the patch body isn't copied into
887 // place until initialization is complete. In this case the
888 // patch site is setup so that any threads besides the
889 // initializing thread are forced to come into the VM and
890 // block.
891 do_patch = (code != Bytecodes::_getstatic && code != Bytecodes::_putstatic) ||
892 instanceKlass::cast(init_klass())->is_initialized();
893 NativeGeneralJump* jump = nativeGeneralJump_at(instr_pc);
894 if (jump->jump_destination() == being_initialized_entry) {
895 assert(do_patch == true, "initialization must be complete at this point");
896 } else {
897 // patch the instruction <move reg, klass>
898 NativeMovConstReg* n_copy = nativeMovConstReg_at(copy_buff);
900 assert(n_copy->data() == 0 ||
901 n_copy->data() == (int)Universe::non_oop_word(),
902 "illegal init value");
903 assert(load_klass() != NULL, "klass not set");
904 n_copy->set_data((intx) (load_klass()));
906 if (TracePatching) {
907 Disassembler::decode(copy_buff, copy_buff + *byte_count, tty);
908 }
910 #if defined(SPARC) || defined(PPC)
911 // Update the oop location in the nmethod with the proper
912 // oop. When the code was generated, a NULL was stuffed
913 // in the oop table and that table needs to be update to
914 // have the right value. On intel the value is kept
915 // directly in the instruction instead of in the oop
916 // table, so set_data above effectively updated the value.
917 nmethod* nm = CodeCache::find_nmethod(instr_pc);
918 assert(nm != NULL, "invalid nmethod_pc");
919 RelocIterator oops(nm, copy_buff, copy_buff + 1);
920 bool found = false;
921 while (oops.next() && !found) {
922 if (oops.type() == relocInfo::oop_type) {
923 oop_Relocation* r = oops.oop_reloc();
924 oop* oop_adr = r->oop_addr();
925 *oop_adr = load_klass();
926 r->fix_oop_relocation();
927 found = true;
928 }
929 }
930 assert(found, "the oop must exist!");
931 #endif
933 }
934 } else {
935 ShouldNotReachHere();
936 }
937 if (do_patch) {
938 // replace instructions
939 // first replace the tail, then the call
940 #ifdef ARM
941 if(stub_id == Runtime1::load_klass_patching_id && !VM_Version::supports_movw()) {
942 copy_buff -= *byte_count;
943 NativeMovConstReg* n_copy2 = nativeMovConstReg_at(copy_buff);
944 n_copy2->set_data((intx) (load_klass()), instr_pc);
945 }
946 #endif
948 for (int i = NativeCall::instruction_size; i < *byte_count; i++) {
949 address ptr = copy_buff + i;
950 int a_byte = (*ptr) & 0xFF;
951 address dst = instr_pc + i;
952 *(unsigned char*)dst = (unsigned char) a_byte;
953 }
954 ICache::invalidate_range(instr_pc, *byte_count);
955 NativeGeneralJump::replace_mt_safe(instr_pc, copy_buff);
957 if (stub_id == Runtime1::load_klass_patching_id) {
958 // update relocInfo to oop
959 nmethod* nm = CodeCache::find_nmethod(instr_pc);
960 assert(nm != NULL, "invalid nmethod_pc");
962 // The old patch site is now a move instruction so update
963 // the reloc info so that it will get updated during
964 // future GCs.
965 RelocIterator iter(nm, (address)instr_pc, (address)(instr_pc + 1));
966 relocInfo::change_reloc_info_for_address(&iter, (address) instr_pc,
967 relocInfo::none, relocInfo::oop_type);
968 #ifdef SPARC
969 // Sparc takes two relocations for an oop so update the second one.
970 address instr_pc2 = instr_pc + NativeMovConstReg::add_offset;
971 RelocIterator iter2(nm, instr_pc2, instr_pc2 + 1);
972 relocInfo::change_reloc_info_for_address(&iter2, (address) instr_pc2,
973 relocInfo::none, relocInfo::oop_type);
974 #endif
975 #ifdef PPC
976 { address instr_pc2 = instr_pc + NativeMovConstReg::lo_offset;
977 RelocIterator iter2(nm, instr_pc2, instr_pc2 + 1);
978 relocInfo::change_reloc_info_for_address(&iter2, (address) instr_pc2, relocInfo::none, relocInfo::oop_type);
979 }
980 #endif
981 }
983 } else {
984 ICache::invalidate_range(copy_buff, *byte_count);
985 NativeGeneralJump::insert_unconditional(instr_pc, being_initialized_entry);
986 }
987 }
988 }
989 }
990 JRT_END
992 //
993 // Entry point for compiled code. We want to patch a nmethod.
994 // We don't do a normal VM transition here because we want to
995 // know after the patching is complete and any safepoint(s) are taken
996 // if the calling nmethod was deoptimized. We do this by calling a
997 // helper method which does the normal VM transition and when it
998 // completes we can check for deoptimization. This simplifies the
999 // assembly code in the cpu directories.
1000 //
1001 int Runtime1::move_klass_patching(JavaThread* thread) {
1002 //
1003 // NOTE: we are still in Java
1004 //
1005 Thread* THREAD = thread;
1006 debug_only(NoHandleMark nhm;)
1007 {
1008 // Enter VM mode
1010 ResetNoHandleMark rnhm;
1011 patch_code(thread, load_klass_patching_id);
1012 }
1013 // Back in JAVA, use no oops DON'T safepoint
1015 // Return true if calling code is deoptimized
1017 return caller_is_deopted();
1018 }
1020 //
1021 // Entry point for compiled code. We want to patch a nmethod.
1022 // We don't do a normal VM transition here because we want to
1023 // know after the patching is complete and any safepoint(s) are taken
1024 // if the calling nmethod was deoptimized. We do this by calling a
1025 // helper method which does the normal VM transition and when it
1026 // completes we can check for deoptimization. This simplifies the
1027 // assembly code in the cpu directories.
1028 //
1030 int Runtime1::access_field_patching(JavaThread* thread) {
1031 //
1032 // NOTE: we are still in Java
1033 //
1034 Thread* THREAD = thread;
1035 debug_only(NoHandleMark nhm;)
1036 {
1037 // Enter VM mode
1039 ResetNoHandleMark rnhm;
1040 patch_code(thread, access_field_patching_id);
1041 }
1042 // Back in JAVA, use no oops DON'T safepoint
1044 // Return true if calling code is deoptimized
1046 return caller_is_deopted();
1047 JRT_END
1050 JRT_LEAF(void, Runtime1::trace_block_entry(jint block_id))
1051 // for now we just print out the block id
1052 tty->print("%d ", block_id);
1053 JRT_END
1056 // Array copy return codes.
1057 enum {
1058 ac_failed = -1, // arraycopy failed
1059 ac_ok = 0 // arraycopy succeeded
1060 };
1063 // Below length is the # elements copied.
1064 template <class T> int obj_arraycopy_work(oopDesc* src, T* src_addr,
1065 oopDesc* dst, T* dst_addr,
1066 int length) {
1068 // For performance reasons, we assume we are using a card marking write
1069 // barrier. The assert will fail if this is not the case.
1070 // Note that we use the non-virtual inlineable variant of write_ref_array.
1071 BarrierSet* bs = Universe::heap()->barrier_set();
1072 assert(bs->has_write_ref_array_opt(), "Barrier set must have ref array opt");
1073 assert(bs->has_write_ref_array_pre_opt(), "For pre-barrier as well.");
1074 if (src == dst) {
1075 // same object, no check
1076 bs->write_ref_array_pre(dst_addr, length);
1077 Copy::conjoint_oops_atomic(src_addr, dst_addr, length);
1078 bs->write_ref_array((HeapWord*)dst_addr, length);
1079 return ac_ok;
1080 } else {
1081 klassOop bound = objArrayKlass::cast(dst->klass())->element_klass();
1082 klassOop stype = objArrayKlass::cast(src->klass())->element_klass();
1083 if (stype == bound || Klass::cast(stype)->is_subtype_of(bound)) {
1084 // Elements are guaranteed to be subtypes, so no check necessary
1085 bs->write_ref_array_pre(dst_addr, length);
1086 Copy::conjoint_oops_atomic(src_addr, dst_addr, length);
1087 bs->write_ref_array((HeapWord*)dst_addr, length);
1088 return ac_ok;
1089 }
1090 }
1091 return ac_failed;
1092 }
1094 // fast and direct copy of arrays; returning -1, means that an exception may be thrown
1095 // and we did not copy anything
1096 JRT_LEAF(int, Runtime1::arraycopy(oopDesc* src, int src_pos, oopDesc* dst, int dst_pos, int length))
1097 #ifndef PRODUCT
1098 _generic_arraycopy_cnt++; // Slow-path oop array copy
1099 #endif
1101 if (src == NULL || dst == NULL || src_pos < 0 || dst_pos < 0 || length < 0) return ac_failed;
1102 if (!dst->is_array() || !src->is_array()) return ac_failed;
1103 if ((unsigned int) arrayOop(src)->length() < (unsigned int)src_pos + (unsigned int)length) return ac_failed;
1104 if ((unsigned int) arrayOop(dst)->length() < (unsigned int)dst_pos + (unsigned int)length) return ac_failed;
1106 if (length == 0) return ac_ok;
1107 if (src->is_typeArray()) {
1108 const klassOop klass_oop = src->klass();
1109 if (klass_oop != dst->klass()) return ac_failed;
1110 typeArrayKlass* klass = typeArrayKlass::cast(klass_oop);
1111 const int l2es = klass->log2_element_size();
1112 const int ihs = klass->array_header_in_bytes() / wordSize;
1113 char* src_addr = (char*) ((oopDesc**)src + ihs) + (src_pos << l2es);
1114 char* dst_addr = (char*) ((oopDesc**)dst + ihs) + (dst_pos << l2es);
1115 // Potential problem: memmove is not guaranteed to be word atomic
1116 // Revisit in Merlin
1117 memmove(dst_addr, src_addr, length << l2es);
1118 return ac_ok;
1119 } else if (src->is_objArray() && dst->is_objArray()) {
1120 if (UseCompressedOops) { // will need for tiered
1121 narrowOop *src_addr = objArrayOop(src)->obj_at_addr<narrowOop>(src_pos);
1122 narrowOop *dst_addr = objArrayOop(dst)->obj_at_addr<narrowOop>(dst_pos);
1123 return obj_arraycopy_work(src, src_addr, dst, dst_addr, length);
1124 } else {
1125 oop *src_addr = objArrayOop(src)->obj_at_addr<oop>(src_pos);
1126 oop *dst_addr = objArrayOop(dst)->obj_at_addr<oop>(dst_pos);
1127 return obj_arraycopy_work(src, src_addr, dst, dst_addr, length);
1128 }
1129 }
1130 return ac_failed;
1131 JRT_END
1134 JRT_LEAF(void, Runtime1::primitive_arraycopy(HeapWord* src, HeapWord* dst, int length))
1135 #ifndef PRODUCT
1136 _primitive_arraycopy_cnt++;
1137 #endif
1139 if (length == 0) return;
1140 // Not guaranteed to be word atomic, but that doesn't matter
1141 // for anything but an oop array, which is covered by oop_arraycopy.
1142 Copy::conjoint_jbytes(src, dst, length);
1143 JRT_END
1145 JRT_LEAF(void, Runtime1::oop_arraycopy(HeapWord* src, HeapWord* dst, int num))
1146 #ifndef PRODUCT
1147 _oop_arraycopy_cnt++;
1148 #endif
1150 if (num == 0) return;
1151 BarrierSet* bs = Universe::heap()->barrier_set();
1152 assert(bs->has_write_ref_array_opt(), "Barrier set must have ref array opt");
1153 assert(bs->has_write_ref_array_pre_opt(), "For pre-barrier as well.");
1154 if (UseCompressedOops) {
1155 bs->write_ref_array_pre((narrowOop*)dst, num);
1156 } else {
1157 bs->write_ref_array_pre((oop*)dst, num);
1158 }
1159 Copy::conjoint_oops_atomic((oop*) src, (oop*) dst, num);
1160 bs->write_ref_array(dst, num);
1161 JRT_END
1164 #ifndef PRODUCT
1165 void Runtime1::print_statistics() {
1166 tty->print_cr("C1 Runtime statistics:");
1167 tty->print_cr(" _resolve_invoke_virtual_cnt: %d", SharedRuntime::_resolve_virtual_ctr);
1168 tty->print_cr(" _resolve_invoke_opt_virtual_cnt: %d", SharedRuntime::_resolve_opt_virtual_ctr);
1169 tty->print_cr(" _resolve_invoke_static_cnt: %d", SharedRuntime::_resolve_static_ctr);
1170 tty->print_cr(" _handle_wrong_method_cnt: %d", SharedRuntime::_wrong_method_ctr);
1171 tty->print_cr(" _ic_miss_cnt: %d", SharedRuntime::_ic_miss_ctr);
1172 tty->print_cr(" _generic_arraycopy_cnt: %d", _generic_arraycopy_cnt);
1173 tty->print_cr(" _primitive_arraycopy_cnt: %d", _primitive_arraycopy_cnt);
1174 tty->print_cr(" _oop_arraycopy_cnt: %d", _oop_arraycopy_cnt);
1175 tty->print_cr(" _arraycopy_slowcase_cnt: %d", _arraycopy_slowcase_cnt);
1177 tty->print_cr(" _new_type_array_slowcase_cnt: %d", _new_type_array_slowcase_cnt);
1178 tty->print_cr(" _new_object_array_slowcase_cnt: %d", _new_object_array_slowcase_cnt);
1179 tty->print_cr(" _new_instance_slowcase_cnt: %d", _new_instance_slowcase_cnt);
1180 tty->print_cr(" _new_multi_array_slowcase_cnt: %d", _new_multi_array_slowcase_cnt);
1181 tty->print_cr(" _monitorenter_slowcase_cnt: %d", _monitorenter_slowcase_cnt);
1182 tty->print_cr(" _monitorexit_slowcase_cnt: %d", _monitorexit_slowcase_cnt);
1183 tty->print_cr(" _patch_code_slowcase_cnt: %d", _patch_code_slowcase_cnt);
1185 tty->print_cr(" _throw_range_check_exception_count: %d:", _throw_range_check_exception_count);
1186 tty->print_cr(" _throw_index_exception_count: %d:", _throw_index_exception_count);
1187 tty->print_cr(" _throw_div0_exception_count: %d:", _throw_div0_exception_count);
1188 tty->print_cr(" _throw_null_pointer_exception_count: %d:", _throw_null_pointer_exception_count);
1189 tty->print_cr(" _throw_class_cast_exception_count: %d:", _throw_class_cast_exception_count);
1190 tty->print_cr(" _throw_incompatible_class_change_error_count: %d:", _throw_incompatible_class_change_error_count);
1191 tty->print_cr(" _throw_array_store_exception_count: %d:", _throw_array_store_exception_count);
1192 tty->print_cr(" _throw_count: %d:", _throw_count);
1194 SharedRuntime::print_ic_miss_histogram();
1195 tty->cr();
1196 }
1197 #endif // PRODUCT