Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
revert to "nmethod_mirror" naming convention
Browse files Browse the repository at this point in the history
  • Loading branch information
dougxc committed Feb 28, 2019
1 parent d20773f commit c891929
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 66 deletions.
2 changes: 1 addition & 1 deletion hotspot/.project
Expand Up @@ -7,7 +7,7 @@
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers></triggers>
<triggers>auto,</triggers>
<arguments>
<dictionary>
<key>?children?</key>
Expand Down
8 changes: 4 additions & 4 deletions src/share/vm/code/nmethod.cpp
Expand Up @@ -1107,7 +1107,7 @@ void nmethod::log_identity(xmlStream* log) const {
}
#if INCLUDE_JVMCI
if (jvmci_nmethod_data() != NULL) {
const char* jvmci_name = jvmci_nmethod_data()->mirror_name();
const char* jvmci_name = jvmci_nmethod_data()->name();
if (jvmci_name != NULL) {
log->print(" jvmci_mirror_name='");
log->text("%s", jvmci_name);
Expand Down Expand Up @@ -3593,7 +3593,7 @@ void nmethod::print_statistics() {
#if INCLUDE_JVMCI
void nmethod::invalidate_mirror() {
if (jvmci_nmethod_data() != NULL) {
jvmci_nmethod_data()->invalidate_mirror(this);
jvmci_nmethod_data()->invalidate_nmethod_mirror(this);
}
}

Expand All @@ -3607,9 +3607,9 @@ void nmethod::update_speculation(JavaThread* thread) {
}
}

const char* nmethod::mirror_name() {
const char* nmethod::jvmci_name() {
if (jvmci_nmethod_data() != NULL) {
return jvmci_nmethod_data()->mirror_name();
return jvmci_nmethod_data()->name();
}
return NULL;
}
Expand Down
4 changes: 2 additions & 2 deletions src/share/vm/code/nmethod.hpp
Expand Up @@ -659,8 +659,8 @@ class nmethod : public CodeBlob {
void set_method(Method* method) { _method = method; }

#if INCLUDE_JVMCI
// Gets the name of the mirror (if any).
const char* mirror_name();
// Gets the JVMCI name of this nmethod.
const char* jvmci_name();

// Updates the state of this nmethod's HotSpotNmethod mirror
// based on the current value of _state. If this nmethod is
Expand Down
2 changes: 1 addition & 1 deletion src/share/vm/compiler/disassembler.cpp
Expand Up @@ -531,7 +531,7 @@ void Disassembler::decode(nmethod* nm, outputStream* st) {
nm->method()->name()->print_symbol_on(env.output());
#if INCLUDE_JVMCI
{
const char* jvmciName = nm->mirror_name();
const char* jvmciName = nm->jvmci_name();
if (jvmciName != NULL) {
env.output()->print(" (%s)", jvmciName);
}
Expand Down
29 changes: 15 additions & 14 deletions src/share/vm/jvmci/jvmciCompilerToVM.cpp
Expand Up @@ -784,8 +784,8 @@ C2V_VMENTRY(jint, installCode, (JNIEnv *env, jobject, jobject target, jobject co
if (cb->is_nmethod()) {
assert(JVMCIENV->isa_HotSpotNmethod(installed_code_handle), "wrong type");
// Clear the link to an old nmethod first
JVMCIObject mirror = installed_code_handle;
JVMCIENV->invalidate_nmethod_mirror(mirror, JVMCI_CHECK_0);
JVMCIObject nmethod_mirror = installed_code_handle;
JVMCIENV->invalidate_nmethod_mirror(nmethod_mirror, JVMCI_CHECK_0);
} else {
assert(JVMCIENV->isa_InstalledCode(installed_code_handle), "wrong type");
}
Expand Down Expand Up @@ -933,8 +933,8 @@ C2V_VMENTRY(jobject, executeHotSpotNmethod, (JNIEnv* env, jobject, jobject args,

HandleMark hm;

JVMCIObject mirror = JVMCIENV->wrap(hs_nmethod);
nmethod* nm = JVMCIENV->asNmethod(mirror);
JVMCIObject nmethod_mirror = JVMCIENV->wrap(hs_nmethod);
nmethod* nm = JVMCIENV->asNmethod(nmethod_mirror);
if (nm == NULL) {
JVMCI_THROW_NULL(InvalidInstalledCodeException);
}
Expand Down Expand Up @@ -1040,8 +1040,8 @@ C2V_END


C2V_VMENTRY(void, invalidateHotSpotNmethod, (JNIEnv* env, jobject, jobject hs_nmethod))
JVMCIObject mirror = JVMCIENV->wrap(hs_nmethod);
JVMCIENV->invalidate_nmethod_mirror(mirror, JVMCI_CHECK);
JVMCIObject nmethod_mirror = JVMCIENV->wrap(hs_nmethod);
JVMCIENV->invalidate_nmethod_mirror(nmethod_mirror, JVMCI_CHECK);
C2V_END

C2V_VMENTRY(jobject, readUncompressedOop, (JNIEnv* env, jobject, jlong addr))
Expand Down Expand Up @@ -2216,10 +2216,11 @@ C2V_VMENTRY(jlong, translate, (JNIEnv* env, jobject, jobject obj_handle))
JVMCINMethodData* data = nm->jvmci_nmethod_data();
if (data != NULL) {
if (peerEnv->is_hotspot()) {
// Only the mirror in the HotSpot heap is held by JVMCINMethodData
oop mirror = data->get_mirror(nm);
if (mirror != NULL) {
result = HotSpotJVMCI::wrap(mirror);
// Only the mirror in the HotSpot heap is accessible
// through JVMCINMethodData
oop nmethod_mirror = data->get_nmethod_mirror(nm);
if (nmethod_mirror != NULL) {
result = HotSpotJVMCI::wrap(nmethod_mirror);
}
}
}
Expand All @@ -2242,11 +2243,11 @@ C2V_VMENTRY(jlong, translate, (JNIEnv* env, jobject, jobject obj_handle))
// HotSpotNMethodHandle instances are updated cooperatively.
if (peerEnv->is_hotspot()) {
JVMCINMethodData* data = nm->jvmci_nmethod_data();
if (data->get_mirror(nm) != NULL) {
JVMCI_THROW_MSG_0(IllegalArgumentException, "Cannot overwrite existing HotSpotNmethod object for nmethod");
if (data->get_nmethod_mirror(nm) != NULL) {
JVMCI_THROW_MSG_0(IllegalArgumentException, "Cannot overwrite existing HotSpotNmethod mirror for nmethod");
}
oop mirror = HotSpotJVMCI::resolve(result);
data->set_mirror(nm, mirror);
oop nmethod_mirror = HotSpotJVMCI::resolve(result);
data->set_nmethod_mirror(nm, nmethod_mirror);
}
}
}
Expand Down
66 changes: 33 additions & 33 deletions src/share/vm/jvmci/jvmciRuntime.cpp
Expand Up @@ -965,16 +965,16 @@ void* JVMCINMethodData::operator new(size_t size, nmethod* nm) throw() {

JVMCINMethodData::JVMCINMethodData(
JVMCIEnv* jvmciEnv,
int mirror_index,
const char* mirror_name,
int nmethod_mirror_index,
const char* name,
FailedSpeculation** failed_speculations)
{
_failed_speculations = failed_speculations;
_mirror_index = mirror_index;
if (mirror_name != NULL) {
_nmethod_mirror_index = nmethod_mirror_index;
if (name != NULL) {
_has_name = true;
char* dest = (char*) this->mirror_name();
strcpy(dest, mirror_name);
char* dest = (char*) this->name();
strcpy(dest, name);
} else {
_has_name = false;
}
Expand All @@ -990,15 +990,15 @@ void JVMCINMethodData::add_failed_speculation(nmethod* nm, jlong speculation) {
FailedSpeculation::add_failed_speculation(nm, _failed_speculations, data, length);
}

oop JVMCINMethodData::get_mirror(nmethod* nm) {
if (_mirror_index == -1) {
oop JVMCINMethodData::get_nmethod_mirror(nmethod* nm) {
if (_nmethod_mirror_index == -1) {
return NULL;
}
return nm->oop_at(_mirror_index);
return nm->oop_at(_nmethod_mirror_index);
}

void JVMCINMethodData::set_mirror(nmethod* nm, oop new_mirror) {
oop* addr = nm->oop_addr_at(_mirror_index);
void JVMCINMethodData::set_nmethod_mirror(nmethod* nm, oop new_mirror) {
oop* addr = nm->oop_addr_at(_nmethod_mirror_index);
assert(*addr == NULL || new_mirror == NULL || *addr == new_mirror, "cannot overwrite non-null mirror");

// Patching in an oop so make sure nm is on the scavenge list.
Expand All @@ -1016,36 +1016,36 @@ void JVMCINMethodData::set_mirror(nmethod* nm, oop new_mirror) {
*addr = new_mirror;
}

void JVMCINMethodData::invalidate_mirror(nmethod* nm) {
oop mirror = get_mirror(nm);
if (mirror == NULL) {
void JVMCINMethodData::invalidate_nmethod_mirror(nmethod* nm) {
oop nmethod_mirror = get_nmethod_mirror(nm);
if (nmethod_mirror == NULL) {
return;
}

// Update the values in the mirror if it still refers to nm.
// We cannot use JVMCIObject to wrap the mirror as this is called
// during GC, forbidding the creation of JNIHandles.
JVMCIEnv* jvmciEnv = NULL;
nmethod* current = (nmethod*) HotSpotJVMCI::InstalledCode::address(jvmciEnv, mirror);
nmethod* current = (nmethod*) HotSpotJVMCI::InstalledCode::address(jvmciEnv, nmethod_mirror);
if (nm == current) {
if (!nm->is_alive()) {
// Break the link from the mirror to nm such that
// future invocations via the mirror will result in
// an InvalidInstalledCodeException.
HotSpotJVMCI::InstalledCode::set_address(jvmciEnv, mirror, 0);
HotSpotJVMCI::InstalledCode::set_entryPoint(jvmciEnv, mirror, 0);
HotSpotJVMCI::InstalledCode::set_address(jvmciEnv, nmethod_mirror, 0);
HotSpotJVMCI::InstalledCode::set_entryPoint(jvmciEnv, nmethod_mirror, 0);
} else if (nm->is_not_entrant()) {
// Zero the entry point so any new invocation will fail but keep
// the address link around that so that existing activations can
// be deoptimized via the mirror (i.e. JVMCIEnv::invalidate_installed_code).
HotSpotJVMCI::InstalledCode::set_entryPoint(jvmciEnv, mirror, 0);
HotSpotJVMCI::InstalledCode::set_entryPoint(jvmciEnv, nmethod_mirror, 0);
}
}

if (!nm->is_alive()) {
// Clear the mirror now that nm is dead and all
// relevant fields in the mirror have been zeroed.
set_mirror(nm, NULL);
set_nmethod_mirror(nm, NULL);
}
}

Expand Down Expand Up @@ -1892,7 +1892,7 @@ JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV,
bool has_unsafe_access,
bool has_wide_vector,
JVMCIObject compiled_code,
JVMCIObject mirror,
JVMCIObject nmethod_mirror,
FailedSpeculation** failed_speculations,
char* speculations,
int speculations_len) {
Expand All @@ -1902,23 +1902,23 @@ JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV,
int comp_level = CompLevel_full_optimization;
char* failure_detail = NULL;

bool install_default = JVMCIENV->get_HotSpotNmethod_isDefault(mirror) != 0;
assert(JVMCIENV->isa_HotSpotNmethod(mirror), "must be");
const char* mirror_name = NULL;
bool install_default = JVMCIENV->get_HotSpotNmethod_isDefault(nmethod_mirror) != 0;
assert(JVMCIENV->isa_HotSpotNmethod(nmethod_mirror), "must be");
const char* nmethod_mirror_name = NULL;
int jvmci_data_size = sizeof(JVMCINMethodData);
JVMCIObject name = JVMCIENV->get_InstalledCode_name(mirror);
JVMCIObject name = JVMCIENV->get_InstalledCode_name(nmethod_mirror);
if (!name.is_null()) {
mirror_name = JVMCIENV->as_utf8_string(name);
jvmci_data_size += strlen(mirror_name) + 1;
nmethod_mirror_name = JVMCIENV->as_utf8_string(name);
jvmci_data_size += (int) strlen(nmethod_mirror_name) + 1;
}
int mirror_index;
if (JVMCIENV->get_HotSpotNmethod_compileIdSnapshot(mirror) == 0) {
int nmethod_mirror_index;
if (JVMCIENV->get_HotSpotNmethod_compileIdSnapshot(nmethod_mirror) == 0) {
// Reserve or initialize mirror slot in the oops table.
OopRecorder* oop_recorder = debug_info->oop_recorder();
mirror_index = oop_recorder->allocate_oop_index(mirror.is_hotspot() ? mirror.as_jobject() : NULL);
nmethod_mirror_index = oop_recorder->allocate_oop_index(nmethod_mirror.is_hotspot() ? nmethod_mirror.as_jobject() : NULL);
} else {
// A HotSpotNmethod mirror whose compileIdSnapshot is non-zero is not tracked by the nmethod
mirror_index = -1;
nmethod_mirror_index = -1;
}

JVMCI::CodeInstallResult result;
Expand Down Expand Up @@ -1981,7 +1981,7 @@ JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV,
CompileBroker::handle_full_code_cache();
}
} else {
JVMCINMethodData* data = new (nm) JVMCINMethodData(JVMCIENV, mirror_index, mirror_name, failed_speculations);
JVMCINMethodData* data = new (nm) JVMCINMethodData(JVMCIENV, nmethod_mirror_index, nmethod_mirror_name, failed_speculations);

nm->set_has_unsafe_access(has_unsafe_access);
nm->set_has_wide_vectors(has_wide_vector);
Expand All @@ -1993,7 +1993,7 @@ JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV,
}

if (install_default) {
assert(!mirror.is_hotspot() || data->get_mirror(nm) == NULL, "must be");
assert(!nmethod_mirror.is_hotspot() || data->get_nmethod_mirror(nm) == NULL, "must be");
if (entry_bci == InvocationEntryBci) {
if (TieredCompilation) {
// If there is an old version we're done with it
Expand Down Expand Up @@ -2030,7 +2030,7 @@ JVMCI::CodeInstallResult JVMCIRuntime::register_method(JVMCIEnv* JVMCIENV,
InstanceKlass::cast(method->method_holder())->add_osr_nmethod(nm);
}
} else {
assert(!mirror.is_hotspot() || data->get_mirror(nm) == HotSpotJVMCI::resolve(mirror), "must be");
assert(!nmethod_mirror.is_hotspot() || data->get_nmethod_mirror(nm) == HotSpotJVMCI::resolve(nmethod_mirror), "must be");
}
}
result = nm != NULL ? JVMCI::ok :JVMCI::cache_full;
Expand Down
16 changes: 8 additions & 8 deletions src/share/vm/jvmci/jvmciRuntime.hpp
Expand Up @@ -41,7 +41,7 @@ class JVMCICompileState;
// at nmethod::_jvmci_data_offset.
class JVMCINMethodData VALUE_OBJ_CLASS_SPEC {
// Index for the HotSpotNmethod mirror in the nmethod's oop table.
int _mirror_index;
int _nmethod_mirror_index;

// Is HotSpotNmethod.name non-null? If so, the value is
// embedded in the end of this object.
Expand All @@ -56,25 +56,25 @@ class JVMCINMethodData VALUE_OBJ_CLASS_SPEC {
void* operator new(size_t size, nmethod* nm) throw();

JVMCINMethodData(JVMCIEnv* jvmciEnv,
int mirror_index,
int nmethod_mirror_index,
const char* name,
FailedSpeculation** failed_speculations);

// Adds `speculation` to the failed speculations list.
void add_failed_speculation(nmethod* nm, jlong speculation);

// Gets the value of HotSpotNmethod.name (which may be NULL).
const char* mirror_name() { return _has_name ? (char*)(((address) this) + sizeof(JVMCINMethodData)) : NULL; }
// Gets the JVMCI name of the nmethod (which may be NULL).
const char* name() { return _has_name ? (char*)(((address) this) + sizeof(JVMCINMethodData)) : NULL; }

// Clears the HotSpotNmethod.address field in the mirror. If nm
// is dead, the HotSpotNmethod.entryPoint field is also cleared.
void invalidate_mirror(nmethod* nm);
void invalidate_nmethod_mirror(nmethod* nm);

// Gets the mirror from nm's oops table.
oop get_mirror(nmethod* nm);
oop get_nmethod_mirror(nmethod* nm);

// Sets the mirror in nm's oops table.
void set_mirror(nmethod* nm, oop mirror);
void set_nmethod_mirror(nmethod* nm, oop mirror);
};

// A top level class that represents an initialized JVMCI runtime.
Expand Down Expand Up @@ -245,7 +245,7 @@ class JVMCIRuntime: public CHeapObj<mtCompiler> {
bool has_unsafe_access,
bool has_wide_vector,
JVMCIObject compiled_code,
JVMCIObject mirror,
JVMCIObject nmethod_mirror,
FailedSpeculation** failed_speculations,
char* speculations,
int speculations_len);
Expand Down
2 changes: 1 addition & 1 deletion src/share/vm/oops/methodData.cpp
Expand Up @@ -891,7 +891,7 @@ static void guarantee_failed_speculations_alive(nmethod* nm, FailedSpeculation**
if (method != NULL) {
method->print_name(&st);
} else {
const char* jvmci_name = nm->mirror_name();
const char* jvmci_name = nm->jvmci_name();
if (jvmci_name != NULL) {
st.print_raw(jvmci_name);
}
Expand Down
2 changes: 1 addition & 1 deletion src/share/vm/runtime/deoptimization.cpp
Expand Up @@ -1660,7 +1660,7 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* thread, jint tra
nm->method()->print_short_name(tty);
tty->print(" compiler=%s compile_id=%d", nm->compiler() == NULL ? "" : nm->compiler()->name(), nm->compile_id());
#if INCLUDE_JVMCI
const char* installed_code_name = nm->mirror_name();
const char* installed_code_name = nm->jvmci_name();
if (installed_code_name != NULL) {
tty->print(" (JVMCI: installed code name=%s) ", installed_code_name);
}
Expand Down
2 changes: 1 addition & 1 deletion src/share/vm/runtime/frame.cpp
Expand Up @@ -735,7 +735,7 @@ void frame::print_on_error(outputStream* st, char* buf, int buflen, bool verbose
((nm->compiler() != NULL) ? nm->compiler()->name() : ""),
buf, m->code_size(), _pc, _cb->code_begin(), _pc - _cb->code_begin());
#if INCLUDE_JVMCI
const char* jvmciName = nm->mirror_name();
const char* jvmciName = nm->jvmci_name();
if (jvmciName != NULL) {
st->print(" (%s)", jvmciName);
}
Expand Down

0 comments on commit c891929

Please sign in to comment.