Mercurial > hg > truffle
comparison src/cpu/x86/vm/macroAssembler_x86.cpp @ 13424:61746b5f0ed3
8028109: compiler/codecache/CheckReservedInitialCodeCacheSizeArgOrder.java crashes in RT_Baseline
Summary: Use non-relocatable code to load byte_map_base
Reviewed-by: kvn, roland
author | anoll |
---|---|
date | Wed, 04 Dec 2013 09:31:17 +0100 |
parents | be525e91f65b |
children | 02f27ecb4f3a 5292439ef895 |
comparison
equal
deleted
inserted
replaced
13423:eae426d683f6 | 13424:61746b5f0ed3 |
---|---|
3352 Address buffer(thread, in_bytes(JavaThread::dirty_card_queue_offset() + | 3352 Address buffer(thread, in_bytes(JavaThread::dirty_card_queue_offset() + |
3353 PtrQueue::byte_offset_of_buf())); | 3353 PtrQueue::byte_offset_of_buf())); |
3354 | 3354 |
3355 BarrierSet* bs = Universe::heap()->barrier_set(); | 3355 BarrierSet* bs = Universe::heap()->barrier_set(); |
3356 CardTableModRefBS* ct = (CardTableModRefBS*)bs; | 3356 CardTableModRefBS* ct = (CardTableModRefBS*)bs; |
3357 assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code"); | |
3358 | |
3357 Label done; | 3359 Label done; |
3358 Label runtime; | 3360 Label runtime; |
3359 | 3361 |
3360 // Does store cross heap regions? | 3362 // Does store cross heap regions? |
3361 | 3363 |
3369 cmpptr(new_val, (int32_t) NULL_WORD); | 3371 cmpptr(new_val, (int32_t) NULL_WORD); |
3370 jcc(Assembler::equal, done); | 3372 jcc(Assembler::equal, done); |
3371 | 3373 |
3372 // storing region crossing non-NULL, is card already dirty? | 3374 // storing region crossing non-NULL, is card already dirty? |
3373 | 3375 |
3374 ExternalAddress cardtable((address) ct->byte_map_base); | |
3375 assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code"); | |
3376 #ifdef _LP64 | |
3377 const Register card_addr = tmp; | 3376 const Register card_addr = tmp; |
3378 | 3377 const Register cardtable = tmp2; |
3379 movq(card_addr, store_addr); | 3378 |
3380 shrq(card_addr, CardTableModRefBS::card_shift); | 3379 movptr(card_addr, store_addr); |
3381 | 3380 shrptr(card_addr, CardTableModRefBS::card_shift); |
3382 lea(tmp2, cardtable); | 3381 // Do not use ExternalAddress to load 'byte_map_base', since 'byte_map_base' is NOT |
3383 | 3382 // a valid address and therefore is not properly handled by the relocation code. |
3384 // get the address of the card | 3383 movptr(cardtable, (intptr_t)ct->byte_map_base); |
3385 addq(card_addr, tmp2); | 3384 addptr(card_addr, cardtable); |
3386 #else | 3385 |
3387 const Register card_index = tmp; | |
3388 | |
3389 movl(card_index, store_addr); | |
3390 shrl(card_index, CardTableModRefBS::card_shift); | |
3391 | |
3392 Address index(noreg, card_index, Address::times_1); | |
3393 const Register card_addr = tmp; | |
3394 lea(card_addr, as_Address(ArrayAddress(cardtable, index))); | |
3395 #endif | |
3396 cmpb(Address(card_addr, 0), (int)G1SATBCardTableModRefBS::g1_young_card_val()); | 3386 cmpb(Address(card_addr, 0), (int)G1SATBCardTableModRefBS::g1_young_card_val()); |
3397 jcc(Assembler::equal, done); | 3387 jcc(Assembler::equal, done); |
3398 | 3388 |
3399 membar(Assembler::Membar_mask_bits(Assembler::StoreLoad)); | 3389 membar(Assembler::Membar_mask_bits(Assembler::StoreLoad)); |
3400 cmpb(Address(card_addr, 0), (int)CardTableModRefBS::dirty_card_val()); | 3390 cmpb(Address(card_addr, 0), (int)CardTableModRefBS::dirty_card_val()); |
3414 movslq(rscratch1, queue_index); | 3404 movslq(rscratch1, queue_index); |
3415 addq(tmp2, rscratch1); | 3405 addq(tmp2, rscratch1); |
3416 movq(Address(tmp2, 0), card_addr); | 3406 movq(Address(tmp2, 0), card_addr); |
3417 #else | 3407 #else |
3418 addl(tmp2, queue_index); | 3408 addl(tmp2, queue_index); |
3419 movl(Address(tmp2, 0), card_index); | 3409 movl(Address(tmp2, 0), card_addr); |
3420 #endif | 3410 #endif |
3421 jmp(done); | 3411 jmp(done); |
3422 | 3412 |
3423 bind(runtime); | 3413 bind(runtime); |
3424 // save the live input values | 3414 // save the live input values |
3466 CardTableModRefBS* ct = (CardTableModRefBS*)bs; | 3456 CardTableModRefBS* ct = (CardTableModRefBS*)bs; |
3467 assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code"); | 3457 assert(sizeof(*ct->byte_map_base) == sizeof(jbyte), "adjust this code"); |
3468 | 3458 |
3469 // The calculation for byte_map_base is as follows: | 3459 // The calculation for byte_map_base is as follows: |
3470 // byte_map_base = _byte_map - (uintptr_t(low_bound) >> card_shift); | 3460 // byte_map_base = _byte_map - (uintptr_t(low_bound) >> card_shift); |
3471 // So this essentially converts an address to a displacement and | 3461 // So this essentially converts an address to a displacement and it will |
3472 // it will never need to be relocated. On 64bit however the value may be too | 3462 // never need to be relocated. On 64bit however the value may be too |
3473 // large for a 32bit displacement | 3463 // large for a 32bit displacement. |
3474 | |
3475 intptr_t disp = (intptr_t) ct->byte_map_base; | 3464 intptr_t disp = (intptr_t) ct->byte_map_base; |
3476 if (is_simm32(disp)) { | 3465 if (is_simm32(disp)) { |
3477 Address cardtable(noreg, obj, Address::times_1, disp); | 3466 Address cardtable(noreg, obj, Address::times_1, disp); |
3478 movb(cardtable, 0); | 3467 movb(cardtable, 0); |
3479 } else { | 3468 } else { |
3480 // By doing it as an ExternalAddress disp could be converted to a rip-relative | 3469 // By doing it as an ExternalAddress 'disp' could be converted to a rip-relative |
3481 // displacement and done in a single instruction given favorable mapping and | 3470 // displacement and done in a single instruction given favorable mapping and a |
3482 // a smarter version of as_Address. Worst case it is two instructions which | 3471 // smarter version of as_Address. However, 'ExternalAddress' generates a relocation |
3483 // is no worse off then loading disp into a register and doing as a simple | 3472 // entry and that entry is not properly handled by the relocation code. |
3484 // Address() as above. | 3473 AddressLiteral cardtable((address)ct->byte_map_base, relocInfo::none); |
3485 // We can't do as ExternalAddress as the only style since if disp == 0 we'll | |
3486 // assert since NULL isn't acceptable in a reloci (see 6644928). In any case | |
3487 // in some cases we'll get a single instruction version. | |
3488 | |
3489 ExternalAddress cardtable((address)disp); | |
3490 Address index(noreg, obj, Address::times_1); | 3474 Address index(noreg, obj, Address::times_1); |
3491 movb(as_Address(ArrayAddress(cardtable, index)), 0); | 3475 movb(as_Address(ArrayAddress(cardtable, index)), 0); |
3492 } | 3476 } |
3493 } | 3477 } |
3494 | 3478 |