< prev index next >
src/share/vm/code/nmethod.cpp
Print this page
*** 1348,1371 ****
}
// Unregister must be done before the state change
Universe::heap()->unregister_nmethod(this);
#if INCLUDE_JVMCI
// The method can only be unloaded after the pointer to the installed code
// Java wrapper is no longer alive. Here we need to clear out this weak
// reference to the dead object. Nulling out the reference has to happen
// after the method is unregistered since the original value may be still
// tracked by the rset.
! if (_jvmci_installed_code != NULL) {
! InstalledCode::set_address(_jvmci_installed_code, 0);
! _jvmci_installed_code = NULL;
! }
#endif
- _state = unloaded;
-
// Log the unloading.
log_state_change();
// The Method* is gone at this point
assert(_method == NULL, "Tautology");
--- 1348,1368 ----
}
// Unregister must be done before the state change
Universe::heap()->unregister_nmethod(this);
+ _state = unloaded;
+
#if INCLUDE_JVMCI
// The method can only be unloaded after the pointer to the installed code
// Java wrapper is no longer alive. Here we need to clear out this weak
// reference to the dead object. Nulling out the reference has to happen
// after the method is unregistered since the original value may be still
// tracked by the rset.
! maybe_invalidate_installed_code();
#endif
// Log the unloading.
log_state_change();
// The Method* is gone at this point
assert(_method == NULL, "Tautology");
*** 1523,1538 ****
// nmethod is in zombie state
set_method(NULL);
} else {
assert(state == not_entrant, "other cases may need to be handled differently");
}
! #if INCLUDE_JVMCI
! if (_jvmci_installed_code != NULL) {
! // Break the link between nmethod and InstalledCode such that the nmethod can subsequently be flushed safely.
! InstalledCode::set_address(_jvmci_installed_code, 0);
! }
! #endif
if (TraceCreateZombies) {
ResourceMark m;
tty->print_cr("nmethod <" INTPTR_FORMAT "> %s code made %s", p2i(this), this->method() ? this->method()->name_and_sig_as_C_string() : "null", (state == not_entrant) ? "not entrant" : "zombie");
}
--- 1520,1531 ----
// nmethod is in zombie state
set_method(NULL);
} else {
assert(state == not_entrant, "other cases may need to be handled differently");
}
!
! JVMCI_ONLY(maybe_invalidate_installed_code());
if (TraceCreateZombies) {
ResourceMark m;
tty->print_cr("nmethod <" INTPTR_FORMAT "> %s code made %s", p2i(this), this->method() ? this->method()->name_and_sig_as_C_string() : "null", (state == not_entrant) ? "not entrant" : "zombie");
}
*** 3382,3391 ****
--- 3375,3400 ----
}
#endif // !PRODUCT
#if INCLUDE_JVMCI
+ void nmethod::maybe_invalidate_installed_code() {
+ if (_jvmci_installed_code != NULL) {
+ if (!is_alive()) {
+ // Break the link between nmethod and InstalledCode such that the nmethod
+ // can subsequently be flushed safely. The link must be maintained while
+ // the method could have live activations since invalidateInstalledCode
+ // might want to invalidate all existing activations.
+ InstalledCode::set_address(_jvmci_installed_code, 0);
+ InstalledCode::set_entryPoint(_jvmci_installed_code, 0);
+ _jvmci_installed_code = NULL;
+ } else if (is_not_entrant()) {
+ InstalledCode::set_entryPoint(_jvmci_installed_code, 0);
+ }
+ }
+ }
+
char* nmethod::jvmci_installed_code_name(char* buf, size_t buflen) {
if (!this->is_compiled_by_jvmci()) {
return NULL;
}
oop installedCode = this->jvmci_installed_code();
< prev index next >