Skip to content
Permalink
Browse files
8272566: [lworld] [AArch64] G1 write barrier slow path needs to save …
…more registers

Reviewed-by: thartmann
  • Loading branch information
nick-arm authored and TobiHartmann committed Aug 18, 2021
1 parent 9c2af85 commit b0219dc830456e44c1dece77c98661a72e80e8d9
Showing with 44 additions and 9 deletions.
  1. +38 −7 src/hotspot/cpu/aarch64/gc/g1/g1BarrierSetAssembler_aarch64.cpp
  2. +6 −2 src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp
@@ -154,12 +154,26 @@ void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm,
__ b(done);

__ bind(runtime);

// save the live input values
RegSet saved = RegSet::of(pre_val);
FloatRegSet fsaved;
if (tosca_live) saved += RegSet::of(r0);
if (obj != noreg) saved += RegSet::of(obj);

// Barriers might be emitted when converting between (scalarized) calling
// conventions for inline types. Save all argument registers before calling
// into the runtime.
if (EnableValhalla && InlineTypePassFieldsAsArgs) {
saved += RegSet::of(j_rarg0, j_rarg1, j_rarg2, j_rarg3);
saved += RegSet::of(j_rarg4, j_rarg5, j_rarg6, j_rarg7);

fsaved += FloatRegSet::of(j_farg0, j_farg1, j_farg2, j_farg3);
fsaved += FloatRegSet::of(j_farg4, j_farg5, j_farg6, j_farg7);
}

__ push(saved, sp);
__ push_fp(fsaved, sp);

// Calling the runtime using the regular call_VM_leaf mechanism generates
// code (generated by InterpreterMacroAssember::call_VM_leaf_base)
@@ -180,6 +194,7 @@ void G1BarrierSetAssembler::g1_write_barrier_pre(MacroAssembler* masm,
__ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_pre_entry), pre_val, thread);
}

__ pop_fp(fsaved, sp);
__ pop(saved, sp);

__ bind(done);
@@ -254,10 +269,26 @@ void G1BarrierSetAssembler::g1_write_barrier_post(MacroAssembler* masm,
__ b(done);

__ bind(runtime);

// save the live input values
RegSet saved = RegSet::of(store_addr);
FloatRegSet fsaved;

// Barriers might be emitted when converting between (scalarized) calling
// conventions for inline types. Save all argument registers before calling
// into the runtime.
if (EnableValhalla && InlineTypePassFieldsAsArgs) {
saved += RegSet::of(j_rarg0, j_rarg1, j_rarg2, j_rarg3);
saved += RegSet::of(j_rarg4, j_rarg5, j_rarg6, j_rarg7);

fsaved += FloatRegSet::of(j_farg0, j_farg1, j_farg2, j_farg3);
fsaved += FloatRegSet::of(j_farg4, j_farg5, j_farg6, j_farg7);
}

__ push(saved, sp);
__ push_fp(fsaved, sp);
__ call_VM_leaf(CAST_FROM_FN_PTR(address, G1BarrierSetRuntime::write_ref_field_post_entry), card_addr, thread);
__ pop_fp(fsaved, sp);
__ pop(saved, sp);

__ bind(done);
@@ -311,13 +342,13 @@ void G1BarrierSetAssembler::oop_store_at(MacroAssembler* masm, DecoratorSet deco
}

if (needs_pre_barrier) {
g1_write_barrier_pre(masm,
tmp1 /* obj */,
tmp2 /* pre_val */,
rthread /* thread */,
tmp3 /* tmp */,
val != noreg /* tosca_live */,
false /* expand_call */);
g1_write_barrier_pre(masm,
tmp1 /* obj */,
tmp2 /* pre_val */,
rthread /* thread */,
tmp3 /* tmp */,
val != noreg /* tosca_live */,
false /* expand_call */);
}

if (val == noreg) {
@@ -5742,8 +5742,12 @@ bool MacroAssembler::pack_inline_helper(const GrowableArray<SigEntry>* sig, int&
return true; // Already written
}

Register val_obj_tmp = r11;
Register from_reg_tmp = r10;
// The GC barrier expanded by store_heap_oop below may call into the
// runtime so use callee-saved registers for any values that need to be
// preserved. The GC barrier assembler should take care of saving the
// Java argument registers.
Register val_obj_tmp = r21;
Register from_reg_tmp = r22;
Register tmp1 = r14;
Register tmp2 = r13;
Register tmp3 = r12;

0 comments on commit b0219dc

Please sign in to comment.