# HG changeset patch # User rrich # Date 1564149788 -7200 # Node ID aad50831e169e8cc136c62286cc82e0bd4512039 # Parent a79a819a821804b766b56becda680710954f137b 8228618: s390: c1/c2 fail to add a metadata relocation in the static call stub. Reviewed-by: mdoerr, goetz diff -r a79a819a8218 -r aad50831e169 src/hotspot/cpu/s390/compiledIC_s390.cpp --- a/src/hotspot/cpu/s390/compiledIC_s390.cpp Mon Jul 29 13:57:54 2019 +0200 +++ b/src/hotspot/cpu/s390/compiledIC_s390.cpp Fri Jul 26 16:03:08 2019 +0200 @@ -119,7 +119,7 @@ #endif // Update stub. - method_holder->set_data((intptr_t)callee()); + method_holder->set_data((intptr_t)callee(), relocInfo::metadata_type); jump->set_jump_destination(entry); // Update jump to call. @@ -134,7 +134,7 @@ // Creation also verifies the object. NativeMovConstReg* method_holder = nativeMovConstReg_at(stub + NativeCall::get_IC_pos_in_java_to_interp_stub()); NativeJump* jump = nativeJump_at(method_holder->next_instruction_address()); - method_holder->set_data(0); + method_holder->set_data(0, relocInfo::metadata_type); jump->set_jump_destination((address)-1); } diff -r a79a819a8218 -r aad50831e169 src/hotspot/cpu/s390/macroAssembler_s390.cpp --- a/src/hotspot/cpu/s390/macroAssembler_s390.cpp Mon Jul 29 13:57:54 2019 +0200 +++ b/src/hotspot/cpu/s390/macroAssembler_s390.cpp Fri Jul 26 16:03:08 2019 +0200 @@ -5891,7 +5891,7 @@ if (tocOffset == -1) return false; address tocPos = tocOffset + code()->consts()->start(); assert((address)code()->consts()->start() != NULL, "Please add CP address"); - + relocate(a.rspec()); load_long_pcrelative(dst, tocPos); return true; } diff -r a79a819a8218 -r aad50831e169 src/hotspot/cpu/s390/nativeInst_s390.cpp --- a/src/hotspot/cpu/s390/nativeInst_s390.cpp Mon Jul 29 13:57:54 2019 +0200 +++ b/src/hotspot/cpu/s390/nativeInst_s390.cpp Fri Jul 26 16:03:08 2019 +0200 @@ -475,12 +475,42 @@ // Divided up in set_data_plain() which patches the instruction in the // code stream and set_data() which additionally patches the oop pool // if necessary. -void NativeMovConstReg::set_data(intptr_t src) { +void NativeMovConstReg::set_data(intptr_t data, relocInfo::relocType expected_type) { // Also store the value into an oop_Relocation cell, if any. CodeBlob *cb = CodeCache::find_blob(instruction_address()); - address next_address = set_data_plain(src, cb); + address next_address = set_data_plain(data, cb); - relocInfo::update_oop_pool(instruction_address(), next_address, (address)src, cb); + // 'RelocIterator' requires an nmethod + nmethod* nm = cb ? cb->as_nmethod_or_null() : NULL; + if (nm != NULL) { + RelocIterator iter(nm, instruction_address(), next_address); + oop* oop_addr = NULL; + Metadata** metadata_addr = NULL; + while (iter.next()) { + if (iter.type() == relocInfo::oop_type) { + oop_Relocation *r = iter.oop_reloc(); + if (oop_addr == NULL) { + oop_addr = r->oop_addr(); + *oop_addr = cast_to_oop(data); + } else { + assert(oop_addr == r->oop_addr(), "must be only one set-oop here"); + } + } + if (iter.type() == relocInfo::metadata_type) { + metadata_Relocation *r = iter.metadata_reloc(); + if (metadata_addr == NULL) { + metadata_addr = r->metadata_addr(); + *metadata_addr = (Metadata*)data; + } else { + assert(metadata_addr == r->metadata_addr(), "must be only one set-metadata here"); + } + } + } + assert(expected_type == relocInfo::none || + (expected_type == relocInfo::metadata_type && metadata_addr != NULL) || + (expected_type == relocInfo::oop_type && oop_addr != NULL), + "%s relocation not found", expected_type == relocInfo::oop_type ? "oop" : "metadata"); + } } void NativeMovConstReg::set_narrow_oop(intptr_t data) { @@ -510,7 +540,7 @@ ICache::invalidate_range(start, range); } -void NativeMovConstReg::set_pcrel_addr(intptr_t newTarget, CompiledMethod *passed_nm /* = NULL */, bool copy_back_to_oop_pool) { +void NativeMovConstReg::set_pcrel_addr(intptr_t newTarget, CompiledMethod *passed_nm /* = NULL */) { address next_address; address loc = addr_at(0); @@ -533,20 +563,9 @@ assert(false, "Not a NativeMovConstReg site for set_pcrel_addr"); next_address = next_instruction_address(); // Failure should be handled in next_instruction_address(). } - - if (copy_back_to_oop_pool) { - if (relocInfo::update_oop_pool(instruction_address(), next_address, (address)newTarget, NULL)) { - ((NativeMovConstReg*)instruction_address())->dump(64, "NativeMovConstReg::set_pcrel_addr(): found oop reloc for pcrel_addr"); -#ifdef LUCY_DBG - VM_Version::z_SIGSEGV(); -#else - assert(false, "Ooooops: found oop reloc for pcrel_addr"); -#endif - } - } } -void NativeMovConstReg::set_pcrel_data(intptr_t newData, CompiledMethod *passed_nm /* = NULL */, bool copy_back_to_oop_pool) { +void NativeMovConstReg::set_pcrel_data(intptr_t newData, CompiledMethod *passed_nm /* = NULL */) { address next_address; address loc = addr_at(0); @@ -573,17 +592,6 @@ assert(false, "Not a NativeMovConstReg site for set_pcrel_data"); next_address = next_instruction_address(); // Failure should be handled in next_instruction_address(). } - - if (copy_back_to_oop_pool) { - if (relocInfo::update_oop_pool(instruction_address(), next_address, (address)newData, NULL)) { - ((NativeMovConstReg*)instruction_address())->dump(64, "NativeMovConstReg::set_pcrel_data(): found oop reloc for pcrel_data"); -#ifdef LUCY_DBG - VM_Version::z_SIGSEGV(); -#else - assert(false, "Ooooops: found oop reloc for pcrel_data"); -#endif - } - } } #ifdef COMPILER1 diff -r a79a819a8218 -r aad50831e169 src/hotspot/cpu/s390/nativeInst_s390.hpp --- a/src/hotspot/cpu/s390/nativeInst_s390.hpp Mon Jul 29 13:57:54 2019 +0200 +++ b/src/hotspot/cpu/s390/nativeInst_s390.hpp Fri Jul 26 16:03:08 2019 +0200 @@ -490,13 +490,13 @@ // Patch data in code stream. address set_data_plain(intptr_t x, CodeBlob *code); // Patch data in code stream and oop pool if necessary. - void set_data(intptr_t x); + void set_data(intptr_t x, relocInfo::relocType expected_type = relocInfo::none); // Patch narrow oop constant in code stream. void set_narrow_oop(intptr_t data); void set_narrow_klass(intptr_t data); - void set_pcrel_addr(intptr_t addr, CompiledMethod *nm = NULL, bool copy_back_to_oop_pool=false); - void set_pcrel_data(intptr_t data, CompiledMethod *nm = NULL, bool copy_back_to_oop_pool=false); + void set_pcrel_addr(intptr_t addr, CompiledMethod *nm = NULL); + void set_pcrel_data(intptr_t data, CompiledMethod *nm = NULL); void verify(); diff -r a79a819a8218 -r aad50831e169 src/hotspot/cpu/s390/relocInfo_s390.cpp --- a/src/hotspot/cpu/s390/relocInfo_s390.cpp Mon Jul 29 13:57:54 2019 +0200 +++ b/src/hotspot/cpu/s390/relocInfo_s390.cpp Fri Jul 26 16:03:08 2019 +0200 @@ -164,49 +164,6 @@ } -// store the new target address into an oop_Relocation cell, if any -// return indication if update happened. -bool relocInfo::update_oop_pool(address begin, address end, address newTarget, CodeBlob* cb) { - - // Try to find the CodeBlob, if not given by caller - if (cb == NULL) cb = CodeCache::find_blob(begin); -#ifdef ASSERT - else - assert(cb == CodeCache::find_blob(begin), "consistency"); -#endif - - // 'RelocIterator' requires an nmethod - nmethod* nm = cb ? cb->as_nmethod_or_null() : NULL; - if (nm != NULL) { - RelocIterator iter(nm, begin, end); - oop* oop_addr = NULL; - Metadata** metadata_addr = NULL; - while (iter.next()) { - if (iter.type() == relocInfo::oop_type) { - oop_Relocation *r = iter.oop_reloc(); - if (oop_addr == NULL) { - oop_addr = r->oop_addr(); - *oop_addr = (oop)newTarget; - } else { - assert(oop_addr == r->oop_addr(), "must be only one set-oop here"); - } - } - if (iter.type() == relocInfo::metadata_type) { - metadata_Relocation *r = iter.metadata_reloc(); - if (metadata_addr == NULL) { - metadata_addr = r->metadata_addr(); - *metadata_addr = (Metadata*)newTarget; - } else { - assert(metadata_addr == r->metadata_addr(), "must be only one set-metadata here"); - } - } - } - return oop_addr || metadata_addr; - } - return false; -} - - address* Relocation::pd_address_in_code() { ShouldNotReachHere(); return 0; diff -r a79a819a8218 -r aad50831e169 src/hotspot/cpu/s390/relocInfo_s390.hpp --- a/src/hotspot/cpu/s390/relocInfo_s390.hpp Mon Jul 29 13:57:54 2019 +0200 +++ b/src/hotspot/cpu/s390/relocInfo_s390.hpp Fri Jul 26 16:03:08 2019 +0200 @@ -114,8 +114,4 @@ // listed in the oop section. static bool mustIterateImmediateOopsInCode() { return false; } - // Store the new target address into an oop_Relocation cell, if any. - // Return indication if update happened. - static bool update_oop_pool(address begin, address end, address newTarget, CodeBlob* cb); - #endif // CPU_S390_RELOCINFO_S390_HPP