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
8 changes: 4 additions & 4 deletions src/hotspot/share/c1/c1_Runtime1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ JRT_ENTRY(void, Runtime1::deoptimize(JavaThread* current, jint trap_request))
Deoptimization::DeoptReason reason = Deoptimization::trap_request_reason(trap_request);

if (action == Deoptimization::Action_make_not_entrant) {
if (nm->make_not_entrant(nmethod::C1_deoptimize)) {
if (nm->make_not_entrant(nmethod::NMethodChangeReason::C1_deoptimize)) {
if (reason == Deoptimization::Reason_tenured) {
MethodData* trap_mdo = Deoptimization::get_method_data(current, method, true /*create_if_missing*/);
if (trap_mdo != nullptr) {
Expand Down Expand Up @@ -1092,7 +1092,7 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* current, C1StubId stub_id ))
// safepoint, but if it's still alive then make it not_entrant.
nmethod* nm = CodeCache::find_nmethod(caller_frame.pc());
if (nm != nullptr) {
nm->make_not_entrant(nmethod::C1_codepatch);
nm->make_not_entrant(nmethod::NMethodChangeReason::C1_codepatch);
}

Deoptimization::deoptimize_frame(current, caller_frame.id());
Expand Down Expand Up @@ -1340,7 +1340,7 @@ void Runtime1::patch_code(JavaThread* current, C1StubId stub_id) {
// Make sure the nmethod is invalidated, i.e. made not entrant.
nmethod* nm = CodeCache::find_nmethod(caller_frame.pc());
if (nm != nullptr) {
nm->make_not_entrant(nmethod::C1_deoptimize_for_patching);
nm->make_not_entrant(nmethod::NMethodChangeReason::C1_deoptimize_for_patching);
}
}

Expand Down Expand Up @@ -1468,7 +1468,7 @@ JRT_ENTRY(void, Runtime1::predicate_failed_trap(JavaThread* current))

nmethod* nm = CodeCache::find_nmethod(caller_frame.pc());
assert (nm != nullptr, "no more nmethod?");
nm->make_not_entrant(nmethod::C1_predicate_failed_trap);
nm->make_not_entrant(nmethod::NMethodChangeReason::C1_predicate_failed_trap);

methodHandle m(current, nm->method());
MethodData* mdo = m->method_data();
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/ci/ciReplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ class CompileReplay : public StackObj {
// Make sure the existence of a prior compile doesn't stop this one
nmethod* nm = (entry_bci != InvocationEntryBci) ? method->lookup_osr_nmethod_for(entry_bci, comp_level, true) : method->code();
if (nm != nullptr) {
nm->make_not_entrant(nmethod::CI_replay);
nm->make_not_entrant(nmethod::NMethodChangeReason::CI_replay);
}
replay_state = this;
CompileBroker::compile_method(methodHandle(THREAD, method), entry_bci, comp_level,
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/code/codeCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,7 @@ void CodeCache::make_marked_nmethods_deoptimized() {
while(iter.next()) {
nmethod* nm = iter.method();
if (nm->is_marked_for_deoptimization() && !nm->has_been_deoptimized() && nm->can_be_deoptimized()) {
nm->make_not_entrant(nmethod::marked_for_deoptimization);
nm->make_not_entrant(nmethod::NMethodChangeReason::marked_for_deoptimization);
nm->make_deoptimized();
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/code/nmethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1968,8 +1968,8 @@ void nmethod::log_state_change(NMethodChangeReason reason) const {
if (LogCompilation) {
if (xtty != nullptr) {
ttyLocker ttyl; // keep the following output all in one block
xtty->begin_elem("make_not_entrant thread='%zu' reason='%d'",
os::current_thread_id(), reason);
xtty->begin_elem("make_not_entrant thread='%zu' reason='%s'",
os::current_thread_id(), NMethodChangeReason_to_string(reason));
log_identity(xtty);
xtty->stamp();
xtty->end_elem();
Expand All @@ -1978,7 +1978,7 @@ void nmethod::log_state_change(NMethodChangeReason reason) const {

ResourceMark rm;
stringStream ss(NEW_RESOURCE_ARRAY(char, 256), 256);
ss.print("made not entrant: %d", reason);
ss.print("made not entrant: %s", NMethodChangeReason_to_string(reason));

CompileTask::print_ul(this, ss.freeze());
if (PrintCompilation) {
Expand Down
65 changes: 58 additions & 7 deletions src/hotspot/share/code/nmethod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,8 @@ class nmethod : public CodeBlob {
void oops_do_set_strong_done(nmethod* old_head);

public:
enum NMethodChangeReason : s4 {
C1_deoptimize = 0,
enum class NMethodChangeReason : u1 {
C1_deoptimize,
C1_codepatch,
C1_predicate_failed_trap,
C1_deoptimize_for_patching,
Expand All @@ -479,21 +479,72 @@ class nmethod : public CodeBlob {
not_used,
OSR_invalidation_for_compiling_with_C1,
OSR_invalidation_back_branch,
JVMCI_reprofile,
JVMCI_materialize_virtual_object,
JVMCI_invalidate_nmethod_mirror,
JVMCI_register_method,
OSR_invalidation_of_lower_level,
set_native_function,
whitebox_deoptimization,
missing_exception_handler,
uncommon_trap,
zombie,
JVMCI_reprofile,
JVMCI_materialize_virtual_object,
JVMCI_invalidate_nmethod_mirror,
JVMCI_register_method,
JVMCI_invalidate_nmethod,
JVMCI_new_installation,
JVMCI_replacing_with_new_code,
};


static const char* NMethodChangeReason_to_string(NMethodChangeReason reason) {
if (reason == nmethod::NMethodChangeReason::C1_deoptimize) {
return "C1 deoptimized";
} else if (reason == nmethod::NMethodChangeReason::C1_codepatch) {
return "C1 code patch";
} else if (reason == nmethod::NMethodChangeReason::C1_predicate_failed_trap) {
return "C1 predicate failed trap";
} else if (reason == nmethod::NMethodChangeReason::C1_deoptimize_for_patching) {
return "C1 deoptimize for patching";
} else if (reason == nmethod::NMethodChangeReason::CI_replay) {
return "CI replay";
} else if (reason == nmethod::NMethodChangeReason::marked_for_deoptimization) {
return "marked for deoptimization";
} else if (reason == nmethod::NMethodChangeReason::not_used) {
return "not used";
} else if (reason == nmethod::NMethodChangeReason::OSR_invalidation_for_compiling_with_C1) {
return "OSR invalidation for compiling with C1";
} else if (reason == nmethod::NMethodChangeReason::OSR_invalidation_back_branch) {
return "OSR invalidation back branch";
} else if (reason == nmethod::NMethodChangeReason::JVMCI_reprofile) {
return "JVMCI reprofile";
} else if (reason == nmethod::NMethodChangeReason::JVMCI_materialize_virtual_object) {
return "JVMCI materialize virtual object";
} else if (reason == nmethod::NMethodChangeReason::JVMCI_invalidate_nmethod_mirror) {
return "JVMCI invalidate nmethod mirror";
} else if (reason == nmethod::NMethodChangeReason::JVMCI_register_method) {
return "JVMCI register method";
} else if (reason == nmethod::NMethodChangeReason::OSR_invalidation_of_lower_level) {
return "OSR invalidation of lower level";
} else if (reason == nmethod::NMethodChangeReason::set_native_function) {
return "set native function";
} else if (reason == nmethod::NMethodChangeReason::whitebox_deoptimization) {
return "whitebox deoptimization";
} else if (reason == nmethod::NMethodChangeReason::missing_exception_handler) {
return "missing exception handler";
} else if (reason == nmethod::NMethodChangeReason::uncommon_trap) {
return "uncommon trap";
} else if (reason == nmethod::NMethodChangeReason::JVMCI_invalidate_nmethod) {
return "JVMCI invalidate nmethod";
} else if (reason == nmethod::NMethodChangeReason::zombie) {
return "zombie";
} else if (reason == nmethod::NMethodChangeReason::JVMCI_new_installation) {
return "JVMCI new installation";
} else if (reason == nmethod::NMethodChangeReason::JVMCI_replacing_with_new_code) {
return "JVMCI replacing with new code";
} else {
return "Unknown";
}
}

// create nmethod with entry_bci
static nmethod* new_nmethod(const methodHandle& method,
int compile_id,
Expand Down Expand Up @@ -657,7 +708,7 @@ class nmethod : public CodeBlob {
// if this thread changed the state of the nmethod or false if
// another thread performed the transition.
bool make_not_entrant(NMethodChangeReason reason);
bool make_not_used() { return make_not_entrant(nmethod::not_used); }
bool make_not_used() { return make_not_entrant(NMethodChangeReason::not_used); }

bool is_marked_for_deoptimization() const { return deoptimization_status() != not_marked; }
bool has_been_deoptimized() const { return deoptimization_status() == deoptimize_done; }
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/compiler/compilationPolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ void CompilationPolicy::compile(const methodHandle& mh, int bci, CompLevel level
nmethod* osr_nm = mh->lookup_osr_nmethod_for(bci, CompLevel_simple, false);
if (osr_nm != nullptr && osr_nm->comp_level() > CompLevel_simple) {
// Invalidate the existing OSR nmethod so that a compile at CompLevel_simple is permitted.
osr_nm->make_not_entrant(nmethod::OSR_invalidation_for_compiling_with_C1);
osr_nm->make_not_entrant(nmethod::NMethodChangeReason::OSR_invalidation_for_compiling_with_C1);
}
compile(mh, bci, CompLevel_simple, THREAD);
}
Expand Down Expand Up @@ -1201,7 +1201,7 @@ void CompilationPolicy::method_back_branch_event(const methodHandle& mh, const m
int osr_bci = nm->is_osr_method() ? nm->osr_entry_bci() : InvocationEntryBci;
print_event(MAKE_NOT_ENTRANT, mh(), mh(), osr_bci, level);
}
nm->make_not_entrant(nmethod::OSR_invalidation_back_branch);
nm->make_not_entrant(nmethod::NMethodChangeReason::OSR_invalidation_back_branch);
}
}
// Fix up next_level if necessary to avoid deopts
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/share/jvmci/jvmciCompilerToVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,7 @@ C2V_VMENTRY_0(jint, installCode0, (JNIEnv *env, jobject,
assert(JVMCIENV->isa_HotSpotNmethod(installed_code_handle), "wrong type");
// Clear the link to an old nmethod first
JVMCIObject nmethod_mirror = installed_code_handle;
JVMCIENV->invalidate_nmethod_mirror(nmethod_mirror, true, nmethod::JVMCI_replacing_with_new_code, JVMCI_CHECK_0);
JVMCIENV->invalidate_nmethod_mirror(nmethod_mirror, true, nmethod::NMethodChangeReason::JVMCI_replacing_with_new_code, JVMCI_CHECK_0);
} else {
assert(JVMCIENV->isa_InstalledCode(installed_code_handle), "wrong type");
}
Expand Down Expand Up @@ -1370,7 +1370,7 @@ C2V_VMENTRY(void, reprofile, (JNIEnv* env, jobject, ARGUMENT_PAIR(method)))

nmethod* code = method->code();
if (code != nullptr) {
code->make_not_entrant(nmethod::JVMCI_reprofile);
code->make_not_entrant(nmethod::NMethodChangeReason::JVMCI_reprofile);
}

MethodData* method_data = method->method_data();
Expand Down Expand Up @@ -1810,7 +1810,7 @@ C2V_VMENTRY(void, materializeVirtualObjects, (JNIEnv* env, jobject, jobject _hs_
if (!fst.current()->is_compiled_frame()) {
JVMCI_THROW_MSG(IllegalStateException, "compiled stack frame expected");
}
fst.current()->cb()->as_nmethod()->make_not_entrant(nmethod::JVMCI_materialize_virtual_object);
fst.current()->cb()->as_nmethod()->make_not_entrant(nmethod::NMethodChangeReason::JVMCI_materialize_virtual_object);
}
Deoptimization::deoptimize(thread, *fst.current(), Deoptimization::Reason_none);
// look for the frame again as it has been updated by deopt (pc, deopt state...)
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/jvmci/jvmciRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2196,7 +2196,7 @@ JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV,
tty->print_cr("Replacing method %s", method_name);
}
if (old != nullptr) {
old->make_not_entrant(nmethod::JVMCI_register_method);
old->make_not_entrant(nmethod::NMethodChangeReason::JVMCI_register_method);
}

LogTarget(Info, nmethod, install) lt;
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/oops/instanceKlass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3494,7 +3494,7 @@ void InstanceKlass::add_osr_nmethod(nmethod* n) {
for (int l = CompLevel_limited_profile; l < n->comp_level(); l++) {
nmethod *inv = lookup_osr_nmethod(n->method(), n->osr_entry_bci(), l, true);
if (inv != nullptr && inv->is_in_use()) {
inv->make_not_entrant(nmethod::OSR_invalidation_of_lower_level);
inv->make_not_entrant(nmethod::NMethodChangeReason::OSR_invalidation_of_lower_level);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/oops/method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ void Method::set_native_function(address function, bool post_event_flag) {
// If so, we have to make it not_entrant.
nmethod* nm = code(); // Put it into local variable to guard against concurrent updates
if (nm != nullptr) {
nm->make_not_entrant(nmethod::set_native_function);
nm->make_not_entrant(nmethod::NMethodChangeReason::set_native_function);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/prims/whitebox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ class VM_WhiteBoxDeoptimizeFrames : public VM_WhiteBoxOperation {
if (_make_not_entrant) {
nmethod* nm = CodeCache::find_nmethod(f->pc());
assert(nm != nullptr, "did not find nmethod");
nm->make_not_entrant(nmethod::whitebox_deoptimization);
nm->make_not_entrant(nmethod::NMethodChangeReason::whitebox_deoptimization);
}
++_result;
}
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/runtime/deoptimization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1813,7 +1813,7 @@ void Deoptimization::deoptimize(JavaThread* thread, frame fr, DeoptReason reason
#if INCLUDE_JVMCI
address Deoptimization::deoptimize_for_missing_exception_handler(nmethod* nm) {
// there is no exception handler for this pc => deoptimize
nm->make_not_entrant(nmethod::missing_exception_handler);
nm->make_not_entrant(nmethod::NMethodChangeReason::missing_exception_handler);

// Use Deoptimization::deoptimize for all of its side-effects:
// gathering traps statistics, logging...
Expand Down Expand Up @@ -2442,7 +2442,7 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* current, jint tr

// Recompile
if (make_not_entrant) {
if (!nm->make_not_entrant(nmethod::uncommon_trap)) {
if (!nm->make_not_entrant(nmethod::NMethodChangeReason::uncommon_trap)) {
return; // the call did not change nmethod's state
}

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/runtime/javaThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ void JavaThread::make_zombies() {
// it is a Java nmethod
nmethod* nm = CodeCache::find_nmethod(fst.current()->pc());
assert(nm != nullptr, "did not find nmethod");
nm->make_not_entrant(nmethod::zombie);
nm->make_not_entrant(nmethod::NMethodChangeReason::zombie);
}
}
}
Expand Down