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