1.1 --- a/src/cpu/x86/vm/macroAssembler_x86.cpp Mon Dec 02 11:12:32 2013 +0100 1.2 +++ b/src/cpu/x86/vm/macroAssembler_x86.cpp Wed Dec 04 09:31:17 2013 +0100 1.3 @@ -3354,6 +3354,8 @@ 1.4 1.5 BarrierSet* bs = Universe::heap()->barrier_set(); 1.6 CardTableModRefBS* ct = (CardTableModRefBS*)bs; 1.7 + assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code"); 1.8 + 1.9 Label done; 1.10 Label runtime; 1.11 1.12 @@ -3371,28 +3373,16 @@ 1.13 1.14 // storing region crossing non-NULL, is card already dirty? 1.15 1.16 - ExternalAddress cardtable((address) ct->byte_map_base); 1.17 - assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code"); 1.18 -#ifdef _LP64 1.19 const Register card_addr = tmp; 1.20 - 1.21 - movq(card_addr, store_addr); 1.22 - shrq(card_addr, CardTableModRefBS::card_shift); 1.23 - 1.24 - lea(tmp2, cardtable); 1.25 - 1.26 - // get the address of the card 1.27 - addq(card_addr, tmp2); 1.28 -#else 1.29 - const Register card_index = tmp; 1.30 - 1.31 - movl(card_index, store_addr); 1.32 - shrl(card_index, CardTableModRefBS::card_shift); 1.33 - 1.34 - Address index(noreg, card_index, Address::times_1); 1.35 - const Register card_addr = tmp; 1.36 - lea(card_addr, as_Address(ArrayAddress(cardtable, index))); 1.37 -#endif 1.38 + const Register cardtable = tmp2; 1.39 + 1.40 + movptr(card_addr, store_addr); 1.41 + shrptr(card_addr, CardTableModRefBS::card_shift); 1.42 + // Do not use ExternalAddress to load 'byte_map_base', since 'byte_map_base' is NOT 1.43 + // a valid address and therefore is not properly handled by the relocation code. 1.44 + movptr(cardtable, (intptr_t)ct->byte_map_base); 1.45 + addptr(card_addr, cardtable); 1.46 + 1.47 cmpb(Address(card_addr, 0), (int)G1SATBCardTableModRefBS::g1_young_card_val()); 1.48 jcc(Assembler::equal, done); 1.49 1.50 @@ -3416,7 +3406,7 @@ 1.51 movq(Address(tmp2, 0), card_addr); 1.52 #else 1.53 addl(tmp2, queue_index); 1.54 - movl(Address(tmp2, 0), card_index); 1.55 + movl(Address(tmp2, 0), card_addr); 1.56 #endif 1.57 jmp(done); 1.58 1.59 @@ -3468,25 +3458,19 @@ 1.60 1.61 // The calculation for byte_map_base is as follows: 1.62 // byte_map_base = _byte_map - (uintptr_t(low_bound) >> card_shift); 1.63 - // So this essentially converts an address to a displacement and 1.64 - // it will never need to be relocated. On 64bit however the value may be too 1.65 - // large for a 32bit displacement 1.66 - 1.67 + // So this essentially converts an address to a displacement and it will 1.68 + // never need to be relocated. On 64bit however the value may be too 1.69 + // large for a 32bit displacement. 1.70 intptr_t disp = (intptr_t) ct->byte_map_base; 1.71 if (is_simm32(disp)) { 1.72 Address cardtable(noreg, obj, Address::times_1, disp); 1.73 movb(cardtable, 0); 1.74 } else { 1.75 - // By doing it as an ExternalAddress disp could be converted to a rip-relative 1.76 - // displacement and done in a single instruction given favorable mapping and 1.77 - // a smarter version of as_Address. Worst case it is two instructions which 1.78 - // is no worse off then loading disp into a register and doing as a simple 1.79 - // Address() as above. 1.80 - // We can't do as ExternalAddress as the only style since if disp == 0 we'll 1.81 - // assert since NULL isn't acceptable in a reloci (see 6644928). In any case 1.82 - // in some cases we'll get a single instruction version. 1.83 - 1.84 - ExternalAddress cardtable((address)disp); 1.85 + // By doing it as an ExternalAddress 'disp' could be converted to a rip-relative 1.86 + // displacement and done in a single instruction given favorable mapping and a 1.87 + // smarter version of as_Address. However, 'ExternalAddress' generates a relocation 1.88 + // entry and that entry is not properly handled by the relocation code. 1.89 + AddressLiteral cardtable((address)ct->byte_map_base, relocInfo::none); 1.90 Address index(noreg, obj, Address::times_1); 1.91 movb(as_Address(ArrayAddress(cardtable, index)), 0); 1.92 }