1 /* 2 * Copyright (c) 1999, 2021, 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 */ 24 25 #include "precompiled.hpp" 26 #include "asm/codeBuffer.hpp" 27 #include "c1/c1_CodeStubs.hpp" 28 #include "c1/c1_Defs.hpp" 29 #include "c1/c1_FrameMap.hpp" 30 #include "c1/c1_LIRAssembler.hpp" 31 #include "c1/c1_MacroAssembler.hpp" 32 #include "c1/c1_Runtime1.hpp" 33 #include "classfile/javaClasses.inline.hpp" 34 #include "classfile/vmClasses.hpp" 35 #include "classfile/vmSymbols.hpp" 36 #include "code/codeBlob.hpp" 37 #include "code/compiledIC.hpp" 38 #include "code/pcDesc.hpp" 39 #include "code/scopeDesc.hpp" 40 #include "code/vtableStubs.hpp" 41 #include "compiler/compilationPolicy.hpp" 42 #include "compiler/disassembler.hpp" 43 #include "compiler/oopMap.hpp" 44 #include "gc/shared/barrierSet.hpp" 45 #include "gc/shared/c1/barrierSetC1.hpp" 46 #include "gc/shared/collectedHeap.hpp" 47 #include "interpreter/bytecode.hpp" 48 #include "interpreter/interpreter.hpp" 49 #include "jfr/support/jfrIntrinsics.hpp" 50 #include "logging/log.hpp" 51 #include "memory/allocation.inline.hpp" 52 #include "memory/oopFactory.hpp" 53 #include "memory/resourceArea.hpp" 54 #include "memory/universe.hpp" 55 #include "oops/access.inline.hpp" 56 #include "oops/flatArrayKlass.hpp" 57 #include "oops/flatArrayOop.inline.hpp" 58 #include "oops/klass.inline.hpp" 59 #include "oops/objArrayOop.inline.hpp" 60 #include "oops/objArrayKlass.hpp" 61 #include "oops/oop.inline.hpp" 62 #include "prims/jvmtiExport.hpp" 63 #include "runtime/atomic.hpp" 64 #include "runtime/fieldDescriptor.inline.hpp" 65 #include "runtime/frame.inline.hpp" 66 #include "runtime/handles.inline.hpp" 67 #include "runtime/interfaceSupport.inline.hpp" 68 #include "runtime/javaCalls.hpp" 69 #include "runtime/sharedRuntime.hpp" 70 #include "runtime/stackWatermarkSet.hpp" 71 #include "runtime/stubRoutines.hpp" 72 #include "runtime/threadCritical.hpp" 73 #include "runtime/vframe.inline.hpp" 74 #include "runtime/vframeArray.hpp" 75 #include "runtime/vm_version.hpp" 76 #include "utilities/copy.hpp" 77 #include "utilities/events.hpp" 78 79 80 // Implementation of StubAssembler 81 82 StubAssembler::StubAssembler(CodeBuffer* code, const char * name, int stub_id) : C1_MacroAssembler(code) { 83 _name = name; 84 _must_gc_arguments = false; 85 _frame_size = no_frame_size; 86 _num_rt_args = 0; 87 _stub_id = stub_id; 88 } 89 90 91 void StubAssembler::set_info(const char* name, bool must_gc_arguments) { 92 _name = name; 93 _must_gc_arguments = must_gc_arguments; 94 } 95 96 97 void StubAssembler::set_frame_size(int size) { 98 if (_frame_size == no_frame_size) { 99 _frame_size = size; 100 } 101 assert(_frame_size == size, "can't change the frame size"); 102 } 103 104 105 void StubAssembler::set_num_rt_args(int args) { 106 if (_num_rt_args == 0) { 107 _num_rt_args = args; 108 } 109 assert(_num_rt_args == args, "can't change the number of args"); 110 } 111 112 // Implementation of Runtime1 113 114 CodeBlob* Runtime1::_blobs[Runtime1::number_of_ids]; 115 const char *Runtime1::_blob_names[] = { 116 RUNTIME1_STUBS(STUB_NAME, LAST_STUB_NAME) 117 }; 118 119 #ifndef PRODUCT 120 // statistics 121 int Runtime1::_generic_arraycopystub_cnt = 0; 122 int Runtime1::_arraycopy_slowcase_cnt = 0; 123 int Runtime1::_arraycopy_checkcast_cnt = 0; 124 int Runtime1::_arraycopy_checkcast_attempt_cnt = 0; 125 int Runtime1::_new_type_array_slowcase_cnt = 0; 126 int Runtime1::_new_object_array_slowcase_cnt = 0; 127 int Runtime1::_new_flat_array_slowcase_cnt = 0; 128 int Runtime1::_new_instance_slowcase_cnt = 0; 129 int Runtime1::_new_multi_array_slowcase_cnt = 0; 130 int Runtime1::_load_flattened_array_slowcase_cnt = 0; 131 int Runtime1::_store_flattened_array_slowcase_cnt = 0; 132 int Runtime1::_substitutability_check_slowcase_cnt = 0; 133 int Runtime1::_buffer_inline_args_slowcase_cnt = 0; 134 int Runtime1::_buffer_inline_args_no_receiver_slowcase_cnt = 0; 135 int Runtime1::_monitorenter_slowcase_cnt = 0; 136 int Runtime1::_monitorexit_slowcase_cnt = 0; 137 int Runtime1::_patch_code_slowcase_cnt = 0; 138 int Runtime1::_throw_range_check_exception_count = 0; 139 int Runtime1::_throw_index_exception_count = 0; 140 int Runtime1::_throw_div0_exception_count = 0; 141 int Runtime1::_throw_null_pointer_exception_count = 0; 142 int Runtime1::_throw_class_cast_exception_count = 0; 143 int Runtime1::_throw_incompatible_class_change_error_count = 0; 144 int Runtime1::_throw_illegal_monitor_state_exception_count = 0; 145 int Runtime1::_throw_count = 0; 146 147 static int _byte_arraycopy_stub_cnt = 0; 148 static int _short_arraycopy_stub_cnt = 0; 149 static int _int_arraycopy_stub_cnt = 0; 150 static int _long_arraycopy_stub_cnt = 0; 151 static int _oop_arraycopy_stub_cnt = 0; 152 153 address Runtime1::arraycopy_count_address(BasicType type) { 154 switch (type) { 155 case T_BOOLEAN: 156 case T_BYTE: return (address)&_byte_arraycopy_stub_cnt; 157 case T_CHAR: 158 case T_SHORT: return (address)&_short_arraycopy_stub_cnt; 159 case T_FLOAT: 160 case T_INT: return (address)&_int_arraycopy_stub_cnt; 161 case T_DOUBLE: 162 case T_LONG: return (address)&_long_arraycopy_stub_cnt; 163 case T_ARRAY: 164 case T_OBJECT: return (address)&_oop_arraycopy_stub_cnt; 165 default: 166 ShouldNotReachHere(); 167 return NULL; 168 } 169 } 170 171 172 #endif 173 174 // Simple helper to see if the caller of a runtime stub which 175 // entered the VM has been deoptimized 176 177 static bool caller_is_deopted(JavaThread* current) { 178 RegisterMap reg_map(current, false); 179 frame runtime_frame = current->last_frame(); 180 frame caller_frame = runtime_frame.sender(®_map); 181 assert(caller_frame.is_compiled_frame(), "must be compiled"); 182 return caller_frame.is_deoptimized_frame(); 183 } 184 185 // Stress deoptimization 186 static void deopt_caller(JavaThread* current) { 187 if (!caller_is_deopted(current)) { 188 RegisterMap reg_map(current, false); 189 frame runtime_frame = current->last_frame(); 190 frame caller_frame = runtime_frame.sender(®_map); 191 Deoptimization::deoptimize_frame(current, caller_frame.id()); 192 assert(caller_is_deopted(current), "Must be deoptimized"); 193 } 194 } 195 196 class StubIDStubAssemblerCodeGenClosure: public StubAssemblerCodeGenClosure { 197 private: 198 Runtime1::StubID _id; 199 public: 200 StubIDStubAssemblerCodeGenClosure(Runtime1::StubID id) : _id(id) {} 201 virtual OopMapSet* generate_code(StubAssembler* sasm) { 202 return Runtime1::generate_code_for(_id, sasm); 203 } 204 }; 205 206 CodeBlob* Runtime1::generate_blob(BufferBlob* buffer_blob, int stub_id, const char* name, bool expect_oop_map, StubAssemblerCodeGenClosure* cl) { 207 ResourceMark rm; 208 // create code buffer for code storage 209 CodeBuffer code(buffer_blob); 210 211 OopMapSet* oop_maps; 212 int frame_size; 213 bool must_gc_arguments; 214 215 Compilation::setup_code_buffer(&code, 0); 216 217 // create assembler for code generation 218 StubAssembler* sasm = new StubAssembler(&code, name, stub_id); 219 // generate code for runtime stub 220 oop_maps = cl->generate_code(sasm); 221 assert(oop_maps == NULL || sasm->frame_size() != no_frame_size, 222 "if stub has an oop map it must have a valid frame size"); 223 assert(!expect_oop_map || oop_maps != NULL, "must have an oopmap"); 224 225 // align so printing shows nop's instead of random code at the end (SimpleStubs are aligned) 226 sasm->align(BytesPerWord); 227 // make sure all code is in code buffer 228 sasm->flush(); 229 230 frame_size = sasm->frame_size(); 231 must_gc_arguments = sasm->must_gc_arguments(); 232 // create blob - distinguish a few special cases 233 CodeBlob* blob = RuntimeStub::new_runtime_stub(name, 234 &code, 235 CodeOffsets::frame_never_safe, 236 frame_size, 237 oop_maps, 238 must_gc_arguments); 239 assert(blob != NULL, "blob must exist"); 240 return blob; 241 } 242 243 void Runtime1::generate_blob_for(BufferBlob* buffer_blob, StubID id) { 244 assert(0 <= id && id < number_of_ids, "illegal stub id"); 245 bool expect_oop_map = true; 246 #ifdef ASSERT 247 // Make sure that stubs that need oopmaps have them 248 switch (id) { 249 // These stubs don't need to have an oopmap 250 case dtrace_object_alloc_id: 251 case slow_subtype_check_id: 252 case fpu2long_stub_id: 253 case unwind_exception_id: 254 case counter_overflow_id: 255 expect_oop_map = false; 256 break; 257 default: 258 break; 259 } 260 #endif 261 StubIDStubAssemblerCodeGenClosure cl(id); 262 CodeBlob* blob = generate_blob(buffer_blob, id, name_for(id), expect_oop_map, &cl); 263 // install blob 264 _blobs[id] = blob; 265 } 266 267 void Runtime1::initialize(BufferBlob* blob) { 268 // platform-dependent initialization 269 initialize_pd(); 270 // generate stubs 271 for (int id = 0; id < number_of_ids; id++) generate_blob_for(blob, (StubID)id); 272 // printing 273 #ifndef PRODUCT 274 if (PrintSimpleStubs) { 275 ResourceMark rm; 276 for (int id = 0; id < number_of_ids; id++) { 277 _blobs[id]->print(); 278 if (_blobs[id]->oop_maps() != NULL) { 279 _blobs[id]->oop_maps()->print(); 280 } 281 } 282 } 283 #endif 284 BarrierSetC1* bs = BarrierSet::barrier_set()->barrier_set_c1(); 285 bs->generate_c1_runtime_stubs(blob); 286 } 287 288 CodeBlob* Runtime1::blob_for(StubID id) { 289 assert(0 <= id && id < number_of_ids, "illegal stub id"); 290 return _blobs[id]; 291 } 292 293 294 const char* Runtime1::name_for(StubID id) { 295 assert(0 <= id && id < number_of_ids, "illegal stub id"); 296 return _blob_names[id]; 297 } 298 299 const char* Runtime1::name_for_address(address entry) { 300 for (int id = 0; id < number_of_ids; id++) { 301 if (entry == entry_for((StubID)id)) return name_for((StubID)id); 302 } 303 304 #define FUNCTION_CASE(a, f) \ 305 if ((intptr_t)a == CAST_FROM_FN_PTR(intptr_t, f)) return #f 306 307 FUNCTION_CASE(entry, os::javaTimeMillis); 308 FUNCTION_CASE(entry, os::javaTimeNanos); 309 FUNCTION_CASE(entry, SharedRuntime::OSR_migration_end); 310 FUNCTION_CASE(entry, SharedRuntime::d2f); 311 FUNCTION_CASE(entry, SharedRuntime::d2i); 312 FUNCTION_CASE(entry, SharedRuntime::d2l); 313 FUNCTION_CASE(entry, SharedRuntime::dcos); 314 FUNCTION_CASE(entry, SharedRuntime::dexp); 315 FUNCTION_CASE(entry, SharedRuntime::dlog); 316 FUNCTION_CASE(entry, SharedRuntime::dlog10); 317 FUNCTION_CASE(entry, SharedRuntime::dpow); 318 FUNCTION_CASE(entry, SharedRuntime::drem); 319 FUNCTION_CASE(entry, SharedRuntime::dsin); 320 FUNCTION_CASE(entry, SharedRuntime::dtan); 321 FUNCTION_CASE(entry, SharedRuntime::f2i); 322 FUNCTION_CASE(entry, SharedRuntime::f2l); 323 FUNCTION_CASE(entry, SharedRuntime::frem); 324 FUNCTION_CASE(entry, SharedRuntime::l2d); 325 FUNCTION_CASE(entry, SharedRuntime::l2f); 326 FUNCTION_CASE(entry, SharedRuntime::ldiv); 327 FUNCTION_CASE(entry, SharedRuntime::lmul); 328 FUNCTION_CASE(entry, SharedRuntime::lrem); 329 FUNCTION_CASE(entry, SharedRuntime::lrem); 330 FUNCTION_CASE(entry, SharedRuntime::dtrace_method_entry); 331 FUNCTION_CASE(entry, SharedRuntime::dtrace_method_exit); 332 FUNCTION_CASE(entry, is_instance_of); 333 FUNCTION_CASE(entry, trace_block_entry); 334 #ifdef JFR_HAVE_INTRINSICS 335 FUNCTION_CASE(entry, JFR_TIME_FUNCTION); 336 #endif 337 FUNCTION_CASE(entry, StubRoutines::updateBytesCRC32()); 338 FUNCTION_CASE(entry, StubRoutines::updateBytesCRC32C()); 339 FUNCTION_CASE(entry, StubRoutines::vectorizedMismatch()); 340 FUNCTION_CASE(entry, StubRoutines::dexp()); 341 FUNCTION_CASE(entry, StubRoutines::dlog()); 342 FUNCTION_CASE(entry, StubRoutines::dlog10()); 343 FUNCTION_CASE(entry, StubRoutines::dpow()); 344 FUNCTION_CASE(entry, StubRoutines::dsin()); 345 FUNCTION_CASE(entry, StubRoutines::dcos()); 346 FUNCTION_CASE(entry, StubRoutines::dtan()); 347 348 #undef FUNCTION_CASE 349 350 // Soft float adds more runtime names. 351 return pd_name_for_address(entry); 352 } 353 354 static void allocate_instance(JavaThread* current, Klass* klass, TRAPS) { 355 #ifndef PRODUCT 356 if (PrintC1Statistics) { 357 Runtime1::_new_instance_slowcase_cnt++; 358 } 359 #endif 360 assert(klass->is_klass(), "not a class"); 361 Handle holder(current, klass->klass_holder()); // keep the klass alive 362 InstanceKlass* h = InstanceKlass::cast(klass); 363 h->check_valid_for_instantiation(true, CHECK); 364 // make sure klass is initialized 365 h->initialize(CHECK); 366 // allocate instance and return via TLS 367 oop obj = h->allocate_instance(CHECK); 368 current->set_vm_result(obj); 369 JRT_END 370 371 JRT_ENTRY(void, Runtime1::new_instance(JavaThread* current, Klass* klass)) 372 allocate_instance(current, klass, CHECK); 373 JRT_END 374 375 // Same as new_instance but throws error for inline klasses 376 JRT_ENTRY(void, Runtime1::new_instance_no_inline(JavaThread* current, Klass* klass)) 377 if (klass->is_inline_klass()) { 378 SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_InstantiationError()); 379 } else { 380 allocate_instance(current, klass, CHECK); 381 } 382 JRT_END 383 384 JRT_ENTRY(void, Runtime1::new_type_array(JavaThread* current, Klass* klass, jint length)) 385 #ifndef PRODUCT 386 if (PrintC1Statistics) { 387 _new_type_array_slowcase_cnt++; 388 } 389 #endif 390 // Note: no handle for klass needed since they are not used 391 // anymore after new_typeArray() and no GC can happen before. 392 // (This may have to change if this code changes!) 393 assert(klass->is_klass(), "not a class"); 394 BasicType elt_type = TypeArrayKlass::cast(klass)->element_type(); 395 oop obj = oopFactory::new_typeArray(elt_type, length, CHECK); 396 current->set_vm_result(obj); 397 // This is pretty rare but this runtime patch is stressful to deoptimization 398 // if we deoptimize here so force a deopt to stress the path. 399 if (DeoptimizeALot) { 400 deopt_caller(current); 401 } 402 403 JRT_END 404 405 406 JRT_ENTRY(void, Runtime1::new_object_array(JavaThread* current, Klass* array_klass, jint length)) 407 #ifndef PRODUCT 408 if (PrintC1Statistics) { 409 _new_object_array_slowcase_cnt++; 410 } 411 #endif 412 // Note: no handle for klass needed since they are not used 413 // anymore after new_objArray() and no GC can happen before. 414 // (This may have to change if this code changes!) 415 assert(array_klass->is_klass(), "not a class"); 416 Handle holder(current, array_klass->klass_holder()); // keep the klass alive 417 Klass* elem_klass = ArrayKlass::cast(array_klass)->element_klass(); 418 objArrayOop obj = oopFactory::new_objArray(elem_klass, length, CHECK); 419 current->set_vm_result(obj); 420 // This is pretty rare but this runtime patch is stressful to deoptimization 421 // if we deoptimize here so force a deopt to stress the path. 422 if (DeoptimizeALot) { 423 deopt_caller(current); 424 } 425 JRT_END 426 427 428 JRT_ENTRY(void, Runtime1::new_flat_array(JavaThread* current, Klass* array_klass, jint length)) 429 NOT_PRODUCT(_new_flat_array_slowcase_cnt++;) 430 431 // Note: no handle for klass needed since they are not used 432 // anymore after new_objArray() and no GC can happen before. 433 // (This may have to change if this code changes!) 434 assert(array_klass->is_klass(), "not a class"); 435 Handle holder(THREAD, array_klass->klass_holder()); // keep the klass alive 436 Klass* elem_klass = ArrayKlass::cast(array_klass)->element_klass(); 437 assert(elem_klass->is_inline_klass(), "must be"); 438 // Logically creates elements, ensure klass init 439 elem_klass->initialize(CHECK); 440 arrayOop obj = oopFactory::new_valueArray(elem_klass, length, CHECK); 441 current->set_vm_result(obj); 442 // This is pretty rare but this runtime patch is stressful to deoptimization 443 // if we deoptimize here so force a deopt to stress the path. 444 if (DeoptimizeALot) { 445 deopt_caller(current); 446 } 447 JRT_END 448 449 450 JRT_ENTRY(void, Runtime1::new_multi_array(JavaThread* current, Klass* klass, int rank, jint* dims)) 451 #ifndef PRODUCT 452 if (PrintC1Statistics) { 453 _new_multi_array_slowcase_cnt++; 454 } 455 #endif 456 assert(klass->is_klass(), "not a class"); 457 assert(rank >= 1, "rank must be nonzero"); 458 Handle holder(current, klass->klass_holder()); // keep the klass alive 459 oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK); 460 current->set_vm_result(obj); 461 JRT_END 462 463 464 static void profile_flat_array(JavaThread* current) { 465 ResourceMark rm(current); 466 vframeStream vfst(current, true); 467 assert(!vfst.at_end(), "Java frame must exist"); 468 // Check if array access profiling is enabled 469 if (vfst.nm()->comp_level() != CompLevel_full_profile || !C1UpdateMethodData) { 470 return; 471 } 472 int bci = vfst.bci(); 473 Method* method = vfst.method(); 474 MethodData* md = method->method_data(); 475 if (md != NULL) { 476 ProfileData* data = md->bci_to_data(bci); 477 assert(data != NULL && data->is_ArrayLoadStoreData(), "incorrect profiling entry"); 478 ArrayLoadStoreData* load_store = (ArrayLoadStoreData*)data; 479 load_store->set_flat_array(); 480 } 481 } 482 483 JRT_ENTRY(void, Runtime1::load_flattened_array(JavaThread* current, flatArrayOopDesc* array, int index)) 484 assert(array->klass()->is_flatArray_klass(), "should not be called"); 485 profile_flat_array(current); 486 487 NOT_PRODUCT(_load_flattened_array_slowcase_cnt++;) 488 assert(array->length() > 0 && index < array->length(), "already checked"); 489 flatArrayHandle vah(current, array); 490 oop obj = flatArrayOopDesc::value_alloc_copy_from_index(vah, index, CHECK); 491 current->set_vm_result(obj); 492 JRT_END 493 494 495 JRT_ENTRY(void, Runtime1::store_flattened_array(JavaThread* current, flatArrayOopDesc* array, int index, oopDesc* value)) 496 if (array->klass()->is_flatArray_klass()) { 497 profile_flat_array(current); 498 } 499 500 NOT_PRODUCT(_store_flattened_array_slowcase_cnt++;) 501 if (value == NULL) { 502 assert(array->klass()->is_flatArray_klass() || array->klass()->is_null_free_array_klass(), "should not be called"); 503 SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_NullPointerException()); 504 } else { 505 assert(array->klass()->is_flatArray_klass(), "should not be called"); 506 array->value_copy_to_index(value, index); 507 } 508 JRT_END 509 510 511 JRT_ENTRY(int, Runtime1::substitutability_check(JavaThread* current, oopDesc* left, oopDesc* right)) 512 NOT_PRODUCT(_substitutability_check_slowcase_cnt++;) 513 JavaCallArguments args; 514 args.push_oop(Handle(THREAD, left)); 515 args.push_oop(Handle(THREAD, right)); 516 JavaValue result(T_BOOLEAN); 517 JavaCalls::call_static(&result, 518 vmClasses::PrimitiveObjectMethods_klass(), 519 vmSymbols::isSubstitutable_name(), 520 vmSymbols::object_object_boolean_signature(), 521 &args, CHECK_0); 522 return result.get_jboolean() ? 1 : 0; 523 JRT_END 524 525 526 extern "C" void ps(); 527 528 void Runtime1::buffer_inline_args_impl(JavaThread* current, Method* m, bool allocate_receiver) { 529 JavaThread* THREAD = current; 530 methodHandle method(current, m); // We are inside the verified_entry or verified_inline_ro_entry of this method. 531 oop obj = SharedRuntime::allocate_inline_types_impl(current, method, allocate_receiver, CHECK); 532 current->set_vm_result(obj); 533 } 534 535 JRT_ENTRY(void, Runtime1::buffer_inline_args(JavaThread* current, Method* method)) 536 NOT_PRODUCT(_buffer_inline_args_slowcase_cnt++;) 537 buffer_inline_args_impl(current, method, true); 538 JRT_END 539 540 JRT_ENTRY(void, Runtime1::buffer_inline_args_no_receiver(JavaThread* current, Method* method)) 541 NOT_PRODUCT(_buffer_inline_args_no_receiver_slowcase_cnt++;) 542 buffer_inline_args_impl(current, method, false); 543 JRT_END 544 545 JRT_ENTRY(void, Runtime1::unimplemented_entry(JavaThread* current, StubID id)) 546 tty->print_cr("Runtime1::entry_for(%d) returned unimplemented entry point", id); 547 JRT_END 548 549 550 JRT_ENTRY(void, Runtime1::throw_array_store_exception(JavaThread* current, oopDesc* obj)) 551 ResourceMark rm(current); 552 const char* klass_name = obj->klass()->external_name(); 553 SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_ArrayStoreException(), klass_name); 554 JRT_END 555 556 557 // counter_overflow() is called from within C1-compiled methods. The enclosing method is the method 558 // associated with the top activation record. The inlinee (that is possibly included in the enclosing 559 // method) method is passed as an argument. In order to do that it is embedded in the code as 560 // a constant. 561 static nmethod* counter_overflow_helper(JavaThread* current, int branch_bci, Method* m) { 562 nmethod* osr_nm = NULL; 563 methodHandle method(current, m); 564 565 RegisterMap map(current, false); 566 frame fr = current->last_frame().sender(&map); 567 nmethod* nm = (nmethod*) fr.cb(); 568 assert(nm!= NULL && nm->is_nmethod(), "Sanity check"); 569 methodHandle enclosing_method(current, nm->method()); 570 571 CompLevel level = (CompLevel)nm->comp_level(); 572 int bci = InvocationEntryBci; 573 if (branch_bci != InvocationEntryBci) { 574 // Compute destination bci 575 address pc = method()->code_base() + branch_bci; 576 Bytecodes::Code branch = Bytecodes::code_at(method(), pc); 577 int offset = 0; 578 switch (branch) { 579 case Bytecodes::_if_icmplt: case Bytecodes::_iflt: 580 case Bytecodes::_if_icmpgt: case Bytecodes::_ifgt: 581 case Bytecodes::_if_icmple: case Bytecodes::_ifle: 582 case Bytecodes::_if_icmpge: case Bytecodes::_ifge: 583 case Bytecodes::_if_icmpeq: case Bytecodes::_if_acmpeq: case Bytecodes::_ifeq: 584 case Bytecodes::_if_icmpne: case Bytecodes::_if_acmpne: case Bytecodes::_ifne: 585 case Bytecodes::_ifnull: case Bytecodes::_ifnonnull: case Bytecodes::_goto: 586 offset = (int16_t)Bytes::get_Java_u2(pc + 1); 587 break; 588 case Bytecodes::_goto_w: 589 offset = Bytes::get_Java_u4(pc + 1); 590 break; 591 default: ; 592 } 593 bci = branch_bci + offset; 594 } 595 osr_nm = CompilationPolicy::event(enclosing_method, method, branch_bci, bci, level, nm, current); 596 return osr_nm; 597 } 598 599 JRT_BLOCK_ENTRY(address, Runtime1::counter_overflow(JavaThread* current, int bci, Method* method)) 600 nmethod* osr_nm; 601 JRT_BLOCK 602 osr_nm = counter_overflow_helper(current, bci, method); 603 if (osr_nm != NULL) { 604 RegisterMap map(current, false); 605 frame fr = current->last_frame().sender(&map); 606 Deoptimization::deoptimize_frame(current, fr.id()); 607 } 608 JRT_BLOCK_END 609 return NULL; 610 JRT_END 611 612 extern void vm_exit(int code); 613 614 // Enter this method from compiled code handler below. This is where we transition 615 // to VM mode. This is done as a helper routine so that the method called directly 616 // from compiled code does not have to transition to VM. This allows the entry 617 // method to see if the nmethod that we have just looked up a handler for has 618 // been deoptimized while we were in the vm. This simplifies the assembly code 619 // cpu directories. 620 // 621 // We are entering here from exception stub (via the entry method below) 622 // If there is a compiled exception handler in this method, we will continue there; 623 // otherwise we will unwind the stack and continue at the caller of top frame method 624 // Note: we enter in Java using a special JRT wrapper. This wrapper allows us to 625 // control the area where we can allow a safepoint. After we exit the safepoint area we can 626 // check to see if the handler we are going to return is now in a nmethod that has 627 // been deoptimized. If that is the case we return the deopt blob 628 // unpack_with_exception entry instead. This makes life for the exception blob easier 629 // because making that same check and diverting is painful from assembly language. 630 JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* current, oopDesc* ex, address pc, nmethod*& nm)) 631 // Reset method handle flag. 632 current->set_is_method_handle_return(false); 633 634 Handle exception(current, ex); 635 636 // This function is called when we are about to throw an exception. Therefore, 637 // we have to poll the stack watermark barrier to make sure that not yet safe 638 // stack frames are made safe before returning into them. 639 if (current->last_frame().cb() == Runtime1::blob_for(Runtime1::handle_exception_from_callee_id)) { 640 // The Runtime1::handle_exception_from_callee_id handler is invoked after the 641 // frame has been unwound. It instead builds its own stub frame, to call the 642 // runtime. But the throwing frame has already been unwound here. 643 StackWatermarkSet::after_unwind(current); 644 } 645 646 nm = CodeCache::find_nmethod(pc); 647 assert(nm != NULL, "this is not an nmethod"); 648 // Adjust the pc as needed/ 649 if (nm->is_deopt_pc(pc)) { 650 RegisterMap map(current, false); 651 frame exception_frame = current->last_frame().sender(&map); 652 // if the frame isn't deopted then pc must not correspond to the caller of last_frame 653 assert(exception_frame.is_deoptimized_frame(), "must be deopted"); 654 pc = exception_frame.pc(); 655 } 656 assert(exception.not_null(), "NULL exceptions should be handled by throw_exception"); 657 // Check that exception is a subclass of Throwable 658 assert(exception->is_a(vmClasses::Throwable_klass()), 659 "Exception not subclass of Throwable"); 660 661 // debugging support 662 // tracing 663 if (log_is_enabled(Info, exceptions)) { 664 ResourceMark rm; 665 stringStream tempst; 666 assert(nm->method() != NULL, "Unexpected NULL method()"); 667 tempst.print("C1 compiled method <%s>\n" 668 " at PC" INTPTR_FORMAT " for thread " INTPTR_FORMAT, 669 nm->method()->print_value_string(), p2i(pc), p2i(current)); 670 Exceptions::log_exception(exception, tempst.as_string()); 671 } 672 // for AbortVMOnException flag 673 Exceptions::debug_check_abort(exception); 674 675 // Check the stack guard pages and reenable them if necessary and there is 676 // enough space on the stack to do so. Use fast exceptions only if the guard 677 // pages are enabled. 678 bool guard_pages_enabled = current->stack_overflow_state()->reguard_stack_if_needed(); 679 680 if (JvmtiExport::can_post_on_exceptions()) { 681 // To ensure correct notification of exception catches and throws 682 // we have to deoptimize here. If we attempted to notify the 683 // catches and throws during this exception lookup it's possible 684 // we could deoptimize on the way out of the VM and end back in 685 // the interpreter at the throw site. This would result in double 686 // notifications since the interpreter would also notify about 687 // these same catches and throws as it unwound the frame. 688 689 RegisterMap reg_map(current); 690 frame stub_frame = current->last_frame(); 691 frame caller_frame = stub_frame.sender(®_map); 692 693 // We don't really want to deoptimize the nmethod itself since we 694 // can actually continue in the exception handler ourselves but I 695 // don't see an easy way to have the desired effect. 696 Deoptimization::deoptimize_frame(current, caller_frame.id()); 697 assert(caller_is_deopted(current), "Must be deoptimized"); 698 699 return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls(); 700 } 701 702 // ExceptionCache is used only for exceptions at call sites and not for implicit exceptions 703 if (guard_pages_enabled) { 704 address fast_continuation = nm->handler_for_exception_and_pc(exception, pc); 705 if (fast_continuation != NULL) { 706 // Set flag if return address is a method handle call site. 707 current->set_is_method_handle_return(nm->is_method_handle_return(pc)); 708 return fast_continuation; 709 } 710 } 711 712 // If the stack guard pages are enabled, check whether there is a handler in 713 // the current method. Otherwise (guard pages disabled), force an unwind and 714 // skip the exception cache update (i.e., just leave continuation==NULL). 715 address continuation = NULL; 716 if (guard_pages_enabled) { 717 718 // New exception handling mechanism can support inlined methods 719 // with exception handlers since the mappings are from PC to PC 720 721 // Clear out the exception oop and pc since looking up an 722 // exception handler can cause class loading, which might throw an 723 // exception and those fields are expected to be clear during 724 // normal bytecode execution. 725 current->clear_exception_oop_and_pc(); 726 727 bool recursive_exception = false; 728 continuation = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, false, false, recursive_exception); 729 // If an exception was thrown during exception dispatch, the exception oop may have changed 730 current->set_exception_oop(exception()); 731 current->set_exception_pc(pc); 732 733 // the exception cache is used only by non-implicit exceptions 734 // Update the exception cache only when there didn't happen 735 // another exception during the computation of the compiled 736 // exception handler. Checking for exception oop equality is not 737 // sufficient because some exceptions are pre-allocated and reused. 738 if (continuation != NULL && !recursive_exception) { 739 nm->add_handler_for_exception_and_pc(exception, pc, continuation); 740 } 741 } 742 743 current->set_vm_result(exception()); 744 // Set flag if return address is a method handle call site. 745 current->set_is_method_handle_return(nm->is_method_handle_return(pc)); 746 747 if (log_is_enabled(Info, exceptions)) { 748 ResourceMark rm; 749 log_info(exceptions)("Thread " PTR_FORMAT " continuing at PC " PTR_FORMAT 750 " for exception thrown at PC " PTR_FORMAT, 751 p2i(current), p2i(continuation), p2i(pc)); 752 } 753 754 return continuation; 755 JRT_END 756 757 // Enter this method from compiled code only if there is a Java exception handler 758 // in the method handling the exception. 759 // We are entering here from exception stub. We don't do a normal VM transition here. 760 // We do it in a helper. This is so we can check to see if the nmethod we have just 761 // searched for an exception handler has been deoptimized in the meantime. 762 address Runtime1::exception_handler_for_pc(JavaThread* current) { 763 oop exception = current->exception_oop(); 764 address pc = current->exception_pc(); 765 // Still in Java mode 766 DEBUG_ONLY(NoHandleMark nhm); 767 nmethod* nm = NULL; 768 address continuation = NULL; 769 { 770 // Enter VM mode by calling the helper 771 ResetNoHandleMark rnhm; 772 continuation = exception_handler_for_pc_helper(current, exception, pc, nm); 773 } 774 // Back in JAVA, use no oops DON'T safepoint 775 776 // Now check to see if the nmethod we were called from is now deoptimized. 777 // If so we must return to the deopt blob and deoptimize the nmethod 778 if (nm != NULL && caller_is_deopted(current)) { 779 continuation = SharedRuntime::deopt_blob()->unpack_with_exception_in_tls(); 780 } 781 782 assert(continuation != NULL, "no handler found"); 783 return continuation; 784 } 785 786 787 JRT_ENTRY(void, Runtime1::throw_range_check_exception(JavaThread* current, int index, arrayOopDesc* a)) 788 #ifndef PRODUCT 789 if (PrintC1Statistics) { 790 _throw_range_check_exception_count++; 791 } 792 #endif 793 const int len = 35; 794 assert(len < strlen("Index %d out of bounds for length %d"), "Must allocate more space for message."); 795 char message[2 * jintAsStringSize + len]; 796 sprintf(message, "Index %d out of bounds for length %d", index, a->length()); 797 SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), message); 798 JRT_END 799 800 801 JRT_ENTRY(void, Runtime1::throw_index_exception(JavaThread* current, int index)) 802 #ifndef PRODUCT 803 if (PrintC1Statistics) { 804 _throw_index_exception_count++; 805 } 806 #endif 807 char message[16]; 808 sprintf(message, "%d", index); 809 SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_IndexOutOfBoundsException(), message); 810 JRT_END 811 812 813 JRT_ENTRY(void, Runtime1::throw_div0_exception(JavaThread* current)) 814 #ifndef PRODUCT 815 if (PrintC1Statistics) { 816 _throw_div0_exception_count++; 817 } 818 #endif 819 SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_ArithmeticException(), "/ by zero"); 820 JRT_END 821 822 823 JRT_ENTRY(void, Runtime1::throw_null_pointer_exception(JavaThread* current)) 824 #ifndef PRODUCT 825 if (PrintC1Statistics) { 826 _throw_null_pointer_exception_count++; 827 } 828 #endif 829 SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_NullPointerException()); 830 JRT_END 831 832 833 JRT_ENTRY(void, Runtime1::throw_class_cast_exception(JavaThread* current, oopDesc* object)) 834 #ifndef PRODUCT 835 if (PrintC1Statistics) { 836 _throw_class_cast_exception_count++; 837 } 838 #endif 839 ResourceMark rm(current); 840 char* message = SharedRuntime::generate_class_cast_message(current, object->klass()); 841 SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_ClassCastException(), message); 842 JRT_END 843 844 845 JRT_ENTRY(void, Runtime1::throw_incompatible_class_change_error(JavaThread* current)) 846 #ifndef PRODUCT 847 if (PrintC1Statistics) { 848 _throw_incompatible_class_change_error_count++; 849 } 850 #endif 851 ResourceMark rm(current); 852 SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_IncompatibleClassChangeError()); 853 JRT_END 854 855 856 JRT_ENTRY(void, Runtime1::throw_illegal_monitor_state_exception(JavaThread* current)) 857 NOT_PRODUCT(_throw_illegal_monitor_state_exception_count++;) 858 ResourceMark rm(current); 859 SharedRuntime::throw_and_post_jvmti_exception(current, vmSymbols::java_lang_IllegalMonitorStateException()); 860 JRT_END 861 862 JRT_BLOCK_ENTRY(void, Runtime1::monitorenter(JavaThread* current, oopDesc* obj, BasicObjectLock* lock)) 863 #ifndef PRODUCT 864 if (PrintC1Statistics) { 865 _monitorenter_slowcase_cnt++; 866 } 867 #endif 868 if (UseHeavyMonitors) { 869 lock->set_obj(obj); 870 } 871 assert(obj == lock->obj(), "must match"); 872 SharedRuntime::monitor_enter_helper(obj, lock->lock(), current); 873 JRT_END 874 875 876 JRT_LEAF(void, Runtime1::monitorexit(JavaThread* current, BasicObjectLock* lock)) 877 #ifndef PRODUCT 878 if (PrintC1Statistics) { 879 _monitorexit_slowcase_cnt++; 880 } 881 #endif 882 assert(current->last_Java_sp(), "last_Java_sp must be set"); 883 oop obj = lock->obj(); 884 assert(oopDesc::is_oop(obj), "must be NULL or an object"); 885 SharedRuntime::monitor_exit_helper(obj, lock->lock(), current); 886 JRT_END 887 888 // Cf. OptoRuntime::deoptimize_caller_frame 889 JRT_ENTRY(void, Runtime1::deoptimize(JavaThread* current, jint trap_request)) 890 // Called from within the owner thread, so no need for safepoint 891 RegisterMap reg_map(current, false); 892 frame stub_frame = current->last_frame(); 893 assert(stub_frame.is_runtime_frame(), "Sanity check"); 894 frame caller_frame = stub_frame.sender(®_map); 895 nmethod* nm = caller_frame.cb()->as_nmethod_or_null(); 896 assert(nm != NULL, "Sanity check"); 897 methodHandle method(current, nm->method()); 898 assert(nm == CodeCache::find_nmethod(caller_frame.pc()), "Should be the same"); 899 Deoptimization::DeoptAction action = Deoptimization::trap_request_action(trap_request); 900 Deoptimization::DeoptReason reason = Deoptimization::trap_request_reason(trap_request); 901 902 if (action == Deoptimization::Action_make_not_entrant) { 903 if (nm->make_not_entrant()) { 904 if (reason == Deoptimization::Reason_tenured) { 905 MethodData* trap_mdo = Deoptimization::get_method_data(current, method, true /*create_if_missing*/); 906 if (trap_mdo != NULL) { 907 trap_mdo->inc_tenure_traps(); 908 } 909 } 910 } 911 } 912 913 // Deoptimize the caller frame. 914 Deoptimization::deoptimize_frame(current, caller_frame.id()); 915 // Return to the now deoptimized frame. 916 JRT_END 917 918 919 #ifndef DEOPTIMIZE_WHEN_PATCHING 920 921 static Klass* resolve_field_return_klass(const methodHandle& caller, int bci, TRAPS) { 922 Bytecode_field field_access(caller, bci); 923 // This can be static or non-static field access 924 Bytecodes::Code code = field_access.code(); 925 926 // We must load class, initialize class and resolve the field 927 fieldDescriptor result; // initialize class if needed 928 constantPoolHandle constants(THREAD, caller->constants()); 929 LinkResolver::resolve_field_access(result, constants, field_access.index(), caller, Bytecodes::java_code(code), CHECK_NULL); 930 return result.field_holder(); 931 } 932 933 934 // 935 // This routine patches sites where a class wasn't loaded or 936 // initialized at the time the code was generated. It handles 937 // references to classes, fields and forcing of initialization. Most 938 // of the cases are straightforward and involving simply forcing 939 // resolution of a class, rewriting the instruction stream with the 940 // needed constant and replacing the call in this function with the 941 // patched code. The case for static field is more complicated since 942 // the thread which is in the process of initializing a class can 943 // access it's static fields but other threads can't so the code 944 // either has to deoptimize when this case is detected or execute a 945 // check that the current thread is the initializing thread. The 946 // current 947 // 948 // Patches basically look like this: 949 // 950 // 951 // patch_site: jmp patch stub ;; will be patched 952 // continue: ... 953 // ... 954 // ... 955 // ... 956 // 957 // They have a stub which looks like this: 958 // 959 // ;; patch body 960 // movl <const>, reg (for class constants) 961 // <or> movl [reg1 + <const>], reg (for field offsets) 962 // <or> movl reg, [reg1 + <const>] (for field offsets) 963 // <being_init offset> <bytes to copy> <bytes to skip> 964 // patch_stub: call Runtime1::patch_code (through a runtime stub) 965 // jmp patch_site 966 // 967 // 968 // A normal patch is done by rewriting the patch body, usually a move, 969 // and then copying it into place over top of the jmp instruction 970 // being careful to flush caches and doing it in an MP-safe way. The 971 // constants following the patch body are used to find various pieces 972 // of the patch relative to the call site for Runtime1::patch_code. 973 // The case for getstatic and putstatic is more complicated because 974 // getstatic and putstatic have special semantics when executing while 975 // the class is being initialized. getstatic/putstatic on a class 976 // which is being_initialized may be executed by the initializing 977 // thread but other threads have to block when they execute it. This 978 // is accomplished in compiled code by executing a test of the current 979 // thread against the initializing thread of the class. It's emitted 980 // as boilerplate in their stub which allows the patched code to be 981 // executed before it's copied back into the main body of the nmethod. 982 // 983 // being_init: get_thread(<tmp reg> 984 // cmpl [reg1 + <init_thread_offset>], <tmp reg> 985 // jne patch_stub 986 // movl [reg1 + <const>], reg (for field offsets) <or> 987 // movl reg, [reg1 + <const>] (for field offsets) 988 // jmp continue 989 // <being_init offset> <bytes to copy> <bytes to skip> 990 // patch_stub: jmp Runtim1::patch_code (through a runtime stub) 991 // jmp patch_site 992 // 993 // If the class is being initialized the patch body is rewritten and 994 // the patch site is rewritten to jump to being_init, instead of 995 // patch_stub. Whenever this code is executed it checks the current 996 // thread against the intializing thread so other threads will enter 997 // the runtime and end up blocked waiting the class to finish 998 // initializing inside the calls to resolve_field below. The 999 // initializing class will continue on it's way. Once the class is 1000 // fully_initialized, the intializing_thread of the class becomes 1001 // NULL, so the next thread to execute this code will fail the test, 1002 // call into patch_code and complete the patching process by copying 1003 // the patch body back into the main part of the nmethod and resume 1004 // executing. 1005 1006 // NB: 1007 // 1008 // Patchable instruction sequences inherently exhibit race conditions, 1009 // where thread A is patching an instruction at the same time thread B 1010 // is executing it. The algorithms we use ensure that any observation 1011 // that B can make on any intermediate states during A's patching will 1012 // always end up with a correct outcome. This is easiest if there are 1013 // few or no intermediate states. (Some inline caches have two 1014 // related instructions that must be patched in tandem. For those, 1015 // intermediate states seem to be unavoidable, but we will get the 1016 // right answer from all possible observation orders.) 1017 // 1018 // When patching the entry instruction at the head of a method, or a 1019 // linkable call instruction inside of a method, we try very hard to 1020 // use a patch sequence which executes as a single memory transaction. 1021 // This means, in practice, that when thread A patches an instruction, 1022 // it should patch a 32-bit or 64-bit word that somehow overlaps the 1023 // instruction or is contained in it. We believe that memory hardware 1024 // will never break up such a word write, if it is naturally aligned 1025 // for the word being written. We also know that some CPUs work very 1026 // hard to create atomic updates even of naturally unaligned words, 1027 // but we don't want to bet the farm on this always working. 1028 // 1029 // Therefore, if there is any chance of a race condition, we try to 1030 // patch only naturally aligned words, as single, full-word writes. 1031 1032 JRT_ENTRY(void, Runtime1::patch_code(JavaThread* current, Runtime1::StubID stub_id )) 1033 #ifndef PRODUCT 1034 if (PrintC1Statistics) { 1035 _patch_code_slowcase_cnt++; 1036 } 1037 #endif 1038 1039 ResourceMark rm(current); 1040 RegisterMap reg_map(current, false); 1041 frame runtime_frame = current->last_frame(); 1042 frame caller_frame = runtime_frame.sender(®_map); 1043 1044 // last java frame on stack 1045 vframeStream vfst(current, true); 1046 assert(!vfst.at_end(), "Java frame must exist"); 1047 1048 methodHandle caller_method(current, vfst.method()); 1049 // Note that caller_method->code() may not be same as caller_code because of OSR's 1050 // Note also that in the presence of inlining it is not guaranteed 1051 // that caller_method() == caller_code->method() 1052 1053 int bci = vfst.bci(); 1054 Bytecodes::Code code = caller_method()->java_code_at(bci); 1055 1056 // this is used by assertions in the access_field_patching_id 1057 BasicType patch_field_type = T_ILLEGAL; 1058 bool deoptimize_for_volatile = false; 1059 bool deoptimize_for_atomic = false; 1060 int patch_field_offset = -1; 1061 Klass* init_klass = NULL; // klass needed by load_klass_patching code 1062 Klass* load_klass = NULL; // klass needed by load_klass_patching code 1063 Handle mirror(current, NULL); // oop needed by load_mirror_patching code 1064 Handle appendix(current, NULL); // oop needed by appendix_patching code 1065 bool load_klass_or_mirror_patch_id = 1066 (stub_id == Runtime1::load_klass_patching_id || stub_id == Runtime1::load_mirror_patching_id); 1067 1068 if (stub_id == Runtime1::access_field_patching_id) { 1069 1070 Bytecode_field field_access(caller_method, bci); 1071 fieldDescriptor result; // initialize class if needed 1072 Bytecodes::Code code = field_access.code(); 1073 constantPoolHandle constants(current, caller_method->constants()); 1074 LinkResolver::resolve_field_access(result, constants, field_access.index(), caller_method, Bytecodes::java_code(code), CHECK); 1075 patch_field_offset = result.offset(); 1076 assert(!result.is_inlined(), "Can not patch access to flattened field"); 1077 1078 // If we're patching a field which is volatile then at compile it 1079 // must not have been know to be volatile, so the generated code 1080 // isn't correct for a volatile reference. The nmethod has to be 1081 // deoptimized so that the code can be regenerated correctly. 1082 // This check is only needed for access_field_patching since this 1083 // is the path for patching field offsets. load_klass is only 1084 // used for patching references to oops which don't need special 1085 // handling in the volatile case. 1086 1087 deoptimize_for_volatile = result.access_flags().is_volatile(); 1088 1089 // If we are patching a field which should be atomic, then 1090 // the generated code is not correct either, force deoptimizing. 1091 // We need to only cover T_LONG and T_DOUBLE fields, as we can 1092 // break access atomicity only for them. 1093 1094 // Strictly speaking, the deoptimization on 64-bit platforms 1095 // is unnecessary, and T_LONG stores on 32-bit platforms need 1096 // to be handled by special patching code when AlwaysAtomicAccesses 1097 // becomes product feature. At this point, we are still going 1098 // for the deoptimization for consistency against volatile 1099 // accesses. 1100 1101 patch_field_type = result.field_type(); 1102 deoptimize_for_atomic = (AlwaysAtomicAccesses && (patch_field_type == T_DOUBLE || patch_field_type == T_LONG)); 1103 1104 } else if (load_klass_or_mirror_patch_id) { 1105 Klass* k = NULL; 1106 switch (code) { 1107 case Bytecodes::_putstatic: 1108 case Bytecodes::_getstatic: 1109 { Klass* klass = resolve_field_return_klass(caller_method, bci, CHECK); 1110 init_klass = klass; 1111 mirror = Handle(current, klass->java_mirror()); 1112 } 1113 break; 1114 case Bytecodes::_new: 1115 { Bytecode_new bnew(caller_method(), caller_method->bcp_from(bci)); 1116 k = caller_method->constants()->klass_at(bnew.index(), CHECK); 1117 } 1118 break; 1119 case Bytecodes::_aconst_init: 1120 { Bytecode_aconst_init baconst_init(caller_method(), caller_method->bcp_from(bci)); 1121 k = caller_method->constants()->klass_at(baconst_init.index(), CHECK); 1122 } 1123 break; 1124 case Bytecodes::_multianewarray: 1125 { Bytecode_multianewarray mna(caller_method(), caller_method->bcp_from(bci)); 1126 k = caller_method->constants()->klass_at(mna.index(), CHECK); 1127 if (k->name()->is_Q_array_signature()) { 1128 // Logically creates elements, ensure klass init 1129 k->initialize(CHECK); 1130 } 1131 } 1132 break; 1133 case Bytecodes::_instanceof: 1134 { Bytecode_instanceof io(caller_method(), caller_method->bcp_from(bci)); 1135 k = caller_method->constants()->klass_at(io.index(), CHECK); 1136 } 1137 break; 1138 case Bytecodes::_checkcast: 1139 { Bytecode_checkcast cc(caller_method(), caller_method->bcp_from(bci)); 1140 k = caller_method->constants()->klass_at(cc.index(), CHECK); 1141 } 1142 break; 1143 case Bytecodes::_anewarray: 1144 { Bytecode_anewarray anew(caller_method(), caller_method->bcp_from(bci)); 1145 Klass* ek = caller_method->constants()->klass_at(anew.index(), CHECK); 1146 k = ek->array_klass(CHECK); 1147 } 1148 break; 1149 case Bytecodes::_ldc: 1150 case Bytecodes::_ldc_w: 1151 case Bytecodes::_ldc2_w: 1152 { 1153 Bytecode_loadconstant cc(caller_method, bci); 1154 oop m = cc.resolve_constant(CHECK); 1155 mirror = Handle(current, m); 1156 } 1157 break; 1158 default: fatal("unexpected bytecode for load_klass_or_mirror_patch_id"); 1159 } 1160 load_klass = k; 1161 } else if (stub_id == load_appendix_patching_id) { 1162 Bytecode_invoke bytecode(caller_method, bci); 1163 Bytecodes::Code bc = bytecode.invoke_code(); 1164 1165 CallInfo info; 1166 constantPoolHandle pool(current, caller_method->constants()); 1167 int index = bytecode.index(); 1168 LinkResolver::resolve_invoke(info, Handle(), pool, index, bc, CHECK); 1169 switch (bc) { 1170 case Bytecodes::_invokehandle: { 1171 int cache_index = ConstantPool::decode_cpcache_index(index, true); 1172 assert(cache_index >= 0 && cache_index < pool->cache()->length(), "unexpected cache index"); 1173 ConstantPoolCacheEntry* cpce = pool->cache()->entry_at(cache_index); 1174 cpce->set_method_handle(pool, info); 1175 appendix = Handle(current, cpce->appendix_if_resolved(pool)); // just in case somebody already resolved the entry 1176 break; 1177 } 1178 case Bytecodes::_invokedynamic: { 1179 ConstantPoolCacheEntry* cpce = pool->invokedynamic_cp_cache_entry_at(index); 1180 cpce->set_dynamic_call(pool, info); 1181 appendix = Handle(current, cpce->appendix_if_resolved(pool)); // just in case somebody already resolved the entry 1182 break; 1183 } 1184 default: fatal("unexpected bytecode for load_appendix_patching_id"); 1185 } 1186 } else { 1187 ShouldNotReachHere(); 1188 } 1189 1190 if (deoptimize_for_volatile || deoptimize_for_atomic) { 1191 // At compile time we assumed the field wasn't volatile/atomic but after 1192 // loading it turns out it was volatile/atomic so we have to throw the 1193 // compiled code out and let it be regenerated. 1194 if (TracePatching) { 1195 if (deoptimize_for_volatile) { 1196 tty->print_cr("Deoptimizing for patching volatile field reference"); 1197 } 1198 if (deoptimize_for_atomic) { 1199 tty->print_cr("Deoptimizing for patching atomic field reference"); 1200 } 1201 } 1202 1203 // It's possible the nmethod was invalidated in the last 1204 // safepoint, but if it's still alive then make it not_entrant. 1205 nmethod* nm = CodeCache::find_nmethod(caller_frame.pc()); 1206 if (nm != NULL) { 1207 nm->make_not_entrant(); 1208 } 1209 1210 Deoptimization::deoptimize_frame(current, caller_frame.id()); 1211 1212 // Return to the now deoptimized frame. 1213 } 1214 1215 // Now copy code back 1216 1217 { 1218 MutexLocker ml_patch (current, Patching_lock, Mutex::_no_safepoint_check_flag); 1219 // 1220 // Deoptimization may have happened while we waited for the lock. 1221 // In that case we don't bother to do any patching we just return 1222 // and let the deopt happen 1223 if (!caller_is_deopted(current)) { 1224 NativeGeneralJump* jump = nativeGeneralJump_at(caller_frame.pc()); 1225 address instr_pc = jump->jump_destination(); 1226 NativeInstruction* ni = nativeInstruction_at(instr_pc); 1227 if (ni->is_jump() ) { 1228 // the jump has not been patched yet 1229 // The jump destination is slow case and therefore not part of the stubs 1230 // (stubs are only for StaticCalls) 1231 1232 // format of buffer 1233 // .... 1234 // instr byte 0 <-- copy_buff 1235 // instr byte 1 1236 // .. 1237 // instr byte n-1 1238 // n 1239 // .... <-- call destination 1240 1241 address stub_location = caller_frame.pc() + PatchingStub::patch_info_offset(); 1242 unsigned char* byte_count = (unsigned char*) (stub_location - 1); 1243 unsigned char* byte_skip = (unsigned char*) (stub_location - 2); 1244 unsigned char* being_initialized_entry_offset = (unsigned char*) (stub_location - 3); 1245 address copy_buff = stub_location - *byte_skip - *byte_count; 1246 address being_initialized_entry = stub_location - *being_initialized_entry_offset; 1247 if (TracePatching) { 1248 ttyLocker ttyl; 1249 tty->print_cr(" Patching %s at bci %d at address " INTPTR_FORMAT " (%s)", Bytecodes::name(code), bci, 1250 p2i(instr_pc), (stub_id == Runtime1::access_field_patching_id) ? "field" : "klass"); 1251 nmethod* caller_code = CodeCache::find_nmethod(caller_frame.pc()); 1252 assert(caller_code != NULL, "nmethod not found"); 1253 1254 // NOTE we use pc() not original_pc() because we already know they are 1255 // identical otherwise we'd have never entered this block of code 1256 1257 const ImmutableOopMap* map = caller_code->oop_map_for_return_address(caller_frame.pc()); 1258 assert(map != NULL, "null check"); 1259 map->print(); 1260 tty->cr(); 1261 1262 Disassembler::decode(copy_buff, copy_buff + *byte_count, tty); 1263 } 1264 // depending on the code below, do_patch says whether to copy the patch body back into the nmethod 1265 bool do_patch = true; 1266 if (stub_id == Runtime1::access_field_patching_id) { 1267 // The offset may not be correct if the class was not loaded at code generation time. 1268 // Set it now. 1269 NativeMovRegMem* n_move = nativeMovRegMem_at(copy_buff); 1270 assert(n_move->offset() == 0 || (n_move->offset() == 4 && (patch_field_type == T_DOUBLE || patch_field_type == T_LONG)), "illegal offset for type"); 1271 assert(patch_field_offset >= 0, "illegal offset"); 1272 n_move->add_offset_in_bytes(patch_field_offset); 1273 } else if (load_klass_or_mirror_patch_id) { 1274 // If a getstatic or putstatic is referencing a klass which 1275 // isn't fully initialized, the patch body isn't copied into 1276 // place until initialization is complete. In this case the 1277 // patch site is setup so that any threads besides the 1278 // initializing thread are forced to come into the VM and 1279 // block. 1280 do_patch = (code != Bytecodes::_getstatic && code != Bytecodes::_putstatic) || 1281 InstanceKlass::cast(init_klass)->is_initialized(); 1282 NativeGeneralJump* jump = nativeGeneralJump_at(instr_pc); 1283 if (jump->jump_destination() == being_initialized_entry) { 1284 assert(do_patch == true, "initialization must be complete at this point"); 1285 } else { 1286 // patch the instruction <move reg, klass> 1287 NativeMovConstReg* n_copy = nativeMovConstReg_at(copy_buff); 1288 1289 assert(n_copy->data() == 0 || 1290 n_copy->data() == (intptr_t)Universe::non_oop_word(), 1291 "illegal init value"); 1292 if (stub_id == Runtime1::load_klass_patching_id) { 1293 assert(load_klass != NULL, "klass not set"); 1294 n_copy->set_data((intx) (load_klass)); 1295 } else { 1296 // Don't need a G1 pre-barrier here since we assert above that data isn't an oop. 1297 n_copy->set_data(cast_from_oop<intx>(mirror())); 1298 } 1299 1300 if (TracePatching) { 1301 Disassembler::decode(copy_buff, copy_buff + *byte_count, tty); 1302 } 1303 } 1304 } else if (stub_id == Runtime1::load_appendix_patching_id) { 1305 NativeMovConstReg* n_copy = nativeMovConstReg_at(copy_buff); 1306 assert(n_copy->data() == 0 || 1307 n_copy->data() == (intptr_t)Universe::non_oop_word(), 1308 "illegal init value"); 1309 n_copy->set_data(cast_from_oop<intx>(appendix())); 1310 1311 if (TracePatching) { 1312 Disassembler::decode(copy_buff, copy_buff + *byte_count, tty); 1313 } 1314 } else { 1315 ShouldNotReachHere(); 1316 } 1317 1318 if (do_patch) { 1319 // replace instructions 1320 // first replace the tail, then the call 1321 #ifdef ARM 1322 if((load_klass_or_mirror_patch_id || 1323 stub_id == Runtime1::load_appendix_patching_id) && 1324 nativeMovConstReg_at(copy_buff)->is_pc_relative()) { 1325 nmethod* nm = CodeCache::find_nmethod(instr_pc); 1326 address addr = NULL; 1327 assert(nm != NULL, "invalid nmethod_pc"); 1328 RelocIterator mds(nm, copy_buff, copy_buff + 1); 1329 while (mds.next()) { 1330 if (mds.type() == relocInfo::oop_type) { 1331 assert(stub_id == Runtime1::load_mirror_patching_id || 1332 stub_id == Runtime1::load_appendix_patching_id, "wrong stub id"); 1333 oop_Relocation* r = mds.oop_reloc(); 1334 addr = (address)r->oop_addr(); 1335 break; 1336 } else if (mds.type() == relocInfo::metadata_type) { 1337 assert(stub_id == Runtime1::load_klass_patching_id, "wrong stub id"); 1338 metadata_Relocation* r = mds.metadata_reloc(); 1339 addr = (address)r->metadata_addr(); 1340 break; 1341 } 1342 } 1343 assert(addr != NULL, "metadata relocation must exist"); 1344 copy_buff -= *byte_count; 1345 NativeMovConstReg* n_copy2 = nativeMovConstReg_at(copy_buff); 1346 n_copy2->set_pc_relative_offset(addr, instr_pc); 1347 } 1348 #endif 1349 1350 for (int i = NativeGeneralJump::instruction_size; i < *byte_count; i++) { 1351 address ptr = copy_buff + i; 1352 int a_byte = (*ptr) & 0xFF; 1353 address dst = instr_pc + i; 1354 *(unsigned char*)dst = (unsigned char) a_byte; 1355 } 1356 ICache::invalidate_range(instr_pc, *byte_count); 1357 NativeGeneralJump::replace_mt_safe(instr_pc, copy_buff); 1358 1359 if (load_klass_or_mirror_patch_id || 1360 stub_id == Runtime1::load_appendix_patching_id) { 1361 relocInfo::relocType rtype = 1362 (stub_id == Runtime1::load_klass_patching_id) ? 1363 relocInfo::metadata_type : 1364 relocInfo::oop_type; 1365 // update relocInfo to metadata 1366 nmethod* nm = CodeCache::find_nmethod(instr_pc); 1367 assert(nm != NULL, "invalid nmethod_pc"); 1368 1369 // The old patch site is now a move instruction so update 1370 // the reloc info so that it will get updated during 1371 // future GCs. 1372 RelocIterator iter(nm, (address)instr_pc, (address)(instr_pc + 1)); 1373 relocInfo::change_reloc_info_for_address(&iter, (address) instr_pc, 1374 relocInfo::none, rtype); 1375 } 1376 1377 } else { 1378 ICache::invalidate_range(copy_buff, *byte_count); 1379 NativeGeneralJump::insert_unconditional(instr_pc, being_initialized_entry); 1380 } 1381 } 1382 } 1383 } 1384 1385 // If we are patching in a non-perm oop, make sure the nmethod 1386 // is on the right list. 1387 { 1388 MutexLocker ml_code (current, CodeCache_lock, Mutex::_no_safepoint_check_flag); 1389 nmethod* nm = CodeCache::find_nmethod(caller_frame.pc()); 1390 guarantee(nm != NULL, "only nmethods can contain non-perm oops"); 1391 1392 // Since we've patched some oops in the nmethod, 1393 // (re)register it with the heap. 1394 Universe::heap()->register_nmethod(nm); 1395 } 1396 JRT_END 1397 1398 #else // DEOPTIMIZE_WHEN_PATCHING 1399 1400 void Runtime1::patch_code(JavaThread* current, Runtime1::StubID stub_id) { 1401 #ifndef PRODUCT 1402 if (PrintC1Statistics) { 1403 _patch_code_slowcase_cnt++; 1404 } 1405 #endif 1406 1407 // Enable WXWrite: the function is called by c1 stub as a runtime function 1408 // (see another implementation above). 1409 MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, current)); 1410 1411 if (TracePatching) { 1412 tty->print_cr("Deoptimizing because patch is needed"); 1413 } 1414 1415 RegisterMap reg_map(current, false); 1416 1417 frame runtime_frame = current->last_frame(); 1418 frame caller_frame = runtime_frame.sender(®_map); 1419 assert(caller_frame.is_compiled_frame(), "Wrong frame type"); 1420 1421 // Make sure the nmethod is invalidated, i.e. made not entrant. 1422 nmethod* nm = CodeCache::find_nmethod(caller_frame.pc()); 1423 if (nm != NULL) { 1424 nm->make_not_entrant(); 1425 } 1426 1427 Deoptimization::deoptimize_frame(current, caller_frame.id()); 1428 // Return to the now deoptimized frame. 1429 postcond(caller_is_deopted(current)); 1430 } 1431 1432 #endif // DEOPTIMIZE_WHEN_PATCHING 1433 1434 // Entry point for compiled code. We want to patch a nmethod. 1435 // We don't do a normal VM transition here because we want to 1436 // know after the patching is complete and any safepoint(s) are taken 1437 // if the calling nmethod was deoptimized. We do this by calling a 1438 // helper method which does the normal VM transition and when it 1439 // completes we can check for deoptimization. This simplifies the 1440 // assembly code in the cpu directories. 1441 // 1442 int Runtime1::move_klass_patching(JavaThread* current) { 1443 // 1444 // NOTE: we are still in Java 1445 // 1446 debug_only(NoHandleMark nhm;) 1447 { 1448 // Enter VM mode 1449 ResetNoHandleMark rnhm; 1450 patch_code(current, load_klass_patching_id); 1451 } 1452 // Back in JAVA, use no oops DON'T safepoint 1453 1454 // Return true if calling code is deoptimized 1455 1456 return caller_is_deopted(current); 1457 } 1458 1459 int Runtime1::move_mirror_patching(JavaThread* current) { 1460 // 1461 // NOTE: we are still in Java 1462 // 1463 debug_only(NoHandleMark nhm;) 1464 { 1465 // Enter VM mode 1466 ResetNoHandleMark rnhm; 1467 patch_code(current, load_mirror_patching_id); 1468 } 1469 // Back in JAVA, use no oops DON'T safepoint 1470 1471 // Return true if calling code is deoptimized 1472 1473 return caller_is_deopted(current); 1474 } 1475 1476 int Runtime1::move_appendix_patching(JavaThread* current) { 1477 // 1478 // NOTE: we are still in Java 1479 // 1480 debug_only(NoHandleMark nhm;) 1481 { 1482 // Enter VM mode 1483 ResetNoHandleMark rnhm; 1484 patch_code(current, load_appendix_patching_id); 1485 } 1486 // Back in JAVA, use no oops DON'T safepoint 1487 1488 // Return true if calling code is deoptimized 1489 1490 return caller_is_deopted(current); 1491 } 1492 1493 // Entry point for compiled code. We want to patch a nmethod. 1494 // We don't do a normal VM transition here because we want to 1495 // know after the patching is complete and any safepoint(s) are taken 1496 // if the calling nmethod was deoptimized. We do this by calling a 1497 // helper method which does the normal VM transition and when it 1498 // completes we can check for deoptimization. This simplifies the 1499 // assembly code in the cpu directories. 1500 // 1501 int Runtime1::access_field_patching(JavaThread* current) { 1502 // 1503 // NOTE: we are still in Java 1504 // 1505 // Handles created in this function will be deleted by the 1506 // HandleMarkCleaner in the transition to the VM. 1507 NoHandleMark nhm; 1508 { 1509 // Enter VM mode 1510 ResetNoHandleMark rnhm; 1511 patch_code(current, access_field_patching_id); 1512 } 1513 // Back in JAVA, use no oops DON'T safepoint 1514 1515 // Return true if calling code is deoptimized 1516 1517 return caller_is_deopted(current); 1518 } 1519 1520 1521 JRT_LEAF(void, Runtime1::trace_block_entry(jint block_id)) 1522 // for now we just print out the block id 1523 tty->print("%d ", block_id); 1524 JRT_END 1525 1526 1527 JRT_LEAF(int, Runtime1::is_instance_of(oopDesc* mirror, oopDesc* obj)) 1528 // had to return int instead of bool, otherwise there may be a mismatch 1529 // between the C calling convention and the Java one. 1530 // e.g., on x86, GCC may clear only %al when returning a bool false, but 1531 // JVM takes the whole %eax as the return value, which may misinterpret 1532 // the return value as a boolean true. 1533 1534 assert(mirror != NULL, "should null-check on mirror before calling"); 1535 Klass* k = java_lang_Class::as_Klass(mirror); 1536 return (k != NULL && obj != NULL && obj->is_a(k)) ? 1 : 0; 1537 JRT_END 1538 1539 JRT_ENTRY(void, Runtime1::predicate_failed_trap(JavaThread* current)) 1540 ResourceMark rm; 1541 1542 RegisterMap reg_map(current, false); 1543 frame runtime_frame = current->last_frame(); 1544 frame caller_frame = runtime_frame.sender(®_map); 1545 1546 nmethod* nm = CodeCache::find_nmethod(caller_frame.pc()); 1547 assert (nm != NULL, "no more nmethod?"); 1548 nm->make_not_entrant(); 1549 1550 methodHandle m(current, nm->method()); 1551 MethodData* mdo = m->method_data(); 1552 1553 if (mdo == NULL && !HAS_PENDING_EXCEPTION) { 1554 // Build an MDO. Ignore errors like OutOfMemory; 1555 // that simply means we won't have an MDO to update. 1556 Method::build_interpreter_method_data(m, THREAD); 1557 if (HAS_PENDING_EXCEPTION) { 1558 // Only metaspace OOM is expected. No Java code executed. 1559 assert((PENDING_EXCEPTION->is_a(vmClasses::OutOfMemoryError_klass())), "we expect only an OOM error here"); 1560 CLEAR_PENDING_EXCEPTION; 1561 } 1562 mdo = m->method_data(); 1563 } 1564 1565 if (mdo != NULL) { 1566 mdo->inc_trap_count(Deoptimization::Reason_none); 1567 } 1568 1569 if (TracePredicateFailedTraps) { 1570 stringStream ss1, ss2; 1571 vframeStream vfst(current); 1572 Method* inlinee = vfst.method(); 1573 inlinee->print_short_name(&ss1); 1574 m->print_short_name(&ss2); 1575 tty->print_cr("Predicate failed trap in method %s at bci %d inlined in %s at pc " INTPTR_FORMAT, ss1.as_string(), vfst.bci(), ss2.as_string(), p2i(caller_frame.pc())); 1576 } 1577 1578 1579 Deoptimization::deoptimize_frame(current, caller_frame.id()); 1580 1581 JRT_END 1582 1583 #ifndef PRODUCT 1584 void Runtime1::print_statistics() { 1585 tty->print_cr("C1 Runtime statistics:"); 1586 tty->print_cr(" _resolve_invoke_virtual_cnt: %d", SharedRuntime::_resolve_virtual_ctr); 1587 tty->print_cr(" _resolve_invoke_opt_virtual_cnt: %d", SharedRuntime::_resolve_opt_virtual_ctr); 1588 tty->print_cr(" _resolve_invoke_static_cnt: %d", SharedRuntime::_resolve_static_ctr); 1589 tty->print_cr(" _handle_wrong_method_cnt: %d", SharedRuntime::_wrong_method_ctr); 1590 tty->print_cr(" _ic_miss_cnt: %d", SharedRuntime::_ic_miss_ctr); 1591 tty->print_cr(" _generic_arraycopystub_cnt: %d", _generic_arraycopystub_cnt); 1592 tty->print_cr(" _byte_arraycopy_cnt: %d", _byte_arraycopy_stub_cnt); 1593 tty->print_cr(" _short_arraycopy_cnt: %d", _short_arraycopy_stub_cnt); 1594 tty->print_cr(" _int_arraycopy_cnt: %d", _int_arraycopy_stub_cnt); 1595 tty->print_cr(" _long_arraycopy_cnt: %d", _long_arraycopy_stub_cnt); 1596 tty->print_cr(" _oop_arraycopy_cnt: %d", _oop_arraycopy_stub_cnt); 1597 tty->print_cr(" _arraycopy_slowcase_cnt: %d", _arraycopy_slowcase_cnt); 1598 tty->print_cr(" _arraycopy_checkcast_cnt: %d", _arraycopy_checkcast_cnt); 1599 tty->print_cr(" _arraycopy_checkcast_attempt_cnt:%d", _arraycopy_checkcast_attempt_cnt); 1600 1601 tty->print_cr(" _new_type_array_slowcase_cnt: %d", _new_type_array_slowcase_cnt); 1602 tty->print_cr(" _new_object_array_slowcase_cnt: %d", _new_object_array_slowcase_cnt); 1603 tty->print_cr(" _new_flat_array_slowcase_cnt: %d", _new_flat_array_slowcase_cnt); 1604 tty->print_cr(" _new_instance_slowcase_cnt: %d", _new_instance_slowcase_cnt); 1605 tty->print_cr(" _new_multi_array_slowcase_cnt: %d", _new_multi_array_slowcase_cnt); 1606 tty->print_cr(" _load_flattened_array_slowcase_cnt: %d", _load_flattened_array_slowcase_cnt); 1607 tty->print_cr(" _store_flattened_array_slowcase_cnt: %d", _store_flattened_array_slowcase_cnt); 1608 tty->print_cr(" _substitutability_check_slowcase_cnt: %d", _substitutability_check_slowcase_cnt); 1609 tty->print_cr(" _buffer_inline_args_slowcase_cnt:%d", _buffer_inline_args_slowcase_cnt); 1610 tty->print_cr(" _buffer_inline_args_no_receiver_slowcase_cnt:%d", _buffer_inline_args_no_receiver_slowcase_cnt); 1611 1612 tty->print_cr(" _monitorenter_slowcase_cnt: %d", _monitorenter_slowcase_cnt); 1613 tty->print_cr(" _monitorexit_slowcase_cnt: %d", _monitorexit_slowcase_cnt); 1614 tty->print_cr(" _patch_code_slowcase_cnt: %d", _patch_code_slowcase_cnt); 1615 1616 tty->print_cr(" _throw_range_check_exception_count: %d:", _throw_range_check_exception_count); 1617 tty->print_cr(" _throw_index_exception_count: %d:", _throw_index_exception_count); 1618 tty->print_cr(" _throw_div0_exception_count: %d:", _throw_div0_exception_count); 1619 tty->print_cr(" _throw_null_pointer_exception_count: %d:", _throw_null_pointer_exception_count); 1620 tty->print_cr(" _throw_class_cast_exception_count: %d:", _throw_class_cast_exception_count); 1621 tty->print_cr(" _throw_incompatible_class_change_error_count: %d:", _throw_incompatible_class_change_error_count); 1622 tty->print_cr(" _throw_illegal_monitor_state_exception_count: %d:", _throw_illegal_monitor_state_exception_count); 1623 tty->print_cr(" _throw_count: %d:", _throw_count); 1624 1625 SharedRuntime::print_ic_miss_histogram(); 1626 tty->cr(); 1627 } 1628 #endif // PRODUCT