Skip to content

Commit 5bb7f8b

Browse files
Yadong WangRealFYang
authored andcommitted
8277890: riscv: fix the infinite LR/SC loop in BarrierSetAssembler::eden_allocate
Reviewed-by: fyang
1 parent 1101c14 commit 5bb7f8b

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -176,14 +176,24 @@ void BarrierSetAssembler::eden_allocate(MacroAssembler* masm, Register obj,
176176
} else {
177177
Register end = tmp1;
178178
Label retry;
179-
int32_t offset = 0;
180179
__ bind(retry);
181180

181+
// Get the current end of the heap
182+
ExternalAddress address_end((address) Universe::heap()->end_addr());
183+
{
184+
int32_t offset;
185+
__ la_patchable(t1, address_end, offset);
186+
__ ld(t1, Address(t1, offset));
187+
}
188+
182189
// Get the current top of the heap
183190
ExternalAddress address_top((address) Universe::heap()->top_addr());
184-
__ la_patchable(t0, address_top, offset);
185-
__ addi(t0, t0, offset);
186-
__ lr_d(obj, t0, Assembler::aqrl);
191+
{
192+
int32_t offset;
193+
__ la_patchable(t0, address_top, offset);
194+
__ addi(t0, t0, offset);
195+
__ lr_d(obj, t0, Assembler::aqrl);
196+
}
187197

188198
// Adjust it my the size of our new object
189199
if (var_size_in_bytes == noreg) {
@@ -195,18 +205,12 @@ void BarrierSetAssembler::eden_allocate(MacroAssembler* masm, Register obj,
195205
// if end < obj then we wrapped around high memory
196206
__ bltu(end, obj, slow_case, is_far);
197207

198-
Register heap_end = t1;
199-
// Get the current end of the heap
200-
ExternalAddress address_end((address) Universe::heap()->end_addr());
201-
offset = 0;
202-
__ la_patchable(heap_end, address_end, offset);
203-
__ ld(heap_end, Address(heap_end, offset));
204-
205-
__ bgtu(end, heap_end, slow_case, is_far);
208+
__ bgtu(end, t1, slow_case, is_far);
206209

207210
// If heap_top hasn't been changed by some other thread, update it.
208211
__ sc_d(t1, end, t0, Assembler::rl);
209212
__ bnez(t1, retry);
213+
210214
incr_allocated_bytes(masm, var_size_in_bytes, con_size_in_bytes, tmp1);
211215
}
212216
}

0 commit comments

Comments
 (0)