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