Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/hotspot/share/ci/ciEnv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ void ciEnv::register_method(ciMethod* target,
task()->comp_level(), method_name);
}
// Allow the code to be executed
MutexLocker ml(NMethod_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);
}
Expand All @@ -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(NMethod_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);
}
Expand Down
24 changes: 12 additions & 12 deletions src/hotspot/share/code/codeCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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());
Expand All @@ -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());
Expand Down Expand Up @@ -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()) {
Expand All @@ -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)) {
Expand All @@ -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()) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/code/codeCache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,13 @@ class CodeCache : AllStatic {
// The relaxed iterators only hold the CodeCache_lock across next calls
template <class T, class Filter, bool is_relaxed> class CodeBlobIterator : public StackObj {
public:
enum LivenessFilter { all, only_not_unloading };
enum LivenessFilter { all, not_unloading };

private:
CodeBlob* _code_blob; // Current CodeBlob
GrowableArrayIterator<CodeHeap*> _heap;
GrowableArrayIterator<CodeHeap*> _end;
bool _only_not_unloading;
bool _not_unloading; // Those nmethods that are not unloading

void initialize_iteration(T* nm) {
}
Expand All @@ -360,7 +360,7 @@ template <class T, class Filter, bool is_relaxed> 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;
Expand All @@ -373,7 +373,7 @@ template <class T, class Filter, bool is_relaxed> 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
Expand Down
3 changes: 3 additions & 0 deletions src/hotspot/share/code/compiledIC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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();
}
Expand Down
12 changes: 6 additions & 6 deletions src/hotspot/share/code/nmethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ const char* nmethod::state() const {
}

void nmethod::set_deoptimized_done() {
ConditionalMutexLocker ml(NMethod_lock, !NMethod_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);
}
Expand Down Expand Up @@ -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(NMethod_lock);
assert_lock_strong(NMethodState_lock);
signed char old_state = _state;
if (old_state >= new_state) {
// Ensure monotonicity of transitions.
Expand Down Expand Up @@ -1931,7 +1931,7 @@ bool nmethod::make_not_entrant() {

{
// Enter critical section. Does not block for safepoint.
ConditionalMutexLocker ml(NMethod_lock, !NMethod_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
Expand Down Expand Up @@ -1974,7 +1974,7 @@ bool nmethod::make_not_entrant() {
// Remove nmethod from method.
unlink_from_method();

} // leave critical region under NMethod_lock
} // leave critical region under NMethodState_lock

#if INCLUDE_JVMCI
// Invalidate can't occur while holding the Patching lock
Expand Down Expand Up @@ -2004,7 +2004,7 @@ void nmethod::unlink() {

flush_dependencies();

// unlink_from_method will take the NMethod_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.
Expand Down Expand Up @@ -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++) {
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/code/nmethod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 NMethod_lock
// Protected by NMethodState_lock
volatile signed char _state; // {not_installed, in_use, not_entrant}

// set during construction
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/gc/z/zNMethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions src/hotspot/share/jvmci/jvmciRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(NMethod_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 {
Expand All @@ -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(NMethod_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 {
Expand All @@ -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(NMethod_lock, Mutex::_no_safepoint_check_flag);
MutexLocker ml(NMethodState_lock, Mutex::_no_safepoint_check_flag);
if (!nm->make_in_use()) {
result = JVMCI::nmethod_reclaimed;
}
Expand Down
8 changes: 4 additions & 4 deletions src/hotspot/share/oops/instanceKlass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(NMethod_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),
Expand All @@ -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(NMethod_lock, !NMethod_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();
Expand Down Expand Up @@ -3421,7 +3421,7 @@ bool InstanceKlass::remove_osr_nmethod(nmethod* n) {
}

int InstanceKlass::mark_osr_nmethods(DeoptimizationScope* deopt_scope, const Method* m) {
ConditionalMutexLocker ml(NMethod_lock, !NMethod_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) {
Expand All @@ -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(NMethod_lock, !NMethod_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) {
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/oops/method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ void Method::clear_code() {
}

void Method::unlink_code(nmethod *compare) {
ConditionalMutexLocker ml(NMethod_lock, !NMethod_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.
Expand All @@ -1171,7 +1171,7 @@ void Method::unlink_code(nmethod *compare) {
}

void Method::unlink_code() {
ConditionalMutexLocker ml(NMethod_lock, !NMethod_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();
}

Expand Down Expand Up @@ -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(NMethod_lock);
assert_lock_strong(NMethodState_lock);
assert( code, "use clear_code to remove code" );
assert( mh->check_code(), "" );

Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/oops/method.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,13 @@ class Method : public Metadata {
bool check_code() const; // Not inline to avoid circular ref
nmethod* code() const;

// Locks NMethod_lock if not held.
// Locks NMethodState_lock if not held.
void unlink_code(nmethod *compare);
// Locks NMethod_lock if not held.
// Locks NMethodState_lock if not held.
void unlink_code();

private:
// Either called with NMethod_lock held or from constructor.
// Either called with NMethodState_lock held or from constructor.
void clear_code();

void clear_method_data() {
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/prims/jvmtiCodeBlobEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/hotspot/share/prims/whitebox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(NMethod_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;
Expand Down
Loading