equal
deleted
inserted
replaced
444 OopMapSet* oop_maps) { |
444 OopMapSet* oop_maps) { |
445 code_buffer->finalize_oop_references(method); |
445 code_buffer->finalize_oop_references(method); |
446 // create nmethod |
446 // create nmethod |
447 nmethod* nm = NULL; |
447 nmethod* nm = NULL; |
448 { |
448 { |
449 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
449 MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
450 int native_nmethod_size = CodeBlob::allocation_size(code_buffer, sizeof(nmethod)); |
450 int native_nmethod_size = CodeBlob::allocation_size(code_buffer, sizeof(nmethod)); |
451 CodeOffsets offsets; |
451 CodeOffsets offsets; |
452 offsets.set_value(CodeOffsets::Verified_Entry, vep_offset); |
452 offsets.set_value(CodeOffsets::Verified_Entry, vep_offset); |
453 offsets.set_value(CodeOffsets::Frame_Complete, frame_complete); |
453 offsets.set_value(CodeOffsets::Frame_Complete, frame_complete); |
454 nm = new (native_nmethod_size, CompLevel_none) nmethod(method(), compiler_none, native_nmethod_size, |
454 nm = new (native_nmethod_size, CompLevel_none) nmethod(method(), compiler_none, native_nmethod_size, |
490 { |
490 { |
491 assert(debug_info->oop_recorder() == code_buffer->oop_recorder(), "shared OR"); |
491 assert(debug_info->oop_recorder() == code_buffer->oop_recorder(), "shared OR"); |
492 code_buffer->finalize_oop_references(method); |
492 code_buffer->finalize_oop_references(method); |
493 // create nmethod |
493 // create nmethod |
494 nmethod* nm = NULL; |
494 nmethod* nm = NULL; |
495 { MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
495 { MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
496 int nmethod_size = |
496 int nmethod_size = |
497 CodeBlob::allocation_size(code_buffer, sizeof(nmethod)) |
497 CodeBlob::allocation_size(code_buffer, sizeof(nmethod)) |
498 + adjust_pcs_size(debug_info->pcs_size()) |
498 + adjust_pcs_size(debug_info->pcs_size()) |
499 + align_up((int)dependencies->size_in_bytes(), oopSize) |
499 + align_up((int)dependencies->size_in_bytes(), oopSize) |
500 + align_up(handler_table->size_in_bytes() , oopSize) |
500 + align_up(handler_table->size_in_bytes() , oopSize) |
1101 clear_ic_callsites(); |
1101 clear_ic_callsites(); |
1102 } |
1102 } |
1103 |
1103 |
1104 // Unregister must be done before the state change |
1104 // Unregister must be done before the state change |
1105 { |
1105 { |
1106 MutexLockerEx ml(SafepointSynchronize::is_at_safepoint() ? NULL : CodeCache_lock, |
1106 MutexLocker ml(SafepointSynchronize::is_at_safepoint() ? NULL : CodeCache_lock, |
1107 Mutex::_no_safepoint_check_flag); |
1107 Mutex::_no_safepoint_check_flag); |
1108 Universe::heap()->unregister_nmethod(this); |
1108 Universe::heap()->unregister_nmethod(this); |
1109 CodeCache::unregister_old_nmethod(this); |
1109 CodeCache::unregister_old_nmethod(this); |
1110 } |
1110 } |
1111 |
1111 |
1220 // this effectively makes the osr nmethod not entrant |
1220 // this effectively makes the osr nmethod not entrant |
1221 invalidate_osr_method(); |
1221 invalidate_osr_method(); |
1222 } |
1222 } |
1223 |
1223 |
1224 // Enter critical section. Does not block for safepoint. |
1224 // Enter critical section. Does not block for safepoint. |
1225 MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag); |
1225 MutexLocker pl(Patching_lock, Mutex::_no_safepoint_check_flag); |
1226 |
1226 |
1227 if (_state == state) { |
1227 if (_state == state) { |
1228 // another thread already performed this transition so nothing |
1228 // another thread already performed this transition so nothing |
1229 // to do, but return false to indicate this. |
1229 // to do, but return false to indicate this. |
1230 return false; |
1230 return false; |
1287 if (state == zombie) { |
1287 if (state == zombie) { |
1288 { |
1288 { |
1289 // Flushing dependencies must be done before any possible |
1289 // Flushing dependencies must be done before any possible |
1290 // safepoint can sneak in, otherwise the oops used by the |
1290 // safepoint can sneak in, otherwise the oops used by the |
1291 // dependency logic could have become stale. |
1291 // dependency logic could have become stale. |
1292 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
1292 MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
1293 if (nmethod_needs_unregister) { |
1293 if (nmethod_needs_unregister) { |
1294 Universe::heap()->unregister_nmethod(this); |
1294 Universe::heap()->unregister_nmethod(this); |
1295 CodeCache::unregister_old_nmethod(this); |
1295 CodeCache::unregister_old_nmethod(this); |
1296 } |
1296 } |
1297 flush_dependencies(/*delete_immediately*/true); |
1297 flush_dependencies(/*delete_immediately*/true); |
1332 NMethodSweeper::report_state_change(this); |
1332 NMethodSweeper::report_state_change(this); |
1333 return true; |
1333 return true; |
1334 } |
1334 } |
1335 |
1335 |
1336 void nmethod::flush() { |
1336 void nmethod::flush() { |
1337 MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
1337 MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); |
1338 // Note that there are no valid oops in the nmethod anymore. |
1338 // Note that there are no valid oops in the nmethod anymore. |
1339 assert(!is_osr_method() || is_unloaded() || is_zombie(), |
1339 assert(!is_osr_method() || is_unloaded() || is_zombie(), |
1340 "osr nmethod must be unloaded or zombie before flushing"); |
1340 "osr nmethod must be unloaded or zombie before flushing"); |
1341 assert(is_zombie() || is_osr_method(), "must be a zombie method"); |
1341 assert(is_zombie() || is_osr_method(), "must be a zombie method"); |
1342 assert (!is_locked_by_vm(), "locked methods shouldn't be flushed"); |
1342 assert (!is_locked_by_vm(), "locked methods shouldn't be flushed"); |
1450 get_and_cache_jmethod_id(); |
1450 get_and_cache_jmethod_id(); |
1451 } |
1451 } |
1452 |
1452 |
1453 if (JvmtiExport::should_post_compiled_method_load()) { |
1453 if (JvmtiExport::should_post_compiled_method_load()) { |
1454 // Let the Service thread (which is a real Java thread) post the event |
1454 // Let the Service thread (which is a real Java thread) post the event |
1455 MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag); |
1455 MutexLocker ml(Service_lock, Mutex::_no_safepoint_check_flag); |
1456 JvmtiDeferredEventQueue::enqueue( |
1456 JvmtiDeferredEventQueue::enqueue( |
1457 JvmtiDeferredEvent::compiled_method_load_event(this)); |
1457 JvmtiDeferredEvent::compiled_method_load_event(this)); |
1458 } |
1458 } |
1459 } |
1459 } |
1460 |
1460 |
1488 if (_jmethod_id != NULL && JvmtiExport::should_post_compiled_method_unload()) { |
1488 if (_jmethod_id != NULL && JvmtiExport::should_post_compiled_method_unload()) { |
1489 assert(!unload_reported(), "already unloaded"); |
1489 assert(!unload_reported(), "already unloaded"); |
1490 JvmtiDeferredEvent event = |
1490 JvmtiDeferredEvent event = |
1491 JvmtiDeferredEvent::compiled_method_unload_event(this, |
1491 JvmtiDeferredEvent::compiled_method_unload_event(this, |
1492 _jmethod_id, insts_begin()); |
1492 _jmethod_id, insts_begin()); |
1493 MutexLockerEx ml(Service_lock, Mutex::_no_safepoint_check_flag); |
1493 MutexLocker ml(Service_lock, Mutex::_no_safepoint_check_flag); |
1494 JvmtiDeferredEventQueue::enqueue(event); |
1494 JvmtiDeferredEventQueue::enqueue(event); |
1495 } |
1495 } |
1496 |
1496 |
1497 // The JVMTI CompiledMethodUnload event can be enabled or disabled at |
1497 // The JVMTI CompiledMethodUnload event can be enabled or disabled at |
1498 // any time. As the nmethod is being unloaded now we mark it has |
1498 // any time. As the nmethod is being unloaded now we mark it has |
2920 } |
2920 } |
2921 |
2921 |
2922 nmethodLocker nml(nm); |
2922 nmethodLocker nml(nm); |
2923 #ifdef ASSERT |
2923 #ifdef ASSERT |
2924 { |
2924 { |
2925 MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag); |
2925 MutexLocker pl(Patching_lock, Mutex::_no_safepoint_check_flag); |
2926 // This relationship can only be checked safely under a lock |
2926 // This relationship can only be checked safely under a lock |
2927 assert(!nm->is_alive() || nm->is_unloading() || nm->jvmci_installed_code() == installedCode(), "sanity check"); |
2927 assert(!nm->is_alive() || nm->is_unloading() || nm->jvmci_installed_code() == installedCode(), "sanity check"); |
2928 } |
2928 } |
2929 #endif |
2929 #endif |
2930 |
2930 |
2937 } |
2937 } |
2938 |
2938 |
2939 // Multiple threads could reach this point so we now need to |
2939 // Multiple threads could reach this point so we now need to |
2940 // lock and re-check the link to the nmethod so that only one |
2940 // lock and re-check the link to the nmethod so that only one |
2941 // thread clears it. |
2941 // thread clears it. |
2942 MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag); |
2942 MutexLocker pl(Patching_lock, Mutex::_no_safepoint_check_flag); |
2943 if (InstalledCode::address(installedCode) == nativeMethod) { |
2943 if (InstalledCode::address(installedCode) == nativeMethod) { |
2944 InstalledCode::set_address(installedCode, 0); |
2944 InstalledCode::set_address(installedCode, 0); |
2945 } |
2945 } |
2946 } |
2946 } |
2947 |
2947 |