提交 f8c2fddd 编写于 作者: A anoll

8028109: compiler/codecache/CheckReservedInitialCodeCacheSizeArgOrder.java crashes in RT_Baseline

Summary: Use non-relocatable code to load byte_map_base
Reviewed-by: kvn, roland
上级 8b279847
...@@ -1719,10 +1719,12 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { ...@@ -1719,10 +1719,12 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) {
BarrierSet* bs = Universe::heap()->barrier_set(); BarrierSet* bs = Universe::heap()->barrier_set();
CardTableModRefBS* ct = (CardTableModRefBS*)bs; CardTableModRefBS* ct = (CardTableModRefBS*)bs;
assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code");
Label done; Label done;
Label runtime; Label runtime;
// At this point we know new_value is non-NULL and the new_value crosses regsion. // At this point we know new_value is non-NULL and the new_value crosses regions.
// Must check to see if card is already dirty // Must check to see if card is already dirty
const Register thread = NOT_LP64(rax) LP64_ONLY(r15_thread); const Register thread = NOT_LP64(rax) LP64_ONLY(r15_thread);
...@@ -1735,26 +1737,17 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { ...@@ -1735,26 +1737,17 @@ OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) {
__ push(rax); __ push(rax);
__ push(rcx); __ push(rcx);
NOT_LP64(__ get_thread(thread);) const Register cardtable = rax;
ExternalAddress cardtable((address)ct->byte_map_base);
assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code");
const Register card_addr = rcx; const Register card_addr = rcx;
#ifdef _LP64
const Register tmp = rscratch1;
f.load_argument(0, card_addr); f.load_argument(0, card_addr);
__ shrq(card_addr, CardTableModRefBS::card_shift); __ shrptr(card_addr, CardTableModRefBS::card_shift);
__ lea(tmp, cardtable); // Do not use ExternalAddress to load 'byte_map_base', since 'byte_map_base' is NOT
// get the address of the card // a valid address and therefore is not properly handled by the relocation code.
__ addq(card_addr, tmp); __ movptr(cardtable, (intptr_t)ct->byte_map_base);
#else __ addptr(card_addr, cardtable);
const Register card_index = rcx;
f.load_argument(0, card_index);
__ shrl(card_index, CardTableModRefBS::card_shift);
Address index(noreg, card_index, Address::times_1); NOT_LP64(__ get_thread(thread);)
__ leal(card_addr, __ as_Address(ArrayAddress(cardtable, index)));
#endif
__ cmpb(Address(card_addr, 0), (int)G1SATBCardTableModRefBS::g1_young_card_val()); __ cmpb(Address(card_addr, 0), (int)G1SATBCardTableModRefBS::g1_young_card_val());
__ jcc(Assembler::equal, done); __ jcc(Assembler::equal, done);
......
...@@ -3354,6 +3354,8 @@ void MacroAssembler::g1_write_barrier_post(Register store_addr, ...@@ -3354,6 +3354,8 @@ void MacroAssembler::g1_write_barrier_post(Register store_addr,
BarrierSet* bs = Universe::heap()->barrier_set(); BarrierSet* bs = Universe::heap()->barrier_set();
CardTableModRefBS* ct = (CardTableModRefBS*)bs; CardTableModRefBS* ct = (CardTableModRefBS*)bs;
assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code");
Label done; Label done;
Label runtime; Label runtime;
...@@ -3371,28 +3373,16 @@ void MacroAssembler::g1_write_barrier_post(Register store_addr, ...@@ -3371,28 +3373,16 @@ void MacroAssembler::g1_write_barrier_post(Register store_addr,
// storing region crossing non-NULL, is card already dirty? // storing region crossing non-NULL, is card already dirty?
ExternalAddress cardtable((address) ct->byte_map_base);
assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code");
#ifdef _LP64
const Register card_addr = tmp; const Register card_addr = tmp;
const Register cardtable = tmp2;
movq(card_addr, store_addr); movptr(card_addr, store_addr);
shrq(card_addr, CardTableModRefBS::card_shift); shrptr(card_addr, CardTableModRefBS::card_shift);
// Do not use ExternalAddress to load 'byte_map_base', since 'byte_map_base' is NOT
lea(tmp2, cardtable); // a valid address and therefore is not properly handled by the relocation code.
movptr(cardtable, (intptr_t)ct->byte_map_base);
addptr(card_addr, cardtable);
// get the address of the card
addq(card_addr, tmp2);
#else
const Register card_index = tmp;
movl(card_index, store_addr);
shrl(card_index, CardTableModRefBS::card_shift);
Address index(noreg, card_index, Address::times_1);
const Register card_addr = tmp;
lea(card_addr, as_Address(ArrayAddress(cardtable, index)));
#endif
cmpb(Address(card_addr, 0), (int)G1SATBCardTableModRefBS::g1_young_card_val()); cmpb(Address(card_addr, 0), (int)G1SATBCardTableModRefBS::g1_young_card_val());
jcc(Assembler::equal, done); jcc(Assembler::equal, done);
...@@ -3416,7 +3406,7 @@ void MacroAssembler::g1_write_barrier_post(Register store_addr, ...@@ -3416,7 +3406,7 @@ void MacroAssembler::g1_write_barrier_post(Register store_addr,
movq(Address(tmp2, 0), card_addr); movq(Address(tmp2, 0), card_addr);
#else #else
addl(tmp2, queue_index); addl(tmp2, queue_index);
movl(Address(tmp2, 0), card_index); movl(Address(tmp2, 0), card_addr);
#endif #endif
jmp(done); jmp(done);
...@@ -3468,25 +3458,19 @@ void MacroAssembler::store_check_part_2(Register obj) { ...@@ -3468,25 +3458,19 @@ void MacroAssembler::store_check_part_2(Register obj) {
// The calculation for byte_map_base is as follows: // The calculation for byte_map_base is as follows:
// byte_map_base = _byte_map - (uintptr_t(low_bound) >> card_shift); // byte_map_base = _byte_map - (uintptr_t(low_bound) >> card_shift);
// So this essentially converts an address to a displacement and // So this essentially converts an address to a displacement and it will
// it will never need to be relocated. On 64bit however the value may be too // never need to be relocated. On 64bit however the value may be too
// large for a 32bit displacement // large for a 32bit displacement.
intptr_t disp = (intptr_t) ct->byte_map_base; intptr_t disp = (intptr_t) ct->byte_map_base;
if (is_simm32(disp)) { if (is_simm32(disp)) {
Address cardtable(noreg, obj, Address::times_1, disp); Address cardtable(noreg, obj, Address::times_1, disp);
movb(cardtable, 0); movb(cardtable, 0);
} else { } else {
// By doing it as an ExternalAddress disp could be converted to a rip-relative // By doing it as an ExternalAddress 'disp' could be converted to a rip-relative
// displacement and done in a single instruction given favorable mapping and // displacement and done in a single instruction given favorable mapping and a
// a smarter version of as_Address. Worst case it is two instructions which // smarter version of as_Address. However, 'ExternalAddress' generates a relocation
// is no worse off then loading disp into a register and doing as a simple // entry and that entry is not properly handled by the relocation code.
// Address() as above. AddressLiteral cardtable((address)ct->byte_map_base, relocInfo::none);
// We can't do as ExternalAddress as the only style since if disp == 0 we'll
// assert since NULL isn't acceptable in a reloci (see 6644928). In any case
// in some cases we'll get a single instruction version.
ExternalAddress cardtable((address)disp);
Address index(noreg, obj, Address::times_1); Address index(noreg, obj, Address::times_1);
movb(as_Address(ArrayAddress(cardtable, index)), 0); movb(as_Address(ArrayAddress(cardtable, index)), 0);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册