Rename 'reasons' enum. Adjust default value for invalidationReason.

This commit is contained in:
JohnTortugo 2025-06-12 19:37:10 +00:00
parent 1f3c2598ae
commit 831ba2f02e
22 changed files with 119 additions and 120 deletions

View File

@ -818,7 +818,7 @@ JRT_ENTRY(void, Runtime1::deoptimize(JavaThread* current, jint trap_request))
Deoptimization::DeoptReason reason = Deoptimization::trap_request_reason(trap_request); Deoptimization::DeoptReason reason = Deoptimization::trap_request_reason(trap_request);
if (action == Deoptimization::Action_make_not_entrant) { if (action == Deoptimization::Action_make_not_entrant) {
if (nm->make_not_entrant(nmethod::ChangeReason::C1_deoptimize)) { if (nm->make_not_entrant(nmethod::InvalidationReason::C1_DEOPTIMIZE)) {
if (reason == Deoptimization::Reason_tenured) { if (reason == Deoptimization::Reason_tenured) {
MethodData* trap_mdo = Deoptimization::get_method_data(current, method, true /*create_if_missing*/); MethodData* trap_mdo = Deoptimization::get_method_data(current, method, true /*create_if_missing*/);
if (trap_mdo != nullptr) { if (trap_mdo != nullptr) {
@ -1110,7 +1110,7 @@ JRT_ENTRY(void, Runtime1::patch_code(JavaThread* current, C1StubId stub_id ))
// safepoint, but if it's still alive then make it not_entrant. // safepoint, but if it's still alive then make it not_entrant.
nmethod* nm = CodeCache::find_nmethod(caller_frame.pc()); nmethod* nm = CodeCache::find_nmethod(caller_frame.pc());
if (nm != nullptr) { if (nm != nullptr) {
nm->make_not_entrant(nmethod::ChangeReason::C1_codepatch); nm->make_not_entrant(nmethod::InvalidationReason::C1_CODEPATCH);
} }
Deoptimization::deoptimize_frame(current, caller_frame.id()); Deoptimization::deoptimize_frame(current, caller_frame.id());
@ -1358,7 +1358,7 @@ void Runtime1::patch_code(JavaThread* current, C1StubId stub_id) {
// Make sure the nmethod is invalidated, i.e. made not entrant. // Make sure the nmethod is invalidated, i.e. made not entrant.
nmethod* nm = CodeCache::find_nmethod(caller_frame.pc()); nmethod* nm = CodeCache::find_nmethod(caller_frame.pc());
if (nm != nullptr) { if (nm != nullptr) {
nm->make_not_entrant(nmethod::ChangeReason::C1_deoptimize_for_patching); nm->make_not_entrant(nmethod::InvalidationReason::C1_DEOPTIMIZE_FOR_PATCHING);
} }
} }
@ -1486,7 +1486,7 @@ JRT_ENTRY(void, Runtime1::predicate_failed_trap(JavaThread* current))
nmethod* nm = CodeCache::find_nmethod(caller_frame.pc()); nmethod* nm = CodeCache::find_nmethod(caller_frame.pc());
assert (nm != nullptr, "no more nmethod?"); assert (nm != nullptr, "no more nmethod?");
nm->make_not_entrant(nmethod::ChangeReason::C1_predicate_failed_trap); nm->make_not_entrant(nmethod::InvalidationReason::C1_PREDICATE_FAILED_TRAP);
methodHandle m(current, nm->method()); methodHandle m(current, nm->method());
MethodData* mdo = m->method_data(); MethodData* mdo = m->method_data();

View File

@ -802,7 +802,7 @@ class CompileReplay : public StackObj {
// Make sure the existence of a prior compile doesn't stop this one // 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(); nmethod* nm = (entry_bci != InvocationEntryBci) ? method->lookup_osr_nmethod_for(entry_bci, comp_level, true) : method->code();
if (nm != nullptr) { if (nm != nullptr) {
nm->make_not_entrant(nmethod::ChangeReason::CI_replay); nm->make_not_entrant(nmethod::InvalidationReason::CI_REPLAY);
} }
replay_state = this; replay_state = this;
CompileBroker::compile_method(methodHandle(THREAD, method), entry_bci, comp_level, CompileBroker::compile_method(methodHandle(THREAD, method), entry_bci, comp_level,

View File

@ -1361,7 +1361,7 @@ void CodeCache::make_marked_nmethods_deoptimized() {
while(iter.next()) { while(iter.next()) {
nmethod* nm = iter.method(); nmethod* nm = iter.method();
if (nm->is_marked_for_deoptimization() && !nm->has_been_deoptimized() && nm->can_be_deoptimized()) { if (nm->is_marked_for_deoptimization() && !nm->has_been_deoptimized() && nm->can_be_deoptimized()) {
nm->make_not_entrant(nmethod::ChangeReason::marked_for_deoptimization); nm->make_not_entrant(nmethod::InvalidationReason::MARKED_FOR_DEOPTIMIZATION);
nm->make_deoptimized(); nm->make_deoptimized();
} }
} }

View File

@ -1975,12 +1975,12 @@ void nmethod::invalidate_osr_method() {
} }
} }
void nmethod::log_state_change(ChangeReason change_reason) const { void nmethod::log_state_change(InvalidationReason invalidation_reason) const {
if (LogCompilation) { if (LogCompilation) {
if (xtty != nullptr) { if (xtty != nullptr) {
ttyLocker ttyl; // keep the following output all in one block ttyLocker ttyl; // keep the following output all in one block
xtty->begin_elem("make_not_entrant thread='%zu' reason='%s'", xtty->begin_elem("make_not_entrant thread='%zu' reason='%s'",
os::current_thread_id(), change_reason_to_string(change_reason)); os::current_thread_id(), invalidation_reason_to_string(invalidation_reason));
log_identity(xtty); log_identity(xtty);
xtty->stamp(); xtty->stamp();
xtty->end_elem(); xtty->end_elem();
@ -1989,7 +1989,7 @@ void nmethod::log_state_change(ChangeReason change_reason) const {
ResourceMark rm; ResourceMark rm;
stringStream ss(NEW_RESOURCE_ARRAY(char, 256), 256); stringStream ss(NEW_RESOURCE_ARRAY(char, 256), 256);
ss.print("made not entrant: %s", change_reason_to_string(change_reason)); ss.print("made not entrant: %s", invalidation_reason_to_string(invalidation_reason));
CompileTask::print_ul(this, ss.freeze()); CompileTask::print_ul(this, ss.freeze());
if (PrintCompilation) { if (PrintCompilation) {
@ -2004,7 +2004,7 @@ void nmethod::unlink_from_method() {
} }
// Invalidate code // Invalidate code
bool nmethod::make_not_entrant(ChangeReason change_reason) { bool nmethod::make_not_entrant(InvalidationReason invalidation_reason) {
// This can be called while the system is already at a safepoint which is ok // This can be called while the system is already at a safepoint which is ok
NoSafepointVerifier nsv; NoSafepointVerifier nsv;
@ -2073,7 +2073,7 @@ bool nmethod::make_not_entrant(ChangeReason change_reason) {
assert(success, "Transition can't fail"); assert(success, "Transition can't fail");
// Log the transition once // Log the transition once
log_state_change(change_reason); log_state_change(invalidation_reason);
// Remove nmethod from method. // Remove nmethod from method.
unlink_from_method(); unlink_from_method();
@ -2084,7 +2084,7 @@ bool nmethod::make_not_entrant(ChangeReason change_reason) {
// Invalidate can't occur while holding the NMethodState_lock // Invalidate can't occur while holding the NMethodState_lock
JVMCINMethodData* nmethod_data = jvmci_nmethod_data(); JVMCINMethodData* nmethod_data = jvmci_nmethod_data();
if (nmethod_data != nullptr) { if (nmethod_data != nullptr) {
nmethod_data->invalidate_nmethod_mirror(this, change_reason); nmethod_data->invalidate_nmethod_mirror(this, invalidation_reason);
} }
#endif #endif
@ -2122,7 +2122,7 @@ void nmethod::unlink() {
// Clear the link between this nmethod and a HotSpotNmethod mirror // Clear the link between this nmethod and a HotSpotNmethod mirror
JVMCINMethodData* nmethod_data = jvmci_nmethod_data(); JVMCINMethodData* nmethod_data = jvmci_nmethod_data();
if (nmethod_data != nullptr) { if (nmethod_data != nullptr) {
nmethod_data->invalidate_nmethod_mirror(this, is_cold() ? nmethod::ChangeReason::GC_unlinking_cold : nmethod::ChangeReason::GC_unlinking); nmethod_data->invalidate_nmethod_mirror(this, is_cold() ? nmethod::InvalidationReason::GC_UNLINKING_COLD : nmethod::InvalidationReason::GC_UNLINKING);
} }
#endif #endif

View File

@ -473,71 +473,71 @@ class nmethod : public CodeBlob {
public: public:
// If you change anything in this enum please patch // If you change anything in this enum please patch
// vmStructs_jvmci.cpp accordingly. // vmStructs_jvmci.cpp accordingly.
enum class ChangeReason : u1 { enum class InvalidationReason : u1 {
unknown, UNKNOWN,
C1_codepatch, C1_CODEPATCH,
C1_deoptimize, C1_DEOPTIMIZE,
C1_deoptimize_for_patching, C1_DEOPTIMIZE_FOR_PATCHING,
C1_predicate_failed_trap, C1_PREDICATE_FAILED_TRAP,
CI_replay, CI_REPLAY,
GC_unlinking, GC_UNLINKING,
GC_unlinking_cold, GC_UNLINKING_COLD,
JVMCI_invalidate_nmethod, JVMCI_INVALIDATE,
JVMCI_materialize_virtual_object, JVMCI_MATERIALIZE_VIRTUAL_OBJECT,
JVMCI_replaced_with_new_code, JVMCI_REPLACED_WITH_NEW_CODE,
JVMCI_reprofile, JVMCI_REPROFILE,
marked_for_deoptimization, MARKED_FOR_DEOPTIMIZATION,
missing_exception_handler, MISSING_EXCEPTION_HANDLER,
not_used, NOT_USED,
OSR_invalidation_back_branch, OSR_INVALIDATION_BACK_BRANCH,
OSR_invalidation_for_compiling_with_C1, OSR_INVALIDATION_FOR_COMPILING_WITH_C1,
OSR_invalidation_of_lower_level, OSR_INVALIDATION_OF_LOWER_LEVEL,
set_native_function, SET_NATIVE_FUNCTION,
uncommon_trap, UNCOMMON_TRAP,
whitebox_deoptimization, WHITEBOX_DEOPTIMIZATION,
zombie, ZOMBIE,
}; };
static const char* change_reason_to_string(ChangeReason change_reason) { static const char* invalidation_reason_to_string(InvalidationReason invalidation_reason) {
switch (change_reason) { switch (invalidation_reason) {
case ChangeReason::C1_codepatch: case InvalidationReason::C1_CODEPATCH:
return "C1 code patch"; return "C1 code patch";
case ChangeReason::C1_deoptimize: case InvalidationReason::C1_DEOPTIMIZE:
return "C1 deoptimized"; return "C1 deoptimized";
case ChangeReason::C1_deoptimize_for_patching: case InvalidationReason::C1_DEOPTIMIZE_FOR_PATCHING:
return "C1 deoptimize for patching"; return "C1 deoptimize for patching";
case ChangeReason::C1_predicate_failed_trap: case InvalidationReason::C1_PREDICATE_FAILED_TRAP:
return "C1 predicate failed trap"; return "C1 predicate failed trap";
case ChangeReason::CI_replay: case InvalidationReason::CI_REPLAY:
return "CI replay"; return "CI replay";
case ChangeReason::JVMCI_invalidate_nmethod: case InvalidationReason::JVMCI_INVALIDATE:
return "JVMCI invalidate nmethod"; return "JVMCI invalidate";
case ChangeReason::JVMCI_materialize_virtual_object: case InvalidationReason::JVMCI_MATERIALIZE_VIRTUAL_OBJECT:
return "JVMCI materialize virtual object"; return "JVMCI materialize virtual object";
case ChangeReason::JVMCI_replaced_with_new_code: case InvalidationReason::JVMCI_REPLACED_WITH_NEW_CODE:
return "JVMCI replaced with new code"; return "JVMCI replaced with new code";
case ChangeReason::JVMCI_reprofile: case InvalidationReason::JVMCI_REPROFILE:
return "JVMCI reprofile"; return "JVMCI reprofile";
case ChangeReason::marked_for_deoptimization: case InvalidationReason::MARKED_FOR_DEOPTIMIZATION:
return "marked for deoptimization"; return "marked for deoptimization";
case ChangeReason::missing_exception_handler: case InvalidationReason::MISSING_EXCEPTION_HANDLER:
return "missing exception handler"; return "missing exception handler";
case ChangeReason::not_used: case InvalidationReason::NOT_USED:
return "not used"; return "not used";
case ChangeReason::OSR_invalidation_back_branch: case InvalidationReason::OSR_INVALIDATION_BACK_BRANCH:
return "OSR invalidation back branch"; return "OSR invalidation back branch";
case ChangeReason::OSR_invalidation_for_compiling_with_C1: case InvalidationReason::OSR_INVALIDATION_FOR_COMPILING_WITH_C1:
return "OSR invalidation for compiling with C1"; return "OSR invalidation for compiling with C1";
case ChangeReason::OSR_invalidation_of_lower_level: case InvalidationReason::OSR_INVALIDATION_OF_LOWER_LEVEL:
return "OSR invalidation of lower level"; return "OSR invalidation of lower level";
case ChangeReason::set_native_function: case InvalidationReason::SET_NATIVE_FUNCTION:
return "set native function"; return "set native function";
case ChangeReason::uncommon_trap: case InvalidationReason::UNCOMMON_TRAP:
return "uncommon trap"; return "uncommon trap";
case ChangeReason::whitebox_deoptimization: case InvalidationReason::WHITEBOX_DEOPTIMIZATION:
return "whitebox deoptimization"; return "whitebox deoptimization";
case ChangeReason::zombie: case InvalidationReason::ZOMBIE:
return "zombie"; return "zombie";
default: { default: {
assert(false, "Unhandled reason"); assert(false, "Unhandled reason");
@ -708,8 +708,8 @@ public:
// alive. It is used when an uncommon trap happens. Returns true // alive. It is used when an uncommon trap happens. Returns true
// if this thread changed the state of the nmethod or false if // if this thread changed the state of the nmethod or false if
// another thread performed the transition. // another thread performed the transition.
bool make_not_entrant(ChangeReason change_reason); bool make_not_entrant(InvalidationReason invalidation_reason);
bool make_not_used() { return make_not_entrant(ChangeReason::not_used); } bool make_not_used() { return make_not_entrant(InvalidationReason::NOT_USED); }
bool is_marked_for_deoptimization() const { return deoptimization_status() != not_marked; } bool is_marked_for_deoptimization() const { return deoptimization_status() != not_marked; }
bool has_been_deoptimized() const { return deoptimization_status() == deoptimize_done; } bool has_been_deoptimized() const { return deoptimization_status() == deoptimize_done; }
@ -1022,7 +1022,7 @@ public:
// Logging // Logging
void log_identity(xmlStream* log) const; void log_identity(xmlStream* log) const;
void log_new_nmethod() const; void log_new_nmethod() const;
void log_state_change(ChangeReason change_reason) const; void log_state_change(InvalidationReason invalidation_reason) const;
// Prints block-level comments, including nmethod specific block labels: // Prints block-level comments, including nmethod specific block labels:
void print_nmethod_labels(outputStream* stream, address block_begin, bool print_section_labels=true) const; void print_nmethod_labels(outputStream* stream, address block_begin, bool print_section_labels=true) const;

View File

@ -924,7 +924,7 @@ void CompilationPolicy::compile(const methodHandle& mh, int bci, CompLevel level
nmethod* osr_nm = mh->lookup_osr_nmethod_for(bci, CompLevel_simple, false); nmethod* osr_nm = mh->lookup_osr_nmethod_for(bci, CompLevel_simple, false);
if (osr_nm != nullptr && osr_nm->comp_level() > CompLevel_simple) { if (osr_nm != nullptr && osr_nm->comp_level() > CompLevel_simple) {
// Invalidate the existing OSR nmethod so that a compile at CompLevel_simple is permitted. // Invalidate the existing OSR nmethod so that a compile at CompLevel_simple is permitted.
osr_nm->make_not_entrant(nmethod::ChangeReason::OSR_invalidation_for_compiling_with_C1); osr_nm->make_not_entrant(nmethod::InvalidationReason::OSR_INVALIDATION_FOR_COMPILING_WITH_C1);
} }
compile(mh, bci, CompLevel_simple, THREAD); compile(mh, bci, CompLevel_simple, THREAD);
} }
@ -1516,7 +1516,7 @@ void CompilationPolicy::method_back_branch_event(const methodHandle& mh, const m
int osr_bci = nm->is_osr_method() ? nm->osr_entry_bci() : InvocationEntryBci; int osr_bci = nm->is_osr_method() ? nm->osr_entry_bci() : InvocationEntryBci;
print_event(MAKE_NOT_ENTRANT, mh(), mh(), osr_bci, level); print_event(MAKE_NOT_ENTRANT, mh(), mh(), osr_bci, level);
} }
nm->make_not_entrant(nmethod::ChangeReason::OSR_invalidation_back_branch); nm->make_not_entrant(nmethod::InvalidationReason::OSR_INVALIDATION_BACK_BRANCH);
} }
} }
// Fix up next_level if necessary to avoid deopts // Fix up next_level if necessary to avoid deopts

View File

@ -1207,7 +1207,7 @@ C2V_VMENTRY_0(jint, installCode0, (JNIEnv *env, jobject,
assert(JVMCIENV->isa_HotSpotNmethod(installed_code_handle), "wrong type"); assert(JVMCIENV->isa_HotSpotNmethod(installed_code_handle), "wrong type");
// Clear the link to an old nmethod first // Clear the link to an old nmethod first
JVMCIObject nmethod_mirror = installed_code_handle; JVMCIObject nmethod_mirror = installed_code_handle;
JVMCIENV->invalidate_nmethod_mirror(nmethod_mirror, true, nmethod::ChangeReason::JVMCI_replaced_with_new_code, JVMCI_CHECK_0); JVMCIENV->invalidate_nmethod_mirror(nmethod_mirror, true, nmethod::InvalidationReason::JVMCI_REPLACED_WITH_NEW_CODE, JVMCI_CHECK_0);
} else { } else {
assert(JVMCIENV->isa_InstalledCode(installed_code_handle), "wrong type"); assert(JVMCIENV->isa_InstalledCode(installed_code_handle), "wrong type");
} }
@ -1218,11 +1218,11 @@ C2V_VMENTRY_0(jint, installCode0, (JNIEnv *env, jobject,
return result; return result;
C2V_END C2V_END
C2V_VMENTRY_0(jobject, getInvalidationReasonString, (JNIEnv *env, jobject, jint invalidation_reason)) C2V_VMENTRY_0(jobject, getInvalidationReasonDescription, (JNIEnv *env, jobject, jint invalidation_reason))
HandleMark hm(THREAD); HandleMark hm(THREAD);
JNIHandleMark jni_hm(thread); JNIHandleMark jni_hm(thread);
nmethod::ChangeReason reason = static_cast<nmethod::ChangeReason>(invalidation_reason); nmethod::InvalidationReason reason = static_cast<nmethod::InvalidationReason>(invalidation_reason);
JVMCIObject desc = JVMCIENV->create_string(nmethod::change_reason_to_string(reason), JVMCI_CHECK_NULL); JVMCIObject desc = JVMCIENV->create_string(nmethod::invalidation_reason_to_string(reason), JVMCI_CHECK_NULL);
return JVMCIENV->get_jobject(desc); return JVMCIENV->get_jobject(desc);
C2V_END C2V_END
@ -1391,7 +1391,7 @@ C2V_VMENTRY(void, reprofile, (JNIEnv* env, jobject, ARGUMENT_PAIR(method)))
nmethod* code = method->code(); nmethod* code = method->code();
if (code != nullptr) { if (code != nullptr) {
code->make_not_entrant(nmethod::ChangeReason::JVMCI_reprofile); code->make_not_entrant(nmethod::InvalidationReason::JVMCI_REPROFILE);
} }
MethodData* method_data = method->method_data(); MethodData* method_data = method->method_data();
@ -1406,7 +1406,7 @@ C2V_END
C2V_VMENTRY(void, invalidateHotSpotNmethod, (JNIEnv* env, jobject, jobject hs_nmethod, jboolean deoptimize, jint invalidation_reason)) C2V_VMENTRY(void, invalidateHotSpotNmethod, (JNIEnv* env, jobject, jobject hs_nmethod, jboolean deoptimize, jint invalidation_reason))
JVMCIObject nmethod_mirror = JVMCIENV->wrap(hs_nmethod); JVMCIObject nmethod_mirror = JVMCIENV->wrap(hs_nmethod);
JVMCIENV->invalidate_nmethod_mirror(nmethod_mirror, deoptimize, static_cast<nmethod::ChangeReason>(invalidation_reason), JVMCI_CHECK); JVMCIENV->invalidate_nmethod_mirror(nmethod_mirror, deoptimize, static_cast<nmethod::InvalidationReason>(invalidation_reason), JVMCI_CHECK);
C2V_END C2V_END
C2V_VMENTRY_NULL(jlongArray, collectCounters, (JNIEnv* env, jobject)) C2V_VMENTRY_NULL(jlongArray, collectCounters, (JNIEnv* env, jobject))
@ -1831,7 +1831,7 @@ C2V_VMENTRY(void, materializeVirtualObjects, (JNIEnv* env, jobject, jobject _hs_
if (!fst.current()->is_compiled_frame()) { if (!fst.current()->is_compiled_frame()) {
JVMCI_THROW_MSG(IllegalStateException, "compiled stack frame expected"); JVMCI_THROW_MSG(IllegalStateException, "compiled stack frame expected");
} }
fst.current()->cb()->as_nmethod()->make_not_entrant(nmethod::ChangeReason::JVMCI_materialize_virtual_object); fst.current()->cb()->as_nmethod()->make_not_entrant(nmethod::InvalidationReason::JVMCI_MATERIALIZE_VIRTUAL_OBJECT);
} }
Deoptimization::deoptimize(thread, *fst.current(), Deoptimization::Reason_none); Deoptimization::deoptimize(thread, *fst.current(), Deoptimization::Reason_none);
// look for the frame again as it has been updated by deopt (pc, deopt state...) // look for the frame again as it has been updated by deopt (pc, deopt state...)
@ -3360,7 +3360,7 @@ JNINativeMethod CompilerToVM::methods[] = {
{CC "getResolvedJavaType0", CC "(Ljava/lang/Object;JZ)" HS_KLASS, FN_PTR(getResolvedJavaType0)}, {CC "getResolvedJavaType0", CC "(Ljava/lang/Object;JZ)" HS_KLASS, FN_PTR(getResolvedJavaType0)},
{CC "readConfiguration", CC "()[" OBJECT, FN_PTR(readConfiguration)}, {CC "readConfiguration", CC "()[" OBJECT, FN_PTR(readConfiguration)},
{CC "installCode0", CC "(JJZ" HS_COMPILED_CODE "[" OBJECT INSTALLED_CODE "J[B)I", FN_PTR(installCode0)}, {CC "installCode0", CC "(JJZ" HS_COMPILED_CODE "[" OBJECT INSTALLED_CODE "J[B)I", FN_PTR(installCode0)},
{CC "getInvalidationReasonString", CC "(I)" STRING, FN_PTR(getInvalidationReasonString)}, {CC "getInvalidationReasonDescription", CC "(I)" STRING, FN_PTR(getInvalidationReasonDescription)},
{CC "getInstallCodeFlags", CC "()I", FN_PTR(getInstallCodeFlags)}, {CC "getInstallCodeFlags", CC "()I", FN_PTR(getInstallCodeFlags)},
{CC "resetCompilationStatistics", CC "()V", FN_PTR(resetCompilationStatistics)}, {CC "resetCompilationStatistics", CC "()V", FN_PTR(resetCompilationStatistics)},
{CC "disassembleCodeBlob", CC "(" INSTALLED_CODE ")" STRING, FN_PTR(disassembleCodeBlob)}, {CC "disassembleCodeBlob", CC "(" INSTALLED_CODE ")" STRING, FN_PTR(disassembleCodeBlob)},

View File

@ -1744,14 +1744,13 @@ void JVMCIEnv::initialize_installed_code(JVMCIObject installed_code, CodeBlob* c
set_InstalledCode_entryPoint(installed_code, (jlong) cb->code_begin()); set_InstalledCode_entryPoint(installed_code, (jlong) cb->code_begin());
} }
set_InstalledCode_address(installed_code, (jlong) cb); set_InstalledCode_address(installed_code, (jlong) cb);
set_HotSpotNmethod_invalidationReason(installed_code, static_cast<int>(nmethod::ChangeReason::unknown));
set_HotSpotInstalledCode_size(installed_code, cb->size()); set_HotSpotInstalledCode_size(installed_code, cb->size());
set_HotSpotInstalledCode_codeStart(installed_code, (jlong) cb->code_begin()); set_HotSpotInstalledCode_codeStart(installed_code, (jlong) cb->code_begin());
set_HotSpotInstalledCode_codeSize(installed_code, cb->code_size()); set_HotSpotInstalledCode_codeSize(installed_code, cb->code_size());
} }
void JVMCIEnv::invalidate_nmethod_mirror(JVMCIObject mirror, bool deoptimize, nmethod::ChangeReason change_reason, JVMCI_TRAPS) { void JVMCIEnv::invalidate_nmethod_mirror(JVMCIObject mirror, bool deoptimize, nmethod::InvalidationReason invalidation_reason, JVMCI_TRAPS) {
if (mirror.is_null()) { if (mirror.is_null()) {
JVMCI_THROW(NullPointerException); JVMCI_THROW(NullPointerException);
} }
@ -1774,7 +1773,7 @@ void JVMCIEnv::invalidate_nmethod_mirror(JVMCIObject mirror, bool deoptimize, nm
if (!deoptimize) { if (!deoptimize) {
// Prevent future executions of the nmethod but let current executions complete. // Prevent future executions of the nmethod but let current executions complete.
nm->make_not_entrant(change_reason); nm->make_not_entrant(invalidation_reason);
// Do not clear the address field here as the Java code may still // Do not clear the address field here as the Java code may still
// want to later call this method with deoptimize == true. That requires // want to later call this method with deoptimize == true. That requires
@ -1783,7 +1782,7 @@ void JVMCIEnv::invalidate_nmethod_mirror(JVMCIObject mirror, bool deoptimize, nm
// Deoptimize the nmethod immediately. // Deoptimize the nmethod immediately.
DeoptimizationScope deopt_scope; DeoptimizationScope deopt_scope;
deopt_scope.mark(nm); deopt_scope.mark(nm);
nm->make_not_entrant(change_reason); nm->make_not_entrant(invalidation_reason);
nm->make_deoptimized(); nm->make_deoptimized();
deopt_scope.deoptimize_marked(); deopt_scope.deoptimize_marked();

View File

@ -462,7 +462,7 @@ public:
// field of `mirror` to prevent it from being called. // field of `mirror` to prevent it from being called.
// If `deoptimize` is true, the nmethod is immediately deoptimized. // If `deoptimize` is true, the nmethod is immediately deoptimized.
// The HotSpotNmethod.address field is zero upon returning. // The HotSpotNmethod.address field is zero upon returning.
void invalidate_nmethod_mirror(JVMCIObject mirror, bool deoptimze, nmethod::ChangeReason change_reason, JVMCI_TRAPS); void invalidate_nmethod_mirror(JVMCIObject mirror, bool deoptimze, nmethod::InvalidationReason invalidation_reason, JVMCI_TRAPS);
void initialize_installed_code(JVMCIObject installed_code, CodeBlob* cb, JVMCI_TRAPS); void initialize_installed_code(JVMCIObject installed_code, CodeBlob* cb, JVMCI_TRAPS);

View File

@ -797,7 +797,7 @@ void JVMCINMethodData::set_nmethod_mirror(nmethod* nm, oop new_mirror) {
Universe::heap()->register_nmethod(nm); Universe::heap()->register_nmethod(nm);
} }
void JVMCINMethodData::invalidate_nmethod_mirror(nmethod* nm, nmethod::ChangeReason invalidation_reason) { void JVMCINMethodData::invalidate_nmethod_mirror(nmethod* nm, nmethod::InvalidationReason invalidation_reason) {
oop nmethod_mirror = get_nmethod_mirror(nm); oop nmethod_mirror = get_nmethod_mirror(nm);
if (nmethod_mirror == nullptr) { if (nmethod_mirror == nullptr) {
return; return;
@ -2186,7 +2186,7 @@ JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV,
tty->print_cr("Replacing method %s", method_name); tty->print_cr("Replacing method %s", method_name);
} }
if (old != nullptr) { if (old != nullptr) {
old->make_not_entrant(nmethod::ChangeReason::JVMCI_replaced_with_new_code); old->make_not_entrant(nmethod::InvalidationReason::JVMCI_REPLACED_WITH_NEW_CODE);
} }
LogTarget(Info, nmethod, install) lt; LogTarget(Info, nmethod, install) lt;

View File

@ -121,7 +121,7 @@ public:
// Clears the HotSpotNmethod.address field in the mirror. If nm // Clears the HotSpotNmethod.address field in the mirror. If nm
// is dead, the HotSpotNmethod.entryPoint field is also cleared. // is dead, the HotSpotNmethod.entryPoint field is also cleared.
void invalidate_nmethod_mirror(nmethod* nm, nmethod::ChangeReason invalidation_reason); void invalidate_nmethod_mirror(nmethod* nm, nmethod::InvalidationReason invalidation_reason);
// Gets the mirror from nm's oops table. // Gets the mirror from nm's oops table.
oop get_nmethod_mirror(nmethod* nm); oop get_nmethod_mirror(nmethod* nm);

View File

@ -564,30 +564,30 @@
declare_constant_with_value("LockStack::_end_offset", LockStack::end_offset()) \ declare_constant_with_value("LockStack::_end_offset", LockStack::end_offset()) \
declare_constant_with_value("OMCache::oop_to_oop_difference", OMCache::oop_to_oop_difference()) \ declare_constant_with_value("OMCache::oop_to_oop_difference", OMCache::oop_to_oop_difference()) \
declare_constant_with_value("OMCache::oop_to_monitor_difference", OMCache::oop_to_monitor_difference()) \ declare_constant_with_value("OMCache::oop_to_monitor_difference", OMCache::oop_to_monitor_difference()) \
\ \
declare_constant_with_value("nmethod::ChangeReason::UNKNOWN", nmethod::ChangeReason::unknown) \ declare_constant(nmethod::InvalidationReason::UNKNOWN) \
declare_constant_with_value("nmethod::ChangeReason::C1_CODEPATCH", nmethod::ChangeReason::C1_codepatch) \ declare_constant(nmethod::InvalidationReason::C1_CODEPATCH) \
declare_constant_with_value("nmethod::ChangeReason::C1_DEOPTIMIZE", nmethod::ChangeReason::C1_deoptimize) \ declare_constant(nmethod::InvalidationReason::C1_DEOPTIMIZE) \
declare_constant_with_value("nmethod::ChangeReason::C1_DEOPTIMIZE_FOR_PATCHING", nmethod::ChangeReason::C1_deoptimize_for_patching) \ declare_constant(nmethod::InvalidationReason::C1_DEOPTIMIZE_FOR_PATCHING) \
declare_constant_with_value("nmethod::ChangeReason::C1_PREDICATE_FAILED_TRAP", nmethod::ChangeReason::C1_predicate_failed_trap) \ declare_constant(nmethod::InvalidationReason::C1_PREDICATE_FAILED_TRAP) \
declare_constant_with_value("nmethod::ChangeReason::CI_REPLAY", nmethod::ChangeReason::CI_replay) \ declare_constant(nmethod::InvalidationReason::CI_REPLAY) \
declare_constant_with_value("nmethod::ChangeReason::GC_UNLINKING", nmethod::ChangeReason::GC_unlinking) \ declare_constant(nmethod::InvalidationReason::GC_UNLINKING) \
declare_constant_with_value("nmethod::ChangeReason::GC_UNLINKING_COLD", nmethod::ChangeReason::GC_unlinking_cold) \ declare_constant(nmethod::InvalidationReason::GC_UNLINKING_COLD) \
declare_constant_with_value("nmethod::ChangeReason::JVMCI_INVALIDATE_NMETHOD", nmethod::ChangeReason::JVMCI_invalidate_nmethod) \ declare_constant(nmethod::InvalidationReason::JVMCI_INVALIDATE) \
declare_constant_with_value("nmethod::ChangeReason::JVMCI_MATERIALIZE_VIRTUAL_OBJECT", nmethod::ChangeReason::JVMCI_materialize_virtual_object) \ declare_constant(nmethod::InvalidationReason::JVMCI_MATERIALIZE_VIRTUAL_OBJECT) \
declare_constant_with_value("nmethod::ChangeReason::JVMCI_REPLACED_WITH_NEW_CODE", nmethod::ChangeReason::JVMCI_replaced_with_new_code) \ declare_constant(nmethod::InvalidationReason::JVMCI_REPLACED_WITH_NEW_CODE) \
declare_constant_with_value("nmethod::ChangeReason::JVMCI_REPROFILE", nmethod::ChangeReason::JVMCI_reprofile) \ declare_constant(nmethod::InvalidationReason::JVMCI_REPROFILE) \
declare_constant_with_value("nmethod::ChangeReason::MARKED_FOR_DEOPTIMIZATION", nmethod::ChangeReason::marked_for_deoptimization) \ declare_constant(nmethod::InvalidationReason::MARKED_FOR_DEOPTIMIZATION) \
declare_constant_with_value("nmethod::ChangeReason::MISSING_EXCEPTION_HANDLER", nmethod::ChangeReason::missing_exception_handler) \ declare_constant(nmethod::InvalidationReason::MISSING_EXCEPTION_HANDLER) \
declare_constant_with_value("nmethod::ChangeReason::NOT_USED", nmethod::ChangeReason::not_used) \ declare_constant(nmethod::InvalidationReason::NOT_USED) \
declare_constant_with_value("nmethod::ChangeReason::OSR_INVALIDATION_BACK_BRANCH", nmethod::ChangeReason::OSR_invalidation_back_branch) \ declare_constant(nmethod::InvalidationReason::OSR_INVALIDATION_BACK_BRANCH) \
declare_constant_with_value("nmethod::ChangeReason::OSR_INVALIDATION_FOR_COMPILING_WITH_C1", nmethod::ChangeReason::OSR_invalidation_for_compiling_with_C1) \ declare_constant(nmethod::InvalidationReason::OSR_INVALIDATION_FOR_COMPILING_WITH_C1) \
declare_constant_with_value("nmethod::ChangeReason::OSR_INVALIDATION_OF_LOWER_LEVEL", nmethod::ChangeReason::OSR_invalidation_of_lower_level) \ declare_constant(nmethod::InvalidationReason::OSR_INVALIDATION_OF_LOWER_LEVEL) \
declare_constant_with_value("nmethod::ChangeReason::SET_NATIVE_FUNCTION", nmethod::ChangeReason::set_native_function) \ declare_constant(nmethod::InvalidationReason::SET_NATIVE_FUNCTION) \
declare_constant_with_value("nmethod::ChangeReason::UNCOMMON_TRAP", nmethod::ChangeReason::uncommon_trap) \ declare_constant(nmethod::InvalidationReason::UNCOMMON_TRAP) \
declare_constant_with_value("nmethod::ChangeReason::WHITEBOX_DEOPTIMIZATION", nmethod::ChangeReason::whitebox_deoptimization) \ declare_constant(nmethod::InvalidationReason::WHITEBOX_DEOPTIMIZATION) \
declare_constant_with_value("nmethod::ChangeReason::ZOMBIE", nmethod::ChangeReason::zombie) \ declare_constant(nmethod::InvalidationReason::ZOMBIE) \
\ \
declare_constant(CodeInstaller::VERIFIED_ENTRY) \ declare_constant(CodeInstaller::VERIFIED_ENTRY) \
declare_constant(CodeInstaller::UNVERIFIED_ENTRY) \ declare_constant(CodeInstaller::UNVERIFIED_ENTRY) \
declare_constant(CodeInstaller::OSR_ENTRY) \ declare_constant(CodeInstaller::OSR_ENTRY) \

View File

@ -3492,7 +3492,7 @@ void InstanceKlass::add_osr_nmethod(nmethod* n) {
for (int l = CompLevel_limited_profile; l < n->comp_level(); l++) { for (int l = CompLevel_limited_profile; l < n->comp_level(); l++) {
nmethod *inv = lookup_osr_nmethod(n->method(), n->osr_entry_bci(), l, true); nmethod *inv = lookup_osr_nmethod(n->method(), n->osr_entry_bci(), l, true);
if (inv != nullptr && inv->is_in_use()) { if (inv != nullptr && inv->is_in_use()) {
inv->make_not_entrant(nmethod::ChangeReason::OSR_invalidation_of_lower_level); inv->make_not_entrant(nmethod::InvalidationReason::OSR_INVALIDATION_OF_LOWER_LEVEL);
} }
} }
} }

View File

@ -1028,7 +1028,7 @@ void Method::set_native_function(address function, bool post_event_flag) {
// If so, we have to make it not_entrant. // If so, we have to make it not_entrant.
nmethod* nm = code(); // Put it into local variable to guard against concurrent updates nmethod* nm = code(); // Put it into local variable to guard against concurrent updates
if (nm != nullptr) { if (nm != nullptr) {
nm->make_not_entrant(nmethod::ChangeReason::set_native_function); nm->make_not_entrant(nmethod::InvalidationReason::SET_NATIVE_FUNCTION);
} }
} }

View File

@ -794,7 +794,7 @@ class VM_WhiteBoxDeoptimizeFrames : public VM_WhiteBoxOperation {
if (_make_not_entrant) { if (_make_not_entrant) {
nmethod* nm = CodeCache::find_nmethod(f->pc()); nmethod* nm = CodeCache::find_nmethod(f->pc());
assert(nm != nullptr, "did not find nmethod"); assert(nm != nullptr, "did not find nmethod");
nm->make_not_entrant(nmethod::ChangeReason::whitebox_deoptimization); nm->make_not_entrant(nmethod::InvalidationReason::WHITEBOX_DEOPTIMIZATION);
} }
++_result; ++_result;
} }

View File

@ -1826,7 +1826,7 @@ void Deoptimization::deoptimize(JavaThread* thread, frame fr, DeoptReason reason
#if INCLUDE_JVMCI #if INCLUDE_JVMCI
address Deoptimization::deoptimize_for_missing_exception_handler(nmethod* nm) { address Deoptimization::deoptimize_for_missing_exception_handler(nmethod* nm) {
// there is no exception handler for this pc => deoptimize // there is no exception handler for this pc => deoptimize
nm->make_not_entrant(nmethod::ChangeReason::missing_exception_handler); nm->make_not_entrant(nmethod::InvalidationReason::MISSING_EXCEPTION_HANDLER);
// Use Deoptimization::deoptimize for all of its side-effects: // Use Deoptimization::deoptimize for all of its side-effects:
// gathering traps statistics, logging... // gathering traps statistics, logging...
@ -2455,7 +2455,7 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* current, jint tr
// Recompile // Recompile
if (make_not_entrant) { if (make_not_entrant) {
if (!nm->make_not_entrant(nmethod::ChangeReason::uncommon_trap)) { if (!nm->make_not_entrant(nmethod::InvalidationReason::UNCOMMON_TRAP)) {
return; // the call did not change nmethod's state return; // the call did not change nmethod's state
} }

View File

@ -1337,7 +1337,7 @@ void JavaThread::make_zombies() {
// it is a Java nmethod // it is a Java nmethod
nmethod* nm = CodeCache::find_nmethod(fst.current()->pc()); nmethod* nm = CodeCache::find_nmethod(fst.current()->pc());
assert(nm != nullptr, "did not find nmethod"); assert(nm != nullptr, "did not find nmethod");
nm->make_not_entrant(nmethod::ChangeReason::zombie); nm->make_not_entrant(nmethod::InvalidationReason::ZOMBIE);
} }
} }
} }

View File

@ -654,7 +654,7 @@ final class CompilerToVM {
long failedSpeculationsAddress, long failedSpeculationsAddress,
byte[] speculations); byte[] speculations);
native String getInvalidationReasonString(int invalidationReason); native String getInvalidationReasonDescription(int invalidationReason);
/** /**
* Gets flags specifying optional parts of code info. Only if a flag is set, will the * Gets flags specifying optional parts of code info. Only if a flag is set, will the

View File

@ -79,6 +79,7 @@ public class HotSpotNmethod extends HotSpotInstalledCode {
/** /**
* Identify the reason that caused this nmethod to be invalidated. * Identify the reason that caused this nmethod to be invalidated.
* A value of -1 means that the nmethod was not invalidated.
*/ */
private int invalidationReason; private int invalidationReason;
@ -88,7 +89,7 @@ public class HotSpotNmethod extends HotSpotInstalledCode {
this.isDefault = isDefault; this.isDefault = isDefault;
boolean inOopsTable = !IS_IN_NATIVE_IMAGE && !isDefault; boolean inOopsTable = !IS_IN_NATIVE_IMAGE && !isDefault;
this.compileIdSnapshot = inOopsTable ? 0L : compileId; this.compileIdSnapshot = inOopsTable ? 0L : compileId;
this.invalidationReason = 0; this.invalidationReason = -1;
assert inOopsTable || compileId != 0L : this; assert inOopsTable || compileId != 0L : this;
} }
@ -216,8 +217,8 @@ public class HotSpotNmethod extends HotSpotInstalledCode {
/** /**
* @return a String describing the reason why this nmethod was invalidated. * @return a String describing the reason why this nmethod was invalidated.
*/ */
public String getInvalidationReasonString() { public String getInvalidationReasonDescription() {
return compilerToVM().getInvalidationReasonString(this.getInvalidationReason()); return compilerToVM().getInvalidationReasonDescription(this.getInvalidationReason());
} }
private static int unknownInvalidationReason() { private static int unknownInvalidationReason() {

View File

@ -69,9 +69,9 @@ public class CodeInvalidationReasonTest extends CodeInstallationTest {
Method method = getMethod("add", int.class, int.class); Method method = getMethod("add", int.class, int.class);
HotSpotNmethod nmethod = test(CodeInvalidationReasonTest::compileAdd, method, 5, 7); HotSpotNmethod nmethod = test(CodeInvalidationReasonTest::compileAdd, method, 5, 7);
Asserts.assertEquals(config.NMETHOD_CHANGE_REASON_UNKNOWN, nmethod.getInvalidationReason()); Asserts.assertEquals(-1 /* since it was not invalidated yet. */, nmethod.getInvalidationReason());
nmethod.invalidate(true, config.NMETHOD_CHANGE_REASON_JVMCI_INVALIDATE); nmethod.invalidate(true, config.NMETHOD_INVALIDATION_REASON_JVMCI_INVALIDATE);
Asserts.assertEquals(config.NMETHOD_CHANGE_REASON_JVMCI_INVALIDATE, nmethod.getInvalidationReason()); Asserts.assertEquals(config.NMETHOD_INVALIDATION_REASON_JVMCI_INVALIDATE, nmethod.getInvalidationReason());
} }
} }

View File

@ -71,13 +71,13 @@ public class SimpleCodeInstallationTest extends CodeInstallationTest {
Asserts.assertNotEquals(nmethod.getStart(), 0L); Asserts.assertNotEquals(nmethod.getStart(), 0L);
// Make nmethod non-entrant but still alive // Make nmethod non-entrant but still alive
nmethod.invalidate(false, config.NMETHOD_CHANGE_REASON_JVMCI_INVALIDATE); nmethod.invalidate(false, config.NMETHOD_INVALIDATION_REASON_JVMCI_INVALIDATE);
Asserts.assertFalse(nmethod.isValid(), "code is valid, i = " + nmethod); Asserts.assertFalse(nmethod.isValid(), "code is valid, i = " + nmethod);
Asserts.assertTrue(nmethod.isAlive(), "code is not alive, i = " + nmethod); Asserts.assertTrue(nmethod.isAlive(), "code is not alive, i = " + nmethod);
Asserts.assertEquals(nmethod.getStart(), 0L); Asserts.assertEquals(nmethod.getStart(), 0L);
// Deoptimize the nmethod and cut the link to it from the HotSpotNmethod // Deoptimize the nmethod and cut the link to it from the HotSpotNmethod
nmethod.invalidate(true, config.NMETHOD_CHANGE_REASON_JVMCI_INVALIDATE); nmethod.invalidate(true, config.NMETHOD_INVALIDATION_REASON_JVMCI_INVALIDATE);
Asserts.assertFalse(nmethod.isValid(), "code is valid, i = " + nmethod); Asserts.assertFalse(nmethod.isValid(), "code is valid, i = " + nmethod);
Asserts.assertFalse(nmethod.isAlive(), "code is alive, i = " + nmethod); Asserts.assertFalse(nmethod.isAlive(), "code is alive, i = " + nmethod);
Asserts.assertEquals(nmethod.getStart(), 0L); Asserts.assertEquals(nmethod.getStart(), 0L);

View File

@ -55,8 +55,7 @@ public class TestHotSpotVMConfig extends HotSpotVMConfigAccess {
public final int maxOopMapStackOffset = getFieldValue("CompilerToVM::Data::_max_oop_map_stack_offset", Integer.class, "int"); public final int maxOopMapStackOffset = getFieldValue("CompilerToVM::Data::_max_oop_map_stack_offset", Integer.class, "int");
public final int heapWordSize = getConstant("HeapWordSize", Integer.class); public final int heapWordSize = getConstant("HeapWordSize", Integer.class);
public final int NMETHOD_CHANGE_REASON_UNKNOWN = getConstant("nmethod::ChangeReason::UNKNOWN", Integer.class); public final int NMETHOD_INVALIDATION_REASON_JVMCI_INVALIDATE = getConstant("nmethod::InvalidationReason::JVMCI_INVALIDATE", Integer.class);
public final int NMETHOD_CHANGE_REASON_JVMCI_INVALIDATE = getConstant("nmethod::ChangeReason::JVMCI_INVALIDATE_NMETHOD", Integer.class);
public final boolean ropProtection; public final boolean ropProtection;