8228618: s390: c1/c2 fail to add a metadata relocation in the static call stub

Reviewed-by: mdoerr, goetz
This commit is contained in:
Richard Reingruber 2019-07-26 16:03:08 +02:00
parent a42636d34b
commit a24a333cfd
6 changed files with 41 additions and 80 deletions

View File

@ -119,7 +119,7 @@ void CompiledDirectStaticCall::set_to_interpreted(const methodHandle& callee, ad
#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 @@ void CompiledDirectStaticCall::set_stub_to_clean(static_stub_Relocation* static_
// 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);
}

View File

@ -5891,7 +5891,7 @@ bool MacroAssembler::load_const_from_toc(Register dst, AddressLiteral& a, Regist
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;
}

View File

@ -475,12 +475,42 @@ address NativeMovConstReg::set_data_plain(intptr_t src, CodeBlob *cb) {
// 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 @@ void NativeMovConstReg::set_narrow_klass(intptr_t data) {
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 @@ void NativeMovConstReg::set_pcrel_addr(intptr_t newTarget, CompiledMethod *passe
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 @@ void NativeMovConstReg::set_pcrel_data(intptr_t newData, CompiledMethod *passed_
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

View File

@ -490,13 +490,13 @@ class NativeMovConstReg: public NativeInstruction {
// 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();

View File

@ -164,49 +164,6 @@ void Relocation::pd_set_call_destination(address x) {
}
// 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;

View File

@ -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