Skip to content

Commit d93dda6

Browse files
committed
Implement C1 write barrier stub
1 parent 5e14860 commit d93dda6

File tree

1 file changed

+47
-2
lines changed

1 file changed

+47
-2
lines changed

openjdk/cpu/riscv/mmtkBarrierSetAssembler_riscv.cpp

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,60 @@ void MMTkBarrierSetAssembler::eden_allocate(MacroAssembler* masm, Register obj,
138138
#define __ sasm->
139139

140140
void MMTkBarrierSetAssembler::generate_c1_write_barrier_runtime_stub(StubAssembler* sasm) const {
141-
// assert(false, "Not implemented");
141+
// printf("xxx MMTkBarrierSetAssembler::generate_c1_write_barrier_runtime_stub\n");
142+
// See also void G1BarrierSetAssembler::generate_c1_post_barrier_runtime_stub(StubAssembler* sasm)
143+
__ prologue("mmtk_write_barrier", false);
144+
145+
Label done, runtime;
146+
147+
// void C1_MacroAssembler::load_parameter(int offset_in_words, Register reg)
148+
// ld(reg, Address(fp, offset_in_words * BytesPerWord));
149+
// ra is free to use here, because calll prologue/epilogue handles it
150+
const Register src = t0;
151+
const Register slot = t1;
152+
const Register new_val = ra;
153+
__ load_parameter(0, src);
154+
__ load_parameter(1, slot);
155+
__ load_parameter(2, new_val);
156+
157+
__ bind(runtime);
158+
159+
// Push integer registers x7, x10-x17, x28-x31.
160+
// t2, a0-a7, t3-t6
161+
__ push_call_clobbered_registers();
162+
163+
#if MMTK_ENABLE_BARRIER_FASTPATH
164+
__ call_VM_leaf(FN_ADDR(MMTkBarrierSetRuntime::object_reference_write_slow_call), src, slot, new_val);
165+
#else
166+
__ call_VM_leaf(FN_ADDR(MMTkBarrierSetRuntime::object_reference_write_post_call), src, slot, new_val);
167+
#endif
168+
169+
__ pop_call_clobbered_registers();
170+
171+
__ bind(done);
172+
173+
__ epilogue();
142174
}
143175

144176
#undef __
145177

146178
#define __ ce->masm()->
147179

148180
void MMTkBarrierSetAssembler::generate_c1_write_barrier_stub_call(LIR_Assembler* ce, MMTkC1BarrierStub* stub) {
149-
// assert(false, "Not implemented");
181+
// printf("xxx MMTkBarrierSetAssembler::generate_c1_write_barrier_stub_call\n");
182+
// See also void G1BarrierSetAssembler::gen_post_barrier_stub(LIR_Assembler* ce, G1PostBarrierStub* stub)
183+
MMTkBarrierSetC1* bs = (MMTkBarrierSetC1*) BarrierSet::barrier_set()->barrier_set_c1();
184+
__ bind(*stub->entry());
185+
assert(stub->src->is_register(), "Precondition");
186+
assert(stub->slot->is_register(), "Precondition");
187+
assert(stub->new_val->is_register(), "Precondition");
188+
// LIR_Assembler::store_parameter(Register r, int offset_from_rsp_in_words)
189+
// __ sd(r, Address(sp, offset_from_rsp_in_bytes));
190+
ce->store_parameter(stub->src->as_pointer_register(), 0);
191+
ce->store_parameter(stub->slot->as_pointer_register(), 1);
192+
ce->store_parameter(stub->new_val->as_pointer_register(), 2);
193+
__ far_call(RuntimeAddress(bs->_write_barrier_c1_runtime_code_blob->code_begin()));
194+
__ j(*stub->continuation());
150195
}
151196

152197
#undef __

0 commit comments

Comments
 (0)