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