From c891929e3dcd61c3fe44dfbaf66fe68f65e23673 Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Thu, 28 Feb 2019 15:20:58 +0100 Subject: [PATCH] revert to "nmethod_mirror" naming convention --- hotspot/.project | 2 +- src/share/vm/code/nmethod.cpp | 8 +-- src/share/vm/code/nmethod.hpp | 4 +- src/share/vm/compiler/disassembler.cpp | 2 +- src/share/vm/jvmci/jvmciCompilerToVM.cpp | 29 ++++++----- src/share/vm/jvmci/jvmciRuntime.cpp | 66 ++++++++++++------------ src/share/vm/jvmci/jvmciRuntime.hpp | 16 +++--- src/share/vm/oops/methodData.cpp | 2 +- src/share/vm/runtime/deoptimization.cpp | 2 +- src/share/vm/runtime/frame.cpp | 2 +- 10 files changed, 67 insertions(+), 66 deletions(-) diff --git a/hotspot/.project b/hotspot/.project index 63e22fc01e..26ab49c722 100644 --- a/hotspot/.project +++ b/hotspot/.project @@ -7,7 +7,7 @@ org.eclipse.cdt.managedbuilder.core.genmakebuilder - + auto, ?children? diff --git a/src/share/vm/code/nmethod.cpp b/src/share/vm/code/nmethod.cpp index f592330963..dbec52b667 100644 --- a/src/share/vm/code/nmethod.cpp +++ b/src/share/vm/code/nmethod.cpp @@ -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); @@ -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); } } @@ -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; } diff --git a/src/share/vm/code/nmethod.hpp b/src/share/vm/code/nmethod.hpp index bd7f1dd5ba..25e92b8b3b 100644 --- a/src/share/vm/code/nmethod.hpp +++ b/src/share/vm/code/nmethod.hpp @@ -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 diff --git a/src/share/vm/compiler/disassembler.cpp b/src/share/vm/compiler/disassembler.cpp index bf53fc3991..5500f3ef07 100644 --- a/src/share/vm/compiler/disassembler.cpp +++ b/src/share/vm/compiler/disassembler.cpp @@ -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); } diff --git a/src/share/vm/jvmci/jvmciCompilerToVM.cpp b/src/share/vm/jvmci/jvmciCompilerToVM.cpp index 4d31060c74..af1928be0b 100644 --- a/src/share/vm/jvmci/jvmciCompilerToVM.cpp +++ b/src/share/vm/jvmci/jvmciCompilerToVM.cpp @@ -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"); } @@ -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); } @@ -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)) @@ -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); } } } @@ -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); } } } diff --git a/src/share/vm/jvmci/jvmciRuntime.cpp b/src/share/vm/jvmci/jvmciRuntime.cpp index 13ef5d97d0..46492234e3 100644 --- a/src/share/vm/jvmci/jvmciRuntime.cpp +++ b/src/share/vm/jvmci/jvmciRuntime.cpp @@ -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; } @@ -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. @@ -1016,9 +1016,9 @@ 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; } @@ -1026,26 +1026,26 @@ void JVMCINMethodData::invalidate_mirror(nmethod* 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); } } @@ -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) { @@ -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; @@ -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); @@ -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 @@ -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; diff --git a/src/share/vm/jvmci/jvmciRuntime.hpp b/src/share/vm/jvmci/jvmciRuntime.hpp index 5512e4f602..63f9f673b2 100644 --- a/src/share/vm/jvmci/jvmciRuntime.hpp +++ b/src/share/vm/jvmci/jvmciRuntime.hpp @@ -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. @@ -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. @@ -245,7 +245,7 @@ class JVMCIRuntime: public CHeapObj { bool has_unsafe_access, bool has_wide_vector, JVMCIObject compiled_code, - JVMCIObject mirror, + JVMCIObject nmethod_mirror, FailedSpeculation** failed_speculations, char* speculations, int speculations_len); diff --git a/src/share/vm/oops/methodData.cpp b/src/share/vm/oops/methodData.cpp index cfce87c08f..270d626b95 100644 --- a/src/share/vm/oops/methodData.cpp +++ b/src/share/vm/oops/methodData.cpp @@ -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); } diff --git a/src/share/vm/runtime/deoptimization.cpp b/src/share/vm/runtime/deoptimization.cpp index 816d5476c0..b69c279052 100644 --- a/src/share/vm/runtime/deoptimization.cpp +++ b/src/share/vm/runtime/deoptimization.cpp @@ -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); } diff --git a/src/share/vm/runtime/frame.cpp b/src/share/vm/runtime/frame.cpp index b86f03a921..38aed3dc2a 100644 --- a/src/share/vm/runtime/frame.cpp +++ b/src/share/vm/runtime/frame.cpp @@ -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); }