8256406: G1 x86 C1/Interpreter post write barrier always uses 32 bit to access variable sized PtrQueue::_index

Reviewed-by: shade
This commit is contained in:
Thomas Schatzl 2020-11-20 11:09:07 +00:00
parent f57662874a
commit a25fb0356a
2 changed files with 14 additions and 13 deletions

View File

@ -32,6 +32,7 @@
#include "gc/g1/heapRegion.hpp"
#include "interpreter/interp_masm.hpp"
#include "runtime/sharedRuntime.hpp"
#include "utilities/debug.hpp"
#include "utilities/macros.hpp"
#ifdef COMPILER1
#include "c1/c1_LIRAssembler.hpp"
@ -264,6 +265,8 @@ void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm,
Register thread,
Register tmp,
Register tmp2) {
// Generated code assumes that buffer index is pointer sized.
STATIC_ASSERT(in_bytes(SATBMarkQueue::byte_width_of_index()) == sizeof(intptr_t));
#ifdef _LP64
assert(thread == r15_thread, "must be");
#endif // _LP64
@ -314,18 +317,13 @@ void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm,
__ movb(Address(card_addr, 0), (int)G1CardTable::dirty_card_val());
__ cmpl(queue_index, 0);
__ jcc(Assembler::equal, runtime);
__ subl(queue_index, wordSize);
__ movptr(tmp2, buffer);
#ifdef _LP64
__ movslq(rscratch1, queue_index);
__ addq(tmp2, rscratch1);
__ movq(Address(tmp2, 0), card_addr);
#else
__ addl(tmp2, queue_index);
__ movl(Address(tmp2, 0), card_addr);
#endif
__ movptr(tmp2, queue_index);
__ testptr(tmp2, tmp2);
__ jcc(Assembler::zero, runtime);
__ subptr(tmp2, wordSize);
__ movptr(queue_index, tmp2);
__ addptr(tmp2, buffer);
__ movptr(Address(tmp2, 0), card_addr);
__ jmp(done);
__ bind(runtime);
@ -453,6 +451,9 @@ void G1BarrierSetAssembler::gen_post_barrier_stub(LIR_Assembler* ce, G1PostBarri
#define __ sasm->
void G1BarrierSetAssembler::generate_c1_pre_barrier_runtime_stub(StubAssembler* sasm) {
// Generated code assumes that buffer index is pointer sized.
STATIC_ASSERT(in_bytes(SATBMarkQueue::byte_width_of_index()) == sizeof(intptr_t));
__ prologue("g1_pre_barrier", false);
// arg0 : previous value of memory

View File

@ -178,7 +178,7 @@ protected:
return byte_offset_of(Derived, _index);
}
static ByteSize byte_width_of_index() { return in_ByteSize(sizeof(size_t)); }
static constexpr ByteSize byte_width_of_index() { return in_ByteSize(sizeof(size_t)); }
template<typename Derived>
static ByteSize byte_offset_of_buf() {