Skip to content
Permalink
Browse files
8274795: AArch64: avoid spilling and restoring r18 in macro assembler
Reviewed-by: aph
Backport-of: ede3f4e94c752a8457b7c24e001bd122845d2f6a
  • Loading branch information
lewurm authored and Vladimir Kempik committed Jan 21, 2022
1 parent 914d48c commit b5cae5738155561dfa4b41fc9382d8a7376b093e
Showing 2 changed files with 21 additions and 6 deletions.
@@ -2040,11 +2040,17 @@ void MacroAssembler::increment(Address dst, int value)


void MacroAssembler::pusha() {
push(0x7fffffff, sp);
push(RegSet::range(r0, r30), sp);
}

void MacroAssembler::popa() {
pop(0x7fffffff, sp);
pop(RegSet::range(r0, r17), sp);
#ifdef R18_RESERVED
ldp(zr, r19, Address(post(sp, 2 * wordSize)));
pop(RegSet::range(r20, r30), sp);
#else
pop(RegSet::range(r18_tls, r30), sp);
#endif
}

// Push lots of registers in the bit set supplied. Don't push sp.
@@ -2579,7 +2585,7 @@ void MacroAssembler::pop_call_clobbered_registers() {

void MacroAssembler::push_CPU_state(bool save_vectors) {
int step = (save_vectors ? 8 : 4) * wordSize;
push(0x3fffffff, sp); // integer registers except lr & sp
push(RegSet::range(r0, r29), sp); // integer registers except lr & sp
mov(rscratch1, -step);
sub(sp, sp, step);
for (int i = 28; i >= 4; i -= 4) {
@@ -2594,7 +2600,15 @@ void MacroAssembler::pop_CPU_state(bool restore_vectors) {
for (int i = 0; i <= 28; i += 4)
ld1(as_FloatRegister(i), as_FloatRegister(i+1), as_FloatRegister(i+2),
as_FloatRegister(i+3), restore_vectors ? T2D : T1D, Address(post(sp, step)));
pop(0x3fffffff, sp); // integer registers except lr & sp

// integer registers except lr & sp
pop(RegSet::range(r0, r17), sp);
#ifdef R18_RESERVED
ldp(zr, r19, Address(post(sp, 2 * wordSize)));
pop(RegSet::range(r20, r29), sp);
#else
pop(RegSet::range(r18_tls, r29), sp);
#endif
}

/**
@@ -1458,11 +1458,12 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) {
__ cmp(rscratch1, JavaThread::stack_guard_yellow_reserved_disabled);
__ br(Assembler::NE, no_reguard);

__ pusha(); // XXX only save smashed registers
__ push_call_clobbered_registers();
__ mov(c_rarg0, rthread);
__ mov(rscratch2, CAST_FROM_FN_PTR(address, SharedRuntime::reguard_yellow_pages));
__ blr(rscratch2);
__ popa(); // XXX only restore smashed registers
__ pop_call_clobbered_registers();

__ bind(no_reguard);
}

1 comment on commit b5cae57

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on b5cae57 Jan 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.