comparison src/cpu/x86/vm/assembler_x86.cpp @ 2404:b40d4fa697bf

6964776: c2 should ensure the polling page is reachable on 64 bit Summary: Materialize the pointer to the polling page in a register instead of using rip-relative addressing when the distance from the code cache is larger than disp32. Reviewed-by: never, kvn
author iveresov
date Sun, 27 Mar 2011 13:17:37 -0700
parents 8033953d67ff
children 09f96c3ff1ad
comparison
equal deleted inserted replaced
2403:1927db75dd85 2404:b40d4fa697bf
3508 // For external_word_type/runtime_call_type if it is reachable from where we 3508 // For external_word_type/runtime_call_type if it is reachable from where we
3509 // are now (possibly a temp buffer) and where we might end up 3509 // are now (possibly a temp buffer) and where we might end up
3510 // anywhere in the codeCache then we are always reachable. 3510 // anywhere in the codeCache then we are always reachable.
3511 // This would have to change if we ever save/restore shared code 3511 // This would have to change if we ever save/restore shared code
3512 // to be more pessimistic. 3512 // to be more pessimistic.
3513
3514 disp = (int64_t)adr._target - ((int64_t)CodeCache::low_bound() + sizeof(int)); 3513 disp = (int64_t)adr._target - ((int64_t)CodeCache::low_bound() + sizeof(int));
3515 if (!is_simm32(disp)) return false; 3514 if (!is_simm32(disp)) return false;
3516 disp = (int64_t)adr._target - ((int64_t)CodeCache::high_bound() + sizeof(int)); 3515 disp = (int64_t)adr._target - ((int64_t)CodeCache::high_bound() + sizeof(int));
3517 if (!is_simm32(disp)) return false; 3516 if (!is_simm32(disp)) return false;
3518 3517
3530 disp -= fudge; 3529 disp -= fudge;
3531 } else { 3530 } else {
3532 disp += fudge; 3531 disp += fudge;
3533 } 3532 }
3534 return is_simm32(disp); 3533 return is_simm32(disp);
3534 }
3535
3536 // Check if the polling page is not reachable from the code cache using rip-relative
3537 // addressing.
3538 bool Assembler::is_polling_page_far() {
3539 intptr_t addr = (intptr_t)os::get_polling_page();
3540 return !is_simm32(addr - (intptr_t)CodeCache::low_bound()) ||
3541 !is_simm32(addr - (intptr_t)CodeCache::high_bound());
3535 } 3542 }
3536 3543
3537 void Assembler::emit_data64(jlong data, 3544 void Assembler::emit_data64(jlong data,
3538 relocInfo::relocType rtype, 3545 relocInfo::relocType rtype,
3539 int format) { 3546 int format) {
6884 shll(reg, 16); 6891 shll(reg, 16);
6885 sarl(reg, 16); 6892 sarl(reg, 16);
6886 } 6893 }
6887 } 6894 }
6888 6895
6896 void MacroAssembler::testl(Register dst, AddressLiteral src) {
6897 assert(reachable(src), "Address should be reachable");
6898 testl(dst, as_Address(src));
6899 }
6900
6889 ////////////////////////////////////////////////////////////////////////////////// 6901 //////////////////////////////////////////////////////////////////////////////////
6890 #ifndef SERIALGC 6902 #ifndef SERIALGC
6891 6903
6892 void MacroAssembler::g1_write_barrier_pre(Register obj, 6904 void MacroAssembler::g1_write_barrier_pre(Register obj,
6893 #ifndef _LP64 6905 #ifndef _LP64
7119 7131
7120 void MacroAssembler::subptr(Register dst, Register src) { 7132 void MacroAssembler::subptr(Register dst, Register src) {
7121 LP64_ONLY(subq(dst, src)) NOT_LP64(subl(dst, src)); 7133 LP64_ONLY(subq(dst, src)) NOT_LP64(subl(dst, src));
7122 } 7134 }
7123 7135
7124 void MacroAssembler::test32(Register src1, AddressLiteral src2) {
7125 // src2 must be rval
7126
7127 if (reachable(src2)) {
7128 testl(src1, as_Address(src2));
7129 } else {
7130 lea(rscratch1, src2);
7131 testl(src1, Address(rscratch1, 0));
7132 }
7133 }
7134
7135 // C++ bool manipulation 7136 // C++ bool manipulation
7136 void MacroAssembler::testbool(Register dst) { 7137 void MacroAssembler::testbool(Register dst) {
7137 if(sizeof(bool) == 1) 7138 if(sizeof(bool) == 1)
7138 testb(dst, 0xff); 7139 testb(dst, 0xff);
7139 else if(sizeof(bool) == 2) { 7140 else if(sizeof(bool) == 2) {