diff --git a/src/hotspot/cpu/aarch64/frame_aarch64.cpp b/src/hotspot/cpu/aarch64/frame_aarch64.cpp index 7acfa79d8b703..0387f763bbdd7 100644 --- a/src/hotspot/cpu/aarch64/frame_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/frame_aarch64.cpp @@ -297,7 +297,7 @@ void frame::patch_pc(Thread* thread, address pc) { DEBUG_ONLY(address old_pc = _pc;) *pc_addr = signed_pc; _pc = pc; // must be set before call to get_deopt_original_pc - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = get_deopt_original_pc(); if (original_pc != nullptr) { assert(original_pc == old_pc, "expected original PC to be stored before patching"); _deopt_state = is_deoptimized; diff --git a/src/hotspot/cpu/aarch64/frame_aarch64.inline.hpp b/src/hotspot/cpu/aarch64/frame_aarch64.inline.hpp index 1dc3208948bc9..f7b33931f8dbf 100644 --- a/src/hotspot/cpu/aarch64/frame_aarch64.inline.hpp +++ b/src/hotspot/cpu/aarch64/frame_aarch64.inline.hpp @@ -71,7 +71,7 @@ inline void frame::init(intptr_t* sp, intptr_t* fp, address pc) { inline void frame::setup(address pc) { adjust_unextended_sp(); - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = get_deopt_original_pc(); if (original_pc != nullptr) { _pc = original_pc; _deopt_state = is_deoptimized; @@ -178,7 +178,7 @@ inline frame::frame(intptr_t* sp, intptr_t* fp) { _cb = CodeCache::find_blob(_pc); adjust_unextended_sp(); - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = get_deopt_original_pc(); if (original_pc != nullptr) { _pc = original_pc; _deopt_state = is_deoptimized; diff --git a/src/hotspot/cpu/arm/frame_arm.cpp b/src/hotspot/cpu/arm/frame_arm.cpp index b22cc5c605f3b..6221191e92634 100644 --- a/src/hotspot/cpu/arm/frame_arm.cpp +++ b/src/hotspot/cpu/arm/frame_arm.cpp @@ -229,7 +229,7 @@ void frame::patch_pc(Thread* thread, address pc) { DEBUG_ONLY(address old_pc = _pc;) *pc_addr = pc; _pc = pc; // must be set before call to get_deopt_original_pc - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = get_deopt_original_pc(); if (original_pc != nullptr) { assert(original_pc == old_pc, "expected original PC to be stored before patching"); _deopt_state = is_deoptimized; diff --git a/src/hotspot/cpu/arm/frame_arm.inline.hpp b/src/hotspot/cpu/arm/frame_arm.inline.hpp index 0ffd8829c0f7d..801b2f6177c3b 100644 --- a/src/hotspot/cpu/arm/frame_arm.inline.hpp +++ b/src/hotspot/cpu/arm/frame_arm.inline.hpp @@ -58,7 +58,7 @@ inline void frame::init(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, add adjust_unextended_sp(); DEBUG_ONLY(_frame_index = -1;) - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = get_deopt_original_pc(); if (original_pc != nullptr) { _pc = original_pc; assert(_cb->as_nmethod()->insts_contains_inclusive(_pc), diff --git a/src/hotspot/cpu/ppc/frame_ppc.cpp b/src/hotspot/cpu/ppc/frame_ppc.cpp index 9841e658a1792..4c1ffeb0d768e 100644 --- a/src/hotspot/cpu/ppc/frame_ppc.cpp +++ b/src/hotspot/cpu/ppc/frame_ppc.cpp @@ -280,7 +280,7 @@ void frame::patch_pc(Thread* thread, address pc) { DEBUG_ONLY(address old_pc = _pc;) own_abi()->lr = (uint64_t)pc; _pc = pc; // must be set before call to get_deopt_original_pc - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = get_deopt_original_pc(); if (original_pc != nullptr) { assert(original_pc == old_pc, "expected original PC to be stored before patching"); _deopt_state = is_deoptimized; diff --git a/src/hotspot/cpu/ppc/frame_ppc.inline.hpp b/src/hotspot/cpu/ppc/frame_ppc.inline.hpp index a14051bff6397..9966ae3f47847 100644 --- a/src/hotspot/cpu/ppc/frame_ppc.inline.hpp +++ b/src/hotspot/cpu/ppc/frame_ppc.inline.hpp @@ -61,7 +61,7 @@ inline void frame::setup(kind knd) { } } - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = get_deopt_original_pc(); if (original_pc != nullptr) { _pc = original_pc; _deopt_state = is_deoptimized; diff --git a/src/hotspot/cpu/riscv/frame_riscv.cpp b/src/hotspot/cpu/riscv/frame_riscv.cpp index 6d8eba2cb294a..32825a02c5eac 100644 --- a/src/hotspot/cpu/riscv/frame_riscv.cpp +++ b/src/hotspot/cpu/riscv/frame_riscv.cpp @@ -273,7 +273,7 @@ void frame::patch_pc(Thread* thread, address pc) { DEBUG_ONLY(address old_pc = _pc;) *pc_addr = pc; _pc = pc; // must be set before call to get_deopt_original_pc - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = get_deopt_original_pc(); if (original_pc != nullptr) { assert(original_pc == old_pc, "expected original PC to be stored before patching"); _deopt_state = is_deoptimized; diff --git a/src/hotspot/cpu/riscv/frame_riscv.inline.hpp b/src/hotspot/cpu/riscv/frame_riscv.inline.hpp index a4e75e09cfe6a..06c5c9f1cdb3b 100644 --- a/src/hotspot/cpu/riscv/frame_riscv.inline.hpp +++ b/src/hotspot/cpu/riscv/frame_riscv.inline.hpp @@ -69,7 +69,7 @@ inline void frame::init(intptr_t* ptr_sp, intptr_t* ptr_fp, address pc) { inline void frame::setup(address pc) { adjust_unextended_sp(); - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = get_deopt_original_pc(); if (original_pc != nullptr) { _pc = original_pc; _deopt_state = is_deoptimized; @@ -170,7 +170,7 @@ inline frame::frame(intptr_t* ptr_sp, intptr_t* ptr_fp) { _cb = CodeCache::find_blob(_pc); adjust_unextended_sp(); - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = get_deopt_original_pc(); if (original_pc != nullptr) { _pc = original_pc; _deopt_state = is_deoptimized; diff --git a/src/hotspot/cpu/s390/frame_s390.cpp b/src/hotspot/cpu/s390/frame_s390.cpp index 62619aa16173d..11c7386dfd776 100644 --- a/src/hotspot/cpu/s390/frame_s390.cpp +++ b/src/hotspot/cpu/s390/frame_s390.cpp @@ -267,7 +267,7 @@ void frame::patch_pc(Thread* thread, address pc) { DEBUG_ONLY(address old_pc = _pc;) own_abi()->return_pc = (uint64_t)pc; _pc = pc; // must be set before call to get_deopt_original_pc - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = get_deopt_original_pc(); if (original_pc != nullptr) { // assert(original_pc == _pc, "expected original to be stored before patching"); _deopt_state = is_deoptimized; diff --git a/src/hotspot/cpu/s390/frame_s390.inline.hpp b/src/hotspot/cpu/s390/frame_s390.inline.hpp index 2609da19df3ec..62e202337fef4 100644 --- a/src/hotspot/cpu/s390/frame_s390.inline.hpp +++ b/src/hotspot/cpu/s390/frame_s390.inline.hpp @@ -56,7 +56,7 @@ inline void frame::setup() { assert(_on_heap || (is_aligned(_sp, alignment_in_bytes) && is_aligned(_fp, alignment_in_bytes)), "invalid alignment sp:" PTR_FORMAT " unextended_sp:" PTR_FORMAT " fp:" PTR_FORMAT, p2i(_sp), p2i(_unextended_sp), p2i(_fp)); - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = get_deopt_original_pc(); if (original_pc != nullptr) { _pc = original_pc; _deopt_state = is_deoptimized; diff --git a/src/hotspot/cpu/x86/frame_x86.cpp b/src/hotspot/cpu/x86/frame_x86.cpp index bff81df1df169..2366d31992d6e 100644 --- a/src/hotspot/cpu/x86/frame_x86.cpp +++ b/src/hotspot/cpu/x86/frame_x86.cpp @@ -283,7 +283,7 @@ void frame::patch_pc(Thread* thread, address pc) { DEBUG_ONLY(address old_pc = _pc;) *pc_addr = pc; _pc = pc; // must be set before call to get_deopt_original_pc - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = get_deopt_original_pc(); if (original_pc != nullptr) { assert(original_pc == old_pc, "expected original PC to be stored before patching"); _deopt_state = is_deoptimized; diff --git a/src/hotspot/cpu/x86/frame_x86.inline.hpp b/src/hotspot/cpu/x86/frame_x86.inline.hpp index 55e263d4a0bf2..0f7e536a494f7 100644 --- a/src/hotspot/cpu/x86/frame_x86.inline.hpp +++ b/src/hotspot/cpu/x86/frame_x86.inline.hpp @@ -66,7 +66,7 @@ inline void frame::init(intptr_t* sp, intptr_t* fp, address pc) { inline void frame::setup(address pc) { adjust_unextended_sp(); - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = get_deopt_original_pc(); if (original_pc != nullptr) { _pc = original_pc; _deopt_state = is_deoptimized; @@ -164,7 +164,7 @@ inline frame::frame(intptr_t* sp, intptr_t* fp) { _cb = CodeCache::find_blob(_pc); adjust_unextended_sp(); - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = get_deopt_original_pc(); if (original_pc != nullptr) { _pc = original_pc; _deopt_state = is_deoptimized; diff --git a/src/hotspot/share/ci/ciEnv.cpp b/src/hotspot/share/ci/ciEnv.cpp index 81db61ad99307..40abaa06df269 100644 --- a/src/hotspot/share/ci/ciEnv.cpp +++ b/src/hotspot/share/ci/ciEnv.cpp @@ -1160,7 +1160,7 @@ void ciEnv::register_method(ciMethod* target, task()->comp_level(), method_name); } // Allow the code to be executed - MutexLocker ml(CompiledMethod_lock, Mutex::_no_safepoint_check_flag); + MutexLocker ml(NMethodState_lock, Mutex::_no_safepoint_check_flag); if (nm->make_in_use()) { method->set_code(method, nm); } @@ -1172,7 +1172,7 @@ void ciEnv::register_method(ciMethod* target, lt.print("Installing osr method (%d) %s @ %d", task()->comp_level(), method_name, entry_bci); } - MutexLocker ml(CompiledMethod_lock, Mutex::_no_safepoint_check_flag); + MutexLocker ml(NMethodState_lock, Mutex::_no_safepoint_check_flag); if (nm->make_in_use()) { method->method_holder()->add_osr_nmethod(nm); } diff --git a/src/hotspot/share/code/codeCache.cpp b/src/hotspot/share/code/codeCache.cpp index 4327f5556b71b..6fed6712b60ae 100644 --- a/src/hotspot/share/code/codeCache.cpp +++ b/src/hotspot/share/code/codeCache.cpp @@ -664,8 +664,8 @@ CodeBlob* CodeCache::find_blob(void* start) { nmethod* CodeCache::find_nmethod(void* start) { CodeBlob* cb = find_blob(start); - assert(cb != nullptr, "did not find an nmethod"); - return cb->as_nmethod(); + assert(cb == nullptr || cb->is_nmethod(), "did not find an nmethod"); + return (nmethod*)cb; } void CodeCache::blobs_do(void f(CodeBlob* nm)) { @@ -679,7 +679,7 @@ void CodeCache::blobs_do(void f(CodeBlob* nm)) { void CodeCache::nmethods_do(void f(nmethod* nm)) { assert_locked_or_safepoint(CodeCache_lock); - NMethodIterator iter(NMethodIterator::all_blobs); + NMethodIterator iter(NMethodIterator::all); while(iter.next()) { f(iter.method()); } @@ -687,7 +687,7 @@ void CodeCache::nmethods_do(void f(nmethod* nm)) { void CodeCache::metadata_do(MetadataClosure* f) { assert_locked_or_safepoint(CodeCache_lock); - NMethodIterator iter(NMethodIterator::all_blobs); + NMethodIterator iter(NMethodIterator::all); while(iter.next()) { iter.method()->metadata_do(f); } @@ -877,7 +877,7 @@ void CodeCache::arm_all_nmethods() { // Mark nmethods for unloading if they contain otherwise unreachable oops. void CodeCache::do_unloading(bool unloading_occurred) { assert_locked_or_safepoint(CodeCache_lock); - NMethodIterator iter(NMethodIterator::all_blobs); + NMethodIterator iter(NMethodIterator::all); while(iter.next()) { iter.method()->do_unloading(unloading_occurred); } @@ -899,7 +899,7 @@ void CodeCache::blobs_do(CodeBlobClosure* f) { void CodeCache::verify_clean_inline_caches() { #ifdef ASSERT - NMethodIterator iter(NMethodIterator::only_not_unloading); + NMethodIterator iter(NMethodIterator::not_unloading); while(iter.next()) { nmethod* nm = iter.method(); nm->verify_clean_inline_caches(); @@ -978,7 +978,7 @@ CodeCache::UnlinkingScope::~UnlinkingScope() { void CodeCache::verify_oops() { MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); VerifyOopClosure voc; - NMethodIterator iter(NMethodIterator::only_not_unloading); + NMethodIterator iter(NMethodIterator::not_unloading); while(iter.next()) { nmethod* nm = iter.method(); nm->oops_do(&voc); @@ -1006,8 +1006,8 @@ int CodeCache::nmethod_count(CodeBlobType code_blob_type) { int CodeCache::nmethod_count() { int count = 0; - for (GrowableArrayIterator heap = _nmethod_heaps->begin(); heap != _nmethod_heaps->end(); ++heap) { - count += (*heap)->nmethod_count(); + for (CodeHeap* heap : *_nmethod_heaps) { + count += heap->nmethod_count(); } return count; } @@ -1173,7 +1173,7 @@ bool CodeCache::has_nmethods_with_dependencies() { void CodeCache::clear_inline_caches() { assert_locked_or_safepoint(CodeCache_lock); - NMethodIterator iter(NMethodIterator::only_not_unloading); + NMethodIterator iter(NMethodIterator::not_unloading); while(iter.next()) { iter.method()->clear_inline_caches(); } @@ -1182,7 +1182,7 @@ void CodeCache::clear_inline_caches() { // Only used by whitebox API void CodeCache::cleanup_inline_caches_whitebox() { assert_locked_or_safepoint(CodeCache_lock); - NMethodIterator iter(NMethodIterator::only_not_unloading); + NMethodIterator iter(NMethodIterator::not_unloading); while(iter.next()) { iter.method()->cleanup_inline_caches_whitebox(); } @@ -1210,7 +1210,7 @@ static void check_live_nmethods_dependencies(DepChange& changes) { // Iterate over live nmethods and check dependencies of all nmethods that are not // marked for deoptimization. A particular dependency is only checked once. - NMethodIterator iter(NMethodIterator::only_not_unloading); + NMethodIterator iter(NMethodIterator::not_unloading); while(iter.next()) { nmethod* nm = iter.method(); // Only notify for live nmethods @@ -1318,7 +1318,7 @@ void CodeCache::mark_dependents_for_evol_deoptimization(DeoptimizationScope* deo // So delete old method table and create a new one. reset_old_method_table(); - NMethodIterator iter(NMethodIterator::all_blobs); + NMethodIterator iter(NMethodIterator::all); while(iter.next()) { nmethod* nm = iter.method(); // Walk all alive nmethods to check for old Methods. @@ -1333,7 +1333,7 @@ void CodeCache::mark_dependents_for_evol_deoptimization(DeoptimizationScope* deo void CodeCache::mark_all_nmethods_for_evol_deoptimization(DeoptimizationScope* deopt_scope) { assert(SafepointSynchronize::is_at_safepoint(), "Can only do this at a safepoint!"); - NMethodIterator iter(NMethodIterator::all_blobs); + NMethodIterator iter(NMethodIterator::all); while(iter.next()) { nmethod* nm = iter.method(); if (!nm->method()->is_method_handle_intrinsic()) { @@ -1354,7 +1354,7 @@ void CodeCache::mark_directives_matches(bool top_only) { Thread *thread = Thread::current(); HandleMark hm(thread); - NMethodIterator iter(NMethodIterator::only_not_unloading); + NMethodIterator iter(NMethodIterator::not_unloading); while(iter.next()) { nmethod* nm = iter.method(); methodHandle mh(thread, nm->method()); @@ -1372,7 +1372,7 @@ void CodeCache::recompile_marked_directives_matches() { // Try the max level and let the directives be applied during the compilation. int comp_level = CompilationPolicy::highest_compile_level(); - RelaxedNMethodIterator iter(RelaxedNMethodIterator::only_not_unloading); + RelaxedNMethodIterator iter(RelaxedNMethodIterator::not_unloading); while(iter.next()) { nmethod* nm = iter.method(); methodHandle mh(thread, nm->method()); @@ -1413,7 +1413,7 @@ void CodeCache::recompile_marked_directives_matches() { // Mark methods for deopt (if safe or possible). void CodeCache::mark_all_nmethods_for_deoptimization(DeoptimizationScope* deopt_scope) { MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); - NMethodIterator iter(NMethodIterator::only_not_unloading); + NMethodIterator iter(NMethodIterator::not_unloading); while(iter.next()) { nmethod* nm = iter.method(); if (!nm->is_native_method()) { @@ -1425,7 +1425,7 @@ void CodeCache::mark_all_nmethods_for_deoptimization(DeoptimizationScope* deopt_ void CodeCache::mark_for_deoptimization(DeoptimizationScope* deopt_scope, Method* dependee) { MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); - NMethodIterator iter(NMethodIterator::only_not_unloading); + NMethodIterator iter(NMethodIterator::not_unloading); while(iter.next()) { nmethod* nm = iter.method(); if (nm->is_dependent_on_method(dependee)) { @@ -1435,7 +1435,7 @@ void CodeCache::mark_for_deoptimization(DeoptimizationScope* deopt_scope, Method } void CodeCache::make_marked_nmethods_deoptimized() { - RelaxedNMethodIterator iter(RelaxedNMethodIterator::only_not_unloading); + RelaxedNMethodIterator iter(RelaxedNMethodIterator::not_unloading); while(iter.next()) { nmethod* nm = iter.method(); if (nm->is_marked_for_deoptimization() && !nm->has_been_deoptimized() && nm->can_be_deoptimized()) { @@ -1647,7 +1647,7 @@ void CodeCache::print_internals() { int *buckets = NEW_C_HEAP_ARRAY(int, bucketLimit, mtCode); memset(buckets, 0, sizeof(int) * bucketLimit); - NMethodIterator iter(NMethodIterator::all_blobs); + NMethodIterator iter(NMethodIterator::all); while(iter.next()) { nmethod* nm = iter.method(); if(nm->method() != nullptr && nm->is_java_method()) { @@ -1838,7 +1838,7 @@ void CodeCache::print_summary(outputStream* st, bool detailed) { void CodeCache::print_codelist(outputStream* st) { MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); - NMethodIterator iter(NMethodIterator::only_not_unloading); + NMethodIterator iter(NMethodIterator::not_unloading); while (iter.next()) { nmethod* nm = iter.method(); ResourceMark rm; @@ -1881,7 +1881,7 @@ void CodeCache::write_perf_map(const char* filename) { return; } - AllCodeBlobsIterator iter(AllCodeBlobsIterator::only_not_unloading); + AllCodeBlobsIterator iter(AllCodeBlobsIterator::not_unloading); while (iter.next()) { CodeBlob *cb = iter.method(); ResourceMark rm; diff --git a/src/hotspot/share/code/codeCache.hpp b/src/hotspot/share/code/codeCache.hpp index 584af0b761a74..bde121a1d8b3a 100644 --- a/src/hotspot/share/code/codeCache.hpp +++ b/src/hotspot/share/code/codeCache.hpp @@ -337,13 +337,13 @@ class CodeCache : AllStatic { // The relaxed iterators only hold the CodeCache_lock across next calls template class CodeBlobIterator : public StackObj { public: - enum LivenessFilter { all_blobs, only_not_unloading }; + enum LivenessFilter { all, not_unloading }; private: CodeBlob* _code_blob; // Current CodeBlob GrowableArrayIterator _heap; GrowableArrayIterator _end; - bool _only_not_unloading; + bool _not_unloading; // Those nmethods that are not unloading void initialize_iteration(T* nm) { } @@ -360,7 +360,7 @@ template class CodeBlobIterator : publi } // Filter is_unloading as required - if (_only_not_unloading) { + if (_not_unloading) { nmethod* nm = _code_blob->as_nmethod_or_null(); if (nm != nullptr && nm->is_unloading()) { continue; @@ -373,7 +373,7 @@ template class CodeBlobIterator : publi public: CodeBlobIterator(LivenessFilter filter, T* nm = nullptr) - : _only_not_unloading(filter == only_not_unloading) + : _not_unloading(filter == not_unloading) { if (Filter::heaps() == nullptr) { // The iterator is supposed to shortcut since we have diff --git a/src/hotspot/share/code/compiledIC.cpp b/src/hotspot/share/code/compiledIC.cpp index 9c71bc4c7c02c..079c8199b1870 100644 --- a/src/hotspot/share/code/compiledIC.cpp +++ b/src/hotspot/share/code/compiledIC.cpp @@ -345,6 +345,7 @@ void CompiledDirectCall::set_to_clean() { void CompiledDirectCall::set(const methodHandle& callee_method) { nmethod* code = callee_method->code(); nmethod* caller = CodeCache::find_nmethod(instruction_address()); + assert(caller != nullptr, "did not find caller nmethod"); bool to_interp_cont_enter = caller->method()->is_continuation_enter_intrinsic() && ContinuationEntry::is_interpreted_call(instruction_address()); @@ -378,11 +379,13 @@ bool CompiledDirectCall::is_call_to_interpreted() const { // It is a call to interpreted, if it calls to a stub. Hence, the destination // must be in the stub part of the nmethod that contains the call nmethod* nm = CodeCache::find_nmethod(instruction_address()); + assert(nm != nullptr, "did not find nmethod"); return nm->stub_contains(destination()); } bool CompiledDirectCall::is_call_to_compiled() const { nmethod* caller = CodeCache::find_nmethod(instruction_address()); + assert(caller != nullptr, "did not find caller nmethod"); CodeBlob* dest_cb = CodeCache::find_blob(destination()); return !caller->stub_contains(destination()) && dest_cb->is_nmethod(); } diff --git a/src/hotspot/share/code/nmethod.cpp b/src/hotspot/share/code/nmethod.cpp index c2970e23239f8..51ba872b3ac66 100644 --- a/src/hotspot/share/code/nmethod.cpp +++ b/src/hotspot/share/code/nmethod.cpp @@ -450,7 +450,7 @@ const char* nmethod::state() const { } void nmethod::set_deoptimized_done() { - ConditionalMutexLocker ml(CompiledMethod_lock, !CompiledMethod_lock->owned_by_self(), Mutex::_no_safepoint_check_flag); + ConditionalMutexLocker ml(NMethodState_lock, !NMethodState_lock->owned_by_self(), Mutex::_no_safepoint_check_flag); if (_deoptimization_status != deoptimize_done) { // can't go backwards Atomic::store(&_deoptimization_status, deoptimize_done); } @@ -1868,7 +1868,7 @@ void nmethod::inc_decompile_count() { bool nmethod::try_transition(signed char new_state_int) { signed char new_state = new_state_int; - assert_lock_strong(CompiledMethod_lock); + assert_lock_strong(NMethodState_lock); signed char old_state = _state; if (old_state >= new_state) { // Ensure monotonicity of transitions. @@ -1931,7 +1931,7 @@ bool nmethod::make_not_entrant() { { // Enter critical section. Does not block for safepoint. - ConditionalMutexLocker ml(CompiledMethod_lock, !CompiledMethod_lock->owned_by_self(), Mutex::_no_safepoint_check_flag); + ConditionalMutexLocker ml(NMethodState_lock, !NMethodState_lock->owned_by_self(), Mutex::_no_safepoint_check_flag); if (Atomic::load(&_state) == not_entrant) { // another thread already performed this transition so nothing @@ -1974,7 +1974,7 @@ bool nmethod::make_not_entrant() { // Remove nmethod from method. unlink_from_method(); - } // leave critical region under CompiledMethod_lock + } // leave critical region under NMethodState_lock #if INCLUDE_JVMCI // Invalidate can't occur while holding the Patching lock @@ -2004,7 +2004,7 @@ void nmethod::unlink() { flush_dependencies(); - // unlink_from_method will take the CompiledMethod_lock. + // unlink_from_method will take the NMethodState_lock. // In this case we don't strictly need it when unlinking nmethods from // the Method, because it is only concurrently unlinked by // the entry barrier, which acquires the per nmethod lock. @@ -2817,7 +2817,7 @@ void nmethod::verify() { nmethod* nm = CodeCache::find_nmethod(verified_entry_point()); if (nm != this) { - fatal("findNMethod did not find this nmethod (" INTPTR_FORMAT ")", p2i(this)); + fatal("find_nmethod did not find this nmethod (" INTPTR_FORMAT ")", p2i(this)); } for (PcDesc* p = scopes_pcs_begin(); p < scopes_pcs_end(); p++) { @@ -2900,7 +2900,7 @@ void nmethod::verify_scopes() { if (method()->is_native()) return; // Ignore stub methods. // iterate through all interrupt point // and verify the debug information is valid. - RelocIterator iter((nmethod*)this); + RelocIterator iter(this); while (iter.next()) { address stub = nullptr; switch (iter.type()) { diff --git a/src/hotspot/share/code/nmethod.hpp b/src/hotspot/share/code/nmethod.hpp index cca63a702b469..e4552992f4b60 100644 --- a/src/hotspot/share/code/nmethod.hpp +++ b/src/hotspot/share/code/nmethod.hpp @@ -272,7 +272,7 @@ class nmethod : public CodeBlob { // used by jvmti to track if an event has been posted for this nmethod. bool _load_reported; - // Protected by CompiledMethod_lock + // Protected by NMethodState_lock volatile signed char _state; // {not_installed, in_use, not_entrant} // set during construction @@ -756,8 +756,6 @@ class nmethod : public CodeBlob { address continuation_for_implicit_div0_exception(address pc) { return continuation_for_implicit_exception(pc, true); } address continuation_for_implicit_null_exception(address pc) { return continuation_for_implicit_exception(pc, false); } - static address get_deopt_original_pc(const frame* fr); - // Inline cache support for class unloading and nmethod unloading private: void cleanup_inline_caches_impl(bool unloading_occurred, bool clean_all); diff --git a/src/hotspot/share/code/nmethod.inline.hpp b/src/hotspot/share/code/nmethod.inline.hpp index 1b6ac5614b43b..4af4d3ffaedd9 100644 --- a/src/hotspot/share/code/nmethod.inline.hpp +++ b/src/hotspot/share/code/nmethod.inline.hpp @@ -50,24 +50,6 @@ inline bool nmethod::is_deopt_mh_entry(address pc) { ; } -// ----------------------------------------------------------------------------- -// nmethod::get_deopt_original_pc -// -// Return the original PC for the given PC if: -// (a) the given PC belongs to an nmethod and -// (b) it is a deopt PC - -inline address nmethod::get_deopt_original_pc(const frame* fr) { - if (fr->cb() == nullptr) return nullptr; - - nmethod* nm = fr->cb()->as_nmethod_or_null(); - if (nm != nullptr && nm->is_deopt_pc(fr->pc())) { - return nm->get_original_pc(fr); - } - return nullptr; -} - - // class ExceptionCache methods inline int ExceptionCache::count() { return Atomic::load_acquire(&_count); } diff --git a/src/hotspot/share/compiler/compileBroker.cpp b/src/hotspot/share/compiler/compileBroker.cpp index d569767c63d4e..a41718d583127 100644 --- a/src/hotspot/share/compiler/compileBroker.cpp +++ b/src/hotspot/share/compiler/compileBroker.cpp @@ -1379,7 +1379,7 @@ nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci, nmethod* method_code = method->code(); if (method_code != nullptr && (compile_reason != CompileTask::Reason_DirectivesChanged)) { if (compilation_is_complete(method, osr_bci, comp_level)) { - return (nmethod*) method_code; + return method_code; } } if (method->is_not_compilable(comp_level)) { diff --git a/src/hotspot/share/gc/shared/parallelCleaning.cpp b/src/hotspot/share/gc/shared/parallelCleaning.cpp index 1150657f2655a..3671500995ea8 100644 --- a/src/hotspot/share/gc/shared/parallelCleaning.cpp +++ b/src/hotspot/share/gc/shared/parallelCleaning.cpp @@ -38,7 +38,7 @@ CodeCacheUnloadingTask::CodeCacheUnloadingTask(uint num_workers, bool unloading_ _first_nmethod(nullptr), _claimed_nmethod(nullptr) { // Get first alive nmethod - NMethodIterator iter(NMethodIterator::all_blobs); + NMethodIterator iter(NMethodIterator::all); if(iter.next()) { _first_nmethod = iter.method(); } @@ -51,13 +51,13 @@ CodeCacheUnloadingTask::~CodeCacheUnloadingTask() { void CodeCacheUnloadingTask::claim_nmethods(nmethod** claimed_nmethods, int *num_claimed_nmethods) { nmethod* first; - NMethodIterator last(NMethodIterator::all_blobs); + NMethodIterator last(NMethodIterator::all); do { *num_claimed_nmethods = 0; first = _claimed_nmethod; - last = NMethodIterator(NMethodIterator::all_blobs, first); + last = NMethodIterator(NMethodIterator::all, first); if (first != nullptr) { diff --git a/src/hotspot/share/gc/shared/scavengableNMethods.cpp b/src/hotspot/share/gc/shared/scavengableNMethods.cpp index f444d4cffc25b..377551e5135e3 100644 --- a/src/hotspot/share/gc/shared/scavengableNMethods.cpp +++ b/src/hotspot/share/gc/shared/scavengableNMethods.cpp @@ -216,7 +216,7 @@ void ScavengableNMethods::unlist_nmethod(nmethod* nm, nmethod* prev) { #ifndef PRODUCT // Temporarily mark nmethods that are claimed to be on the scavenge list. void ScavengableNMethods::mark_on_list_nmethods() { - NMethodIterator iter(NMethodIterator::all_blobs); + NMethodIterator iter(NMethodIterator::all); while(iter.next()) { nmethod* nm = iter.method(); ScavengableNMethodsData data = gc_data(nm); @@ -229,7 +229,7 @@ void ScavengableNMethods::mark_on_list_nmethods() { // Make sure that the effects of mark_on_list_nmethods is gone. void ScavengableNMethods::verify_nmethods() { - NMethodIterator iter(NMethodIterator::all_blobs); + NMethodIterator iter(NMethodIterator::all); while(iter.next()) { nmethod* nm = iter.method(); diff --git a/src/hotspot/share/gc/z/zNMethod.cpp b/src/hotspot/share/gc/z/zNMethod.cpp index a7d23124b683f..a1639648acd9d 100644 --- a/src/hotspot/share/gc/z/zNMethod.cpp +++ b/src/hotspot/share/gc/z/zNMethod.cpp @@ -306,6 +306,7 @@ oop ZNMethod::load_oop(oop* p, DecoratorSet decorators) { assert((decorators & ON_WEAK_OOP_REF) == 0, "nmethod oops have phantom strength, not weak"); nmethod* const nm = CodeCache::find_nmethod((void*)p); + assert(nm != nullptr, "did not find nmethod"); if (!is_armed(nm)) { // If the nmethod entry barrier isn't armed, then it has been applied // already. The implication is that the contents of the memory location diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp index 861a96318b447..27bac1b6b4f56 100644 --- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp +++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp @@ -1750,8 +1750,7 @@ C2V_VMENTRY(void, materializeVirtualObjects, (JNIEnv* env, jobject, jobject _hs_ if (!fst.current()->is_compiled_frame()) { JVMCI_THROW_MSG(IllegalStateException, "compiled stack frame expected"); } - assert(fst.current()->cb()->is_nmethod(), "nmethod expected"); - ((nmethod*) fst.current()->cb())->make_not_entrant(); + fst.current()->cb()->as_nmethod()->make_not_entrant(); } Deoptimization::deoptimize(thread, *fst.current(), Deoptimization::Reason_none); // look for the frame again as it has been updated by deopt (pc, deopt state...) diff --git a/src/hotspot/share/jvmci/jvmciRuntime.cpp b/src/hotspot/share/jvmci/jvmciRuntime.cpp index 3d1351f91bbab..6bab80ddae6a1 100644 --- a/src/hotspot/share/jvmci/jvmciRuntime.cpp +++ b/src/hotspot/share/jvmci/jvmciRuntime.cpp @@ -268,6 +268,7 @@ JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* c StackWatermarkSet::after_unwind(current); nm = CodeCache::find_nmethod(pc); + assert(nm != nullptr, "did not find nmethod"); // Adjust the pc as needed/ if (nm->is_deopt_pc(pc)) { RegisterMap map(current, @@ -2225,7 +2226,7 @@ JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV, comp_level, method_name, nm->entry_point()); } // Allow the code to be executed - MutexLocker ml(CompiledMethod_lock, Mutex::_no_safepoint_check_flag); + MutexLocker ml(NMethodState_lock, Mutex::_no_safepoint_check_flag); if (nm->make_in_use()) { method->set_code(method, nm); } else { @@ -2239,7 +2240,7 @@ JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV, lt.print("Installing osr method (%d) %s @ %d", comp_level, method_name, entry_bci); } - MutexLocker ml(CompiledMethod_lock, Mutex::_no_safepoint_check_flag); + MutexLocker ml(NMethodState_lock, Mutex::_no_safepoint_check_flag); if (nm->make_in_use()) { InstanceKlass::cast(method->method_holder())->add_osr_nmethod(nm); } else { @@ -2248,7 +2249,7 @@ JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV, } } else { assert(!nmethod_mirror.is_hotspot() || data->get_nmethod_mirror(nm, /* phantom_ref */ false) == HotSpotJVMCI::resolve(nmethod_mirror), "must be"); - MutexLocker ml(CompiledMethod_lock, Mutex::_no_safepoint_check_flag); + MutexLocker ml(NMethodState_lock, Mutex::_no_safepoint_check_flag); if (!nm->make_in_use()) { result = JVMCI::nmethod_reclaimed; } diff --git a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp index a1d78762873c1..ec92a9e82274a 100644 --- a/src/hotspot/share/oops/instanceKlass.cpp +++ b/src/hotspot/share/oops/instanceKlass.cpp @@ -3355,7 +3355,7 @@ void InstanceKlass::adjust_default_methods(bool* trace_name_printed) { // On-stack replacement stuff void InstanceKlass::add_osr_nmethod(nmethod* n) { - assert_lock_strong(CompiledMethod_lock); + assert_lock_strong(NMethodState_lock); #ifndef PRODUCT nmethod* prev = lookup_osr_nmethod(n->method(), n->osr_entry_bci(), n->comp_level(), true); assert(prev == nullptr || !prev->is_in_use() COMPILER2_PRESENT(|| StressRecompilation), @@ -3380,7 +3380,7 @@ void InstanceKlass::add_osr_nmethod(nmethod* n) { // Remove osr nmethod from the list. Return true if found and removed. bool InstanceKlass::remove_osr_nmethod(nmethod* n) { // This is a short non-blocking critical region, so the no safepoint check is ok. - ConditionalMutexLocker ml(CompiledMethod_lock, !CompiledMethod_lock->owned_by_self(), Mutex::_no_safepoint_check_flag); + ConditionalMutexLocker ml(NMethodState_lock, !NMethodState_lock->owned_by_self(), Mutex::_no_safepoint_check_flag); assert(n->is_osr_method(), "wrong kind of nmethod"); nmethod* last = nullptr; nmethod* cur = osr_nmethods_head(); @@ -3421,7 +3421,7 @@ bool InstanceKlass::remove_osr_nmethod(nmethod* n) { } int InstanceKlass::mark_osr_nmethods(DeoptimizationScope* deopt_scope, const Method* m) { - ConditionalMutexLocker ml(CompiledMethod_lock, !CompiledMethod_lock->owned_by_self(), Mutex::_no_safepoint_check_flag); + ConditionalMutexLocker ml(NMethodState_lock, !NMethodState_lock->owned_by_self(), Mutex::_no_safepoint_check_flag); nmethod* osr = osr_nmethods_head(); int found = 0; while (osr != nullptr) { @@ -3436,7 +3436,7 @@ int InstanceKlass::mark_osr_nmethods(DeoptimizationScope* deopt_scope, const Met } nmethod* InstanceKlass::lookup_osr_nmethod(const Method* m, int bci, int comp_level, bool match_level) const { - ConditionalMutexLocker ml(CompiledMethod_lock, !CompiledMethod_lock->owned_by_self(), Mutex::_no_safepoint_check_flag); + ConditionalMutexLocker ml(NMethodState_lock, !NMethodState_lock->owned_by_self(), Mutex::_no_safepoint_check_flag); nmethod* osr = osr_nmethods_head(); nmethod* best = nullptr; while (osr != nullptr) { diff --git a/src/hotspot/share/oops/method.cpp b/src/hotspot/share/oops/method.cpp index 794c134205ea3..d2e25feef4022 100644 --- a/src/hotspot/share/oops/method.cpp +++ b/src/hotspot/share/oops/method.cpp @@ -1160,7 +1160,7 @@ void Method::clear_code() { } void Method::unlink_code(nmethod *compare) { - ConditionalMutexLocker ml(CompiledMethod_lock, !CompiledMethod_lock->owned_by_self(), Mutex::_no_safepoint_check_flag); + ConditionalMutexLocker ml(NMethodState_lock, !NMethodState_lock->owned_by_self(), Mutex::_no_safepoint_check_flag); // We need to check if either the _code or _from_compiled_code_entry_point // refer to this nmethod because there is a race in setting these two fields // in Method* as seen in bugid 4947125. @@ -1171,7 +1171,7 @@ void Method::unlink_code(nmethod *compare) { } void Method::unlink_code() { - ConditionalMutexLocker ml(CompiledMethod_lock, !CompiledMethod_lock->owned_by_self(), Mutex::_no_safepoint_check_flag); + ConditionalMutexLocker ml(NMethodState_lock, !NMethodState_lock->owned_by_self(), Mutex::_no_safepoint_check_flag); clear_code(); } @@ -1309,7 +1309,7 @@ bool Method::check_code() const { // Install compiled code. Instantly it can execute. void Method::set_code(const methodHandle& mh, nmethod *code) { - assert_lock_strong(CompiledMethod_lock); + assert_lock_strong(NMethodState_lock); assert( code, "use clear_code to remove code" ); assert( mh->check_code(), "" ); diff --git a/src/hotspot/share/oops/method.hpp b/src/hotspot/share/oops/method.hpp index 295d868d094aa..838178d2de292 100644 --- a/src/hotspot/share/oops/method.hpp +++ b/src/hotspot/share/oops/method.hpp @@ -359,13 +359,13 @@ class Method : public Metadata { bool check_code() const; // Not inline to avoid circular ref nmethod* code() const; - // Locks CompiledMethod_lock if not held. + // Locks NMethodState_lock if not held. void unlink_code(nmethod *compare); - // Locks CompiledMethod_lock if not held. + // Locks NMethodState_lock if not held. void unlink_code(); private: - // Either called with CompiledMethod_lock held or from constructor. + // Either called with NMethodState_lock held or from constructor. void clear_code(); void clear_method_data() { diff --git a/src/hotspot/share/prims/jvmtiCodeBlobEvents.cpp b/src/hotspot/share/prims/jvmtiCodeBlobEvents.cpp index df7e6de6c3363..a32bba9225a6d 100644 --- a/src/hotspot/share/prims/jvmtiCodeBlobEvents.cpp +++ b/src/hotspot/share/prims/jvmtiCodeBlobEvents.cpp @@ -234,7 +234,7 @@ jvmtiError JvmtiCodeBlobEvents::generate_compiled_method_load_events(JvmtiEnv* e // Save events to the queue for posting outside the CodeCache_lock. MutexLocker mu(java_thread, CodeCache_lock, Mutex::_no_safepoint_check_flag); // Iterate over non-profiled and profiled nmethods - NMethodIterator iter(NMethodIterator::only_not_unloading); + NMethodIterator iter(NMethodIterator::not_unloading); while(iter.next()) { nmethod* current = iter.method(); current->post_compiled_method_load_event(state); diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index 1ee0ba1715827..9ad77658072f7 100644 --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -769,6 +769,7 @@ class VM_WhiteBoxDeoptimizeFrames : public VM_WhiteBoxOperation { Deoptimization::deoptimize(t, *f); if (_make_not_entrant) { nmethod* nm = CodeCache::find_nmethod(f->pc()); + assert(nm != nullptr, "did not find nmethod"); nm->make_not_entrant(); } ++_result; @@ -819,7 +820,7 @@ WB_ENTRY(jint, WB_DeoptimizeMethod(JNIEnv* env, jobject o, jobject method, jbool if (is_osr) { result += mh->method_holder()->mark_osr_nmethods(&deopt_scope, mh()); } else { - MutexLocker ml(CompiledMethod_lock, Mutex::_no_safepoint_check_flag); + MutexLocker ml(NMethodState_lock, Mutex::_no_safepoint_check_flag); if (mh->code() != nullptr) { deopt_scope.mark(mh->code()); ++result; diff --git a/src/hotspot/share/runtime/deoptimization.cpp b/src/hotspot/share/runtime/deoptimization.cpp index d019decd6d8f7..621b22386bed0 100644 --- a/src/hotspot/share/runtime/deoptimization.cpp +++ b/src/hotspot/share/runtime/deoptimization.cpp @@ -108,7 +108,7 @@ bool DeoptimizationScope::_committing_in_progress = false; DeoptimizationScope::DeoptimizationScope() : _required_gen(0) { DEBUG_ONLY(_deopted = false;) - MutexLocker ml(CompiledMethod_lock, Mutex::_no_safepoint_check_flag); + MutexLocker ml(NMethodState_lock, Mutex::_no_safepoint_check_flag); // If there is nothing to deopt _required_gen is the same as comitted. _required_gen = DeoptimizationScope::_committed_deopt_gen; } @@ -118,7 +118,7 @@ DeoptimizationScope::~DeoptimizationScope() { } void DeoptimizationScope::mark(nmethod* nm, bool inc_recompile_counts) { - ConditionalMutexLocker ml(CompiledMethod_lock, !CompiledMethod_lock->owned_by_self(), Mutex::_no_safepoint_check_flag); + ConditionalMutexLocker ml(NMethodState_lock, !NMethodState_lock->owned_by_self(), Mutex::_no_safepoint_check_flag); // If it's already marked but we still need it to be deopted. if (nm->is_marked_for_deoptimization()) { @@ -139,7 +139,7 @@ void DeoptimizationScope::mark(nmethod* nm, bool inc_recompile_counts) { } void DeoptimizationScope::dependent(nmethod* nm) { - ConditionalMutexLocker ml(CompiledMethod_lock, !CompiledMethod_lock->owned_by_self(), Mutex::_no_safepoint_check_flag); + ConditionalMutexLocker ml(NMethodState_lock, !NMethodState_lock->owned_by_self(), Mutex::_no_safepoint_check_flag); // A method marked by someone else may have a _required_gen lower than what we marked with. // Therefore only store it if it's higher than _required_gen. @@ -170,7 +170,7 @@ void DeoptimizationScope::deoptimize_marked() { bool wait = false; while (true) { { - ConditionalMutexLocker ml(CompiledMethod_lock, !CompiledMethod_lock->owned_by_self(), Mutex::_no_safepoint_check_flag); + ConditionalMutexLocker ml(NMethodState_lock, !NMethodState_lock->owned_by_self(), Mutex::_no_safepoint_check_flag); // First we check if we or someone else already deopted the gen we want. if (DeoptimizationScope::_committed_deopt_gen >= _required_gen) { @@ -198,7 +198,7 @@ void DeoptimizationScope::deoptimize_marked() { Deoptimization::deoptimize_all_marked(); // May safepoint and an additional deopt may have occurred. DEBUG_ONLY(_deopted = true;) { - ConditionalMutexLocker ml(CompiledMethod_lock, !CompiledMethod_lock->owned_by_self(), Mutex::_no_safepoint_check_flag); + ConditionalMutexLocker ml(NMethodState_lock, !NMethodState_lock->owned_by_self(), Mutex::_no_safepoint_check_flag); // Make sure that committed doesn't go backwards. // Should only happen if we did a deopt during a safepoint above. diff --git a/src/hotspot/share/runtime/frame.hpp b/src/hotspot/share/runtime/frame.hpp index 6bf24aec5a216..1ace75de99490 100644 --- a/src/hotspot/share/runtime/frame.hpp +++ b/src/hotspot/share/runtime/frame.hpp @@ -121,6 +121,11 @@ class frame { // is deoptimization. It likely no one else should ever use it. address raw_pc() const; + // Return the original PC for the given PC if: + // (a) the given PC belongs to an nmethod and + // (b) it is a deopt PC + address get_deopt_original_pc() const; + void set_pc(address newpc); intptr_t* sp() const { assert_absolute(); return _sp; } diff --git a/src/hotspot/share/runtime/frame.inline.hpp b/src/hotspot/share/runtime/frame.inline.hpp index 4624c114ec433..aa2de69a7396a 100644 --- a/src/hotspot/share/runtime/frame.inline.hpp +++ b/src/hotspot/share/runtime/frame.inline.hpp @@ -71,6 +71,16 @@ inline bool frame::is_compiled_frame() const { return false; } +inline address frame::get_deopt_original_pc() const { + if (_cb == nullptr) return nullptr; + + nmethod* nm = _cb->as_nmethod_or_null(); + if (nm != nullptr && nm->is_deopt_pc(_pc)) { + return nm->get_original_pc(this); + } + return nullptr; +} + template inline address frame::oopmapreg_to_location(VMReg reg, const RegisterMapT* reg_map) const { if (reg->is_reg()) { diff --git a/src/hotspot/share/runtime/javaThread.cpp b/src/hotspot/share/runtime/javaThread.cpp index 723aadedc29c9..d77faa687989d 100644 --- a/src/hotspot/share/runtime/javaThread.cpp +++ b/src/hotspot/share/runtime/javaThread.cpp @@ -1290,8 +1290,8 @@ void JavaThread::deoptimize() { // Deoptimize only at particular bcis. DeoptimizeOnlyAt // consists of comma or carriage return separated numbers so // search for the current bci in that string. - address pc = fst.current()->pc(); - nmethod* nm = (nmethod*) fst.current()->cb(); + address pc = fst.current()->pc(); + nmethod* nm = fst.current()->cb()->as_nmethod(); ScopeDesc* sd = nm->scope_desc_at(pc); char buffer[8]; jio_snprintf(buffer, sizeof(buffer), "%d", sd->bci()); @@ -1333,6 +1333,7 @@ void JavaThread::make_zombies() { if (fst.current()->can_be_deoptimized()) { // it is a Java nmethod nmethod* nm = CodeCache::find_nmethod(fst.current()->pc()); + assert(nm != nullptr, "did not find nmethod"); nm->make_not_entrant(); } } diff --git a/src/hotspot/share/runtime/mutexLocker.cpp b/src/hotspot/share/runtime/mutexLocker.cpp index 1bf821fa5f694..d945037324ee5 100644 --- a/src/hotspot/share/runtime/mutexLocker.cpp +++ b/src/hotspot/share/runtime/mutexLocker.cpp @@ -37,7 +37,7 @@ // Mutexes used in the VM (see comment in mutexLocker.hpp): Mutex* Patching_lock = nullptr; -Mutex* CompiledMethod_lock = nullptr; +Mutex* NMethodState_lock = nullptr; Monitor* SystemDictionary_lock = nullptr; Mutex* InvokeMethodTypeTable_lock = nullptr; Monitor* InvokeMethodIntrinsicTable_lock = nullptr; @@ -327,7 +327,7 @@ void mutex_init() { MUTEX_DEFL(VtableStubs_lock , PaddedMutex , CompiledIC_lock); // Also holds DumpTimeTable_lock MUTEX_DEFL(CodeCache_lock , PaddedMonitor, VtableStubs_lock); MUTEX_DEFL(DirectivesStack_lock , PaddedMutex , CodeCache_lock); - MUTEX_DEFL(CompiledMethod_lock , PaddedMutex , CodeCache_lock); + MUTEX_DEFL(NMethodState_lock , PaddedMutex , CodeCache_lock); MUTEX_DEFL(Threads_lock , PaddedMonitor, CompileThread_lock, true); MUTEX_DEFL(Compile_lock , PaddedMutex , MethodCompileQueue_lock); diff --git a/src/hotspot/share/runtime/mutexLocker.hpp b/src/hotspot/share/runtime/mutexLocker.hpp index 7729189e18aa3..8b71a097812ea 100644 --- a/src/hotspot/share/runtime/mutexLocker.hpp +++ b/src/hotspot/share/runtime/mutexLocker.hpp @@ -32,7 +32,7 @@ // Mutexes used in the VM. extern Mutex* Patching_lock; // a lock used to guard code patching of compiled code -extern Mutex* CompiledMethod_lock; // a lock used to guard a compiled method and OSR queues +extern Mutex* NMethodState_lock; // a lock used to guard a compiled method state extern Monitor* SystemDictionary_lock; // a lock on the system dictionary extern Mutex* InvokeMethodTypeTable_lock; extern Monitor* InvokeMethodIntrinsicTable_lock; diff --git a/src/hotspot/share/runtime/sharedRuntime.cpp b/src/hotspot/share/runtime/sharedRuntime.cpp index 248d840f01f63..a4ee1a3173461 100644 --- a/src/hotspot/share/runtime/sharedRuntime.cpp +++ b/src/hotspot/share/runtime/sharedRuntime.cpp @@ -1638,6 +1638,7 @@ methodHandle SharedRuntime::reresolve_call_site(TRAPS) { address pc = caller.pc(); nmethod* caller_nm = CodeCache::find_nmethod(pc); + assert(caller_nm != nullptr, "did not find caller nmethod"); // Default call_addr is the location of the "basic" call. // Determine the address of the call we a reresolving. With @@ -2780,7 +2781,7 @@ void AdapterHandlerLibrary::create_native_wrapper(const methodHandle& method) { if (nm != nullptr) { { - MutexLocker pl(CompiledMethod_lock, Mutex::_no_safepoint_check_flag); + MutexLocker pl(NMethodState_lock, Mutex::_no_safepoint_check_flag); if (nm->make_in_use()) { method->set_code(method, nm); }