Compare commits

...

2 Commits

Author SHA1 Message Date
JohnTortugo
6f6d129bff Fix some remaining renames. 2025-06-12 20:14:49 +00:00
JohnTortugo
831ba2f02e Rename 'reasons' enum. Adjust default value for invalidationReason. 2025-06-12 19:37:10 +00:00
24 changed files with 127 additions and 128 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);
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) {
MethodData* trap_mdo = Deoptimization::get_method_data(current, method, true /*create_if_missing*/);
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.
nmethod* nm = CodeCache::find_nmethod(caller_frame.pc());
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());
@ -1358,7 +1358,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::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());
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());
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
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::ChangeReason::CI_replay);
nm->make_not_entrant(nmethod::InvalidationReason::CI_REPLAY);
}
replay_state = this;
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()) {
nmethod* nm = iter.method();
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();
}
}

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 (xtty != nullptr) {
ttyLocker ttyl; // keep the following output all in one block
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);
xtty->stamp();
xtty->end_elem();
@ -1989,7 +1989,7 @@ void nmethod::log_state_change(ChangeReason change_reason) const {
ResourceMark rm;
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());
if (PrintCompilation) {
@ -2004,7 +2004,7 @@ void nmethod::unlink_from_method() {
}
// 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
NoSafepointVerifier nsv;
@ -2073,7 +2073,7 @@ bool nmethod::make_not_entrant(ChangeReason change_reason) {
assert(success, "Transition can't fail");
// Log the transition once
log_state_change(change_reason);
log_state_change(invalidation_reason);
// Remove nmethod 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
JVMCINMethodData* nmethod_data = jvmci_nmethod_data();
if (nmethod_data != nullptr) {
nmethod_data->invalidate_nmethod_mirror(this, change_reason);
nmethod_data->invalidate_nmethod_mirror(this, invalidation_reason);
}
#endif
@ -2122,7 +2122,7 @@ void nmethod::unlink() {
// Clear the link between this nmethod and a HotSpotNmethod mirror
JVMCINMethodData* nmethod_data = jvmci_nmethod_data();
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

View File

@ -473,71 +473,71 @@ class nmethod : public CodeBlob {
public:
// If you change anything in this enum please patch
// vmStructs_jvmci.cpp accordingly.
enum class ChangeReason : u1 {
unknown,
C1_codepatch,
C1_deoptimize,
C1_deoptimize_for_patching,
C1_predicate_failed_trap,
CI_replay,
GC_unlinking,
GC_unlinking_cold,
JVMCI_invalidate_nmethod,
JVMCI_materialize_virtual_object,
JVMCI_replaced_with_new_code,
JVMCI_reprofile,
marked_for_deoptimization,
missing_exception_handler,
not_used,
OSR_invalidation_back_branch,
OSR_invalidation_for_compiling_with_C1,
OSR_invalidation_of_lower_level,
set_native_function,
uncommon_trap,
whitebox_deoptimization,
zombie,
enum class InvalidationReason : u1 {
UNKNOWN,
C1_CODEPATCH,
C1_DEOPTIMIZE,
C1_DEOPTIMIZE_FOR_PATCHING,
C1_PREDICATE_FAILED_TRAP,
CI_REPLAY,
GC_UNLINKING,
GC_UNLINKING_COLD,
JVMCI_INVALIDATE,
JVMCI_MATERIALIZE_VIRTUAL_OBJECT,
JVMCI_REPLACED_WITH_NEW_CODE,
JVMCI_REPROFILE,
MARKED_FOR_DEOPTIMIZATION,
MISSING_EXCEPTION_HANDLER,
NOT_USED,
OSR_INVALIDATION_BACK_BRANCH,
OSR_INVALIDATION_FOR_COMPILING_WITH_C1,
OSR_INVALIDATION_OF_LOWER_LEVEL,
SET_NATIVE_FUNCTION,
UNCOMMON_TRAP,
WHITEBOX_DEOPTIMIZATION,
ZOMBIE,
};
static const char* change_reason_to_string(ChangeReason change_reason) {
switch (change_reason) {
case ChangeReason::C1_codepatch:
static const char* invalidation_reason_to_string(InvalidationReason invalidation_reason) {
switch (invalidation_reason) {
case InvalidationReason::C1_CODEPATCH:
return "C1 code patch";
case ChangeReason::C1_deoptimize:
case InvalidationReason::C1_DEOPTIMIZE:
return "C1 deoptimized";
case ChangeReason::C1_deoptimize_for_patching:
case InvalidationReason::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";
case ChangeReason::CI_replay:
case InvalidationReason::CI_REPLAY:
return "CI replay";
case ChangeReason::JVMCI_invalidate_nmethod:
return "JVMCI invalidate nmethod";
case ChangeReason::JVMCI_materialize_virtual_object:
case InvalidationReason::JVMCI_INVALIDATE:
return "JVMCI invalidate";
case InvalidationReason::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";
case ChangeReason::JVMCI_reprofile:
case InvalidationReason::JVMCI_REPROFILE:
return "JVMCI reprofile";
case ChangeReason::marked_for_deoptimization:
case InvalidationReason::MARKED_FOR_DEOPTIMIZATION:
return "marked for deoptimization";
case ChangeReason::missing_exception_handler:
case InvalidationReason::MISSING_EXCEPTION_HANDLER:
return "missing exception handler";
case ChangeReason::not_used:
case InvalidationReason::NOT_USED:
return "not used";
case ChangeReason::OSR_invalidation_back_branch:
case InvalidationReason::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";
case ChangeReason::OSR_invalidation_of_lower_level:
case InvalidationReason::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";
case ChangeReason::uncommon_trap:
case InvalidationReason::UNCOMMON_TRAP:
return "uncommon trap";
case ChangeReason::whitebox_deoptimization:
case InvalidationReason::WHITEBOX_DEOPTIMIZATION:
return "whitebox deoptimization";
case ChangeReason::zombie:
case InvalidationReason::ZOMBIE:
return "zombie";
default: {
assert(false, "Unhandled reason");
@ -708,8 +708,8 @@ public:
// alive. It is used when an uncommon trap happens. Returns true
// if this thread changed the state of the nmethod or false if
// another thread performed the transition.
bool make_not_entrant(ChangeReason change_reason);
bool make_not_used() { return make_not_entrant(ChangeReason::not_used); }
bool make_not_entrant(InvalidationReason invalidation_reason);
bool make_not_used() { return make_not_entrant(InvalidationReason::NOT_USED); }
bool is_marked_for_deoptimization() const { return deoptimization_status() != not_marked; }
bool has_been_deoptimized() const { return deoptimization_status() == deoptimize_done; }
@ -1022,7 +1022,7 @@ public:
// Logging
void log_identity(xmlStream* log) 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:
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);
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::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);
}
@ -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;
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

View File

@ -1207,7 +1207,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::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 {
assert(JVMCIENV->isa_InstalledCode(installed_code_handle), "wrong type");
}
@ -1218,11 +1218,11 @@ C2V_VMENTRY_0(jint, installCode0, (JNIEnv *env, jobject,
return result;
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);
JNIHandleMark jni_hm(thread);
nmethod::ChangeReason reason = static_cast<nmethod::ChangeReason>(invalidation_reason);
JVMCIObject desc = JVMCIENV->create_string(nmethod::change_reason_to_string(reason), JVMCI_CHECK_NULL);
nmethod::InvalidationReason reason = static_cast<nmethod::InvalidationReason>(invalidation_reason);
JVMCIObject desc = JVMCIENV->create_string(nmethod::invalidation_reason_to_string(reason), JVMCI_CHECK_NULL);
return JVMCIENV->get_jobject(desc);
C2V_END
@ -1391,7 +1391,7 @@ C2V_VMENTRY(void, reprofile, (JNIEnv* env, jobject, ARGUMENT_PAIR(method)))
nmethod* code = method->code();
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();
@ -1406,7 +1406,7 @@ C2V_END
C2V_VMENTRY(void, invalidateHotSpotNmethod, (JNIEnv* env, jobject, jobject hs_nmethod, jboolean deoptimize, jint invalidation_reason))
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_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()) {
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);
// 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 "readConfiguration", CC "()[" OBJECT, FN_PTR(readConfiguration)},
{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 "resetCompilationStatistics", CC "()V", FN_PTR(resetCompilationStatistics)},
{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_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_codeStart(installed_code, (jlong) cb->code_begin());
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()) {
JVMCI_THROW(NullPointerException);
}
@ -1774,7 +1773,7 @@ void JVMCIEnv::invalidate_nmethod_mirror(JVMCIObject mirror, bool deoptimize, nm
if (!deoptimize) {
// 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
// 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.
DeoptimizationScope deopt_scope;
deopt_scope.mark(nm);
nm->make_not_entrant(change_reason);
nm->make_not_entrant(invalidation_reason);
nm->make_deoptimized();
deopt_scope.deoptimize_marked();

View File

@ -462,7 +462,7 @@ public:
// field of `mirror` to prevent it from being called.
// If `deoptimize` is true, the nmethod is immediately deoptimized.
// 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);

View File

@ -797,7 +797,7 @@ void JVMCINMethodData::set_nmethod_mirror(nmethod* nm, oop new_mirror) {
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);
if (nmethod_mirror == nullptr) {
return;
@ -2186,7 +2186,7 @@ JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV,
tty->print_cr("Replacing method %s", method_name);
}
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;

View File

@ -121,7 +121,7 @@ public:
// Clears the HotSpotNmethod.address field in the mirror. If nm
// 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.
oop get_nmethod_mirror(nmethod* nm);

View File

@ -565,28 +565,28 @@
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("nmethod::ChangeReason::UNKNOWN", nmethod::ChangeReason::unknown) \
declare_constant_with_value("nmethod::ChangeReason::C1_CODEPATCH", nmethod::ChangeReason::C1_codepatch) \
declare_constant_with_value("nmethod::ChangeReason::C1_DEOPTIMIZE", nmethod::ChangeReason::C1_deoptimize) \
declare_constant_with_value("nmethod::ChangeReason::C1_DEOPTIMIZE_FOR_PATCHING", nmethod::ChangeReason::C1_deoptimize_for_patching) \
declare_constant_with_value("nmethod::ChangeReason::C1_PREDICATE_FAILED_TRAP", nmethod::ChangeReason::C1_predicate_failed_trap) \
declare_constant_with_value("nmethod::ChangeReason::CI_REPLAY", nmethod::ChangeReason::CI_replay) \
declare_constant_with_value("nmethod::ChangeReason::GC_UNLINKING", nmethod::ChangeReason::GC_unlinking) \
declare_constant_with_value("nmethod::ChangeReason::GC_UNLINKING_COLD", nmethod::ChangeReason::GC_unlinking_cold) \
declare_constant_with_value("nmethod::ChangeReason::JVMCI_INVALIDATE_NMETHOD", nmethod::ChangeReason::JVMCI_invalidate_nmethod) \
declare_constant_with_value("nmethod::ChangeReason::JVMCI_MATERIALIZE_VIRTUAL_OBJECT", nmethod::ChangeReason::JVMCI_materialize_virtual_object) \
declare_constant_with_value("nmethod::ChangeReason::JVMCI_REPLACED_WITH_NEW_CODE", nmethod::ChangeReason::JVMCI_replaced_with_new_code) \
declare_constant_with_value("nmethod::ChangeReason::JVMCI_REPROFILE", nmethod::ChangeReason::JVMCI_reprofile) \
declare_constant_with_value("nmethod::ChangeReason::MARKED_FOR_DEOPTIMIZATION", nmethod::ChangeReason::marked_for_deoptimization) \
declare_constant_with_value("nmethod::ChangeReason::MISSING_EXCEPTION_HANDLER", nmethod::ChangeReason::missing_exception_handler) \
declare_constant_with_value("nmethod::ChangeReason::NOT_USED", nmethod::ChangeReason::not_used) \
declare_constant_with_value("nmethod::ChangeReason::OSR_INVALIDATION_BACK_BRANCH", nmethod::ChangeReason::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_with_value("nmethod::ChangeReason::OSR_INVALIDATION_OF_LOWER_LEVEL", nmethod::ChangeReason::OSR_invalidation_of_lower_level) \
declare_constant_with_value("nmethod::ChangeReason::SET_NATIVE_FUNCTION", nmethod::ChangeReason::set_native_function) \
declare_constant_with_value("nmethod::ChangeReason::UNCOMMON_TRAP", nmethod::ChangeReason::uncommon_trap) \
declare_constant_with_value("nmethod::ChangeReason::WHITEBOX_DEOPTIMIZATION", nmethod::ChangeReason::whitebox_deoptimization) \
declare_constant_with_value("nmethod::ChangeReason::ZOMBIE", nmethod::ChangeReason::zombie) \
declare_constant(nmethod::InvalidationReason::UNKNOWN) \
declare_constant(nmethod::InvalidationReason::C1_CODEPATCH) \
declare_constant(nmethod::InvalidationReason::C1_DEOPTIMIZE) \
declare_constant(nmethod::InvalidationReason::C1_DEOPTIMIZE_FOR_PATCHING) \
declare_constant(nmethod::InvalidationReason::C1_PREDICATE_FAILED_TRAP) \
declare_constant(nmethod::InvalidationReason::CI_REPLAY) \
declare_constant(nmethod::InvalidationReason::GC_UNLINKING) \
declare_constant(nmethod::InvalidationReason::GC_UNLINKING_COLD) \
declare_constant(nmethod::InvalidationReason::JVMCI_INVALIDATE) \
declare_constant(nmethod::InvalidationReason::JVMCI_MATERIALIZE_VIRTUAL_OBJECT) \
declare_constant(nmethod::InvalidationReason::JVMCI_REPLACED_WITH_NEW_CODE) \
declare_constant(nmethod::InvalidationReason::JVMCI_REPROFILE) \
declare_constant(nmethod::InvalidationReason::MARKED_FOR_DEOPTIMIZATION) \
declare_constant(nmethod::InvalidationReason::MISSING_EXCEPTION_HANDLER) \
declare_constant(nmethod::InvalidationReason::NOT_USED) \
declare_constant(nmethod::InvalidationReason::OSR_INVALIDATION_BACK_BRANCH) \
declare_constant(nmethod::InvalidationReason::OSR_INVALIDATION_FOR_COMPILING_WITH_C1) \
declare_constant(nmethod::InvalidationReason::OSR_INVALIDATION_OF_LOWER_LEVEL) \
declare_constant(nmethod::InvalidationReason::SET_NATIVE_FUNCTION) \
declare_constant(nmethod::InvalidationReason::UNCOMMON_TRAP) \
declare_constant(nmethod::InvalidationReason::WHITEBOX_DEOPTIMIZATION) \
declare_constant(nmethod::InvalidationReason::ZOMBIE) \
\
declare_constant(CodeInstaller::VERIFIED_ENTRY) \
declare_constant(CodeInstaller::UNVERIFIED_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++) {
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::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.
nmethod* nm = code(); // Put it into local variable to guard against concurrent updates
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) {
nmethod* nm = CodeCache::find_nmethod(f->pc());
assert(nm != nullptr, "did not find nmethod");
nm->make_not_entrant(nmethod::ChangeReason::whitebox_deoptimization);
nm->make_not_entrant(nmethod::InvalidationReason::WHITEBOX_DEOPTIMIZATION);
}
++_result;
}

View File

@ -1826,7 +1826,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::ChangeReason::missing_exception_handler);
nm->make_not_entrant(nmethod::InvalidationReason::MISSING_EXCEPTION_HANDLER);
// Use Deoptimization::deoptimize for all of its side-effects:
// gathering traps statistics, logging...
@ -2455,7 +2455,7 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* current, jint tr
// Recompile
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
}

View File

@ -1337,7 +1337,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::ChangeReason::zombie);
nm->make_not_entrant(nmethod::InvalidationReason::ZOMBIE);
}
}
}

View File

@ -654,7 +654,7 @@ final class CompilerToVM {
long failedSpeculationsAddress,
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

View File

@ -165,7 +165,7 @@ public class HotSpotCodeCacheProvider implements CodeCacheProvider {
@Override
public void invalidateInstalledCode(InstalledCode installedCode) {
invalidateInstalledCode(installedCode, unknownInvalidationReason());
invalidateInstalledCode(installedCode, jvmciInvalidationReason());
}
@Override
@ -206,7 +206,7 @@ public class HotSpotCodeCacheProvider implements CodeCacheProvider {
runtime.getCompilerToVM().resetCompilationStatistics();
}
private static int unknownInvalidationReason() {
return HotSpotJVMCIRuntime.runtime().config.getConstant("nmethod::ChangeReason::Unknown", Integer.class);
private static int jvmciInvalidationReason() {
return HotSpotJVMCIRuntime.runtime().config.getConstant("nmethod::InvalidationReason::JVMCI_INVALIDATE", Integer.class);
}
}

View File

@ -79,6 +79,7 @@ public class HotSpotNmethod extends HotSpotInstalledCode {
/**
* Identify the reason that caused this nmethod to be invalidated.
* A value of -1 means that the nmethod was not invalidated.
*/
private int invalidationReason;
@ -88,7 +89,7 @@ public class HotSpotNmethod extends HotSpotInstalledCode {
this.isDefault = isDefault;
boolean inOopsTable = !IS_IN_NATIVE_IMAGE && !isDefault;
this.compileIdSnapshot = inOopsTable ? 0L : compileId;
this.invalidationReason = 0;
this.invalidationReason = -1;
assert inOopsTable || compileId != 0L : this;
}
@ -141,7 +142,7 @@ public class HotSpotNmethod extends HotSpotInstalledCode {
@Override
public void invalidate(boolean deoptimize) {
invalidate(deoptimize, unknownInvalidationReason());
invalidate(deoptimize, jvmciInvalidationReason());
}
@Override
@ -216,11 +217,11 @@ public class HotSpotNmethod extends HotSpotInstalledCode {
/**
* @return a String describing the reason why this nmethod was invalidated.
*/
public String getInvalidationReasonString() {
return compilerToVM().getInvalidationReasonString(this.getInvalidationReason());
public String getInvalidationReasonDescription() {
return compilerToVM().getInvalidationReasonDescription(this.getInvalidationReason());
}
private static int unknownInvalidationReason() {
return HotSpotJVMCIRuntime.runtime().config.getConstant("nmethod::ChangeReason::Unknown", Integer.class);
private static int jvmciInvalidationReason() {
return HotSpotJVMCIRuntime.runtime().config.getConstant("nmethod::InvalidationReason::JVMCI_INVALIDATE", Integer.class);
}
}

View File

@ -229,8 +229,8 @@ public class CompilerToVMHelper {
CTVM.reprofile((HotSpotResolvedJavaMethodImpl)method);
}
public static void invalidateHotSpotNmethod(HotSpotNmethod nmethodMirror, boolean deoptimize, int changeReason) {
CTVM.invalidateHotSpotNmethod(nmethodMirror, deoptimize, changeReason);
public static void invalidateHotSpotNmethod(HotSpotNmethod nmethodMirror, boolean deoptimize, int invalidationReason) {
CTVM.invalidateHotSpotNmethod(nmethodMirror, deoptimize, invalidationReason);
}
public static long[] collectCounters() {

View File

@ -69,9 +69,9 @@ public class CodeInvalidationReasonTest extends CodeInstallationTest {
Method method = getMethod("add", int.class, int.class);
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);
Asserts.assertEquals(config.NMETHOD_CHANGE_REASON_JVMCI_INVALIDATE, nmethod.getInvalidationReason());
nmethod.invalidate(true, config.NMETHOD_INVALIDATION_REASON_JVMCI_INVALIDATE);
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);
// 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.assertTrue(nmethod.isAlive(), "code is not alive, i = " + nmethod);
Asserts.assertEquals(nmethod.getStart(), 0L);
// 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.isAlive(), "code is alive, i = " + nmethod);
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 heapWordSize = getConstant("HeapWordSize", Integer.class);
public final int NMETHOD_CHANGE_REASON_UNKNOWN = getConstant("nmethod::ChangeReason::UNKNOWN", Integer.class);
public final int NMETHOD_CHANGE_REASON_JVMCI_INVALIDATE = getConstant("nmethod::ChangeReason::JVMCI_INVALIDATE_NMETHOD", Integer.class);
public final int NMETHOD_INVALIDATION_REASON_JVMCI_INVALIDATE = getConstant("nmethod::InvalidationReason::JVMCI_INVALIDATE", Integer.class);
public final boolean ropProtection;