Skip to content

8357267: ZGC: Handle APX EGPRs spilling in ZRuntimeCallSpill #25351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 78 additions & 23 deletions src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,48 @@ class ZRuntimeCallSpill {

void save() {
MacroAssembler* masm = _masm;
__ push(rax);
__ push(rcx);
__ push(rdx);
__ push(rdi);
__ push(rsi);
__ push(r8);
__ push(r9);
__ push(r10);
__ push(r11);
if (VM_Version::supports_apx_f()) {
if (_result != rax) {
__ pushp(rax);
}
__ pushp(rcx);
// Save current stack pointer into rcx
__ movptr(rcx, rsp);
// Align stack pointer to 16 byte boundary. This is hard constraint
// for push2/pop2 with PPX hints.
__ andptr(rsp, -StackAlignmentInBytes);
// Push original stack pointer.
__ push(rcx);
// Restore the original contents of RCX register.
__ movptr(rcx, Address(rcx));
// Now push remaining caller save GPRs and EGPRs on 16B aligned stack.
// Note: For PPX to work properly, a PPX-marked PUSH2 (respectively, POP2) should always
// be matched with a PPX-marked POP2 (PUSH2), not with two PPX-marked POPs (PUSHs).
__ pushp(rdx);
__ push2p(rdi, rsi);
__ push2p(r8, r9);
__ push2p(r10, r11);
__ push2p(r16, r17);
__ push2p(r18, r19);
__ push2p(r20, r21);
__ push2p(r22, r23);
__ push2p(r24, r25);
__ push2p(r26, r27);
__ push2p(r28, r29);
__ push2p(r30, r31);
} else {
if (_result != rax) {
__ push(rax);
}
__ push(rcx);
__ push(rdx);
__ push(rdi);
__ push(rsi);
__ push(r8);
__ push(r9);
__ push(r10);
__ push(r11);
}

if (_xmm_spill_size != 0) {
__ subptr(rsp, _xmm_spill_size);
Expand Down Expand Up @@ -139,21 +172,43 @@ class ZRuntimeCallSpill {
__ addptr(rsp, _xmm_spill_size);
}

__ pop(r11);
__ pop(r10);
__ pop(r9);
__ pop(r8);
__ pop(rsi);
__ pop(rdi);
__ pop(rdx);
__ pop(rcx);
if (_result == noreg) {
__ pop(rax);
} else if (_result == rax) {
__ addptr(rsp, wordSize);
if (VM_Version::supports_apx_f()) {
__ pop2p(r31, r30);
__ pop2p(r29, r28);
__ pop2p(r27, r26);
__ pop2p(r25, r24);
__ pop2p(r23, r22);
__ pop2p(r21, r20);
__ pop2p(r19, r18);
__ pop2p(r17, r16);
__ pop2p(r11, r10);
__ pop2p(r9, r8);
__ pop2p(rsi, rdi);
__ popp(rdx);
// Re-instantiate original stack pointer.
__ movptr(rsp, Address(rsp));
__ popp(rcx);
if (_result == noreg) {
__ popp(rax);
} else if (_result != rax) {
__ movptr(_result, rax);
__ popp(rax);
}
} else {
__ movptr(_result, rax);
__ pop(rax);
__ pop(r11);
__ pop(r10);
__ pop(r9);
__ pop(r8);
__ pop(rsi);
__ pop(rdi);
__ pop(rdx);
__ pop(rcx);
if (_result == noreg) {
__ pop(rax);
} else if (_result != rax) {
__ movptr(_result, rax);
__ pop(rax);
}
}
}

Expand Down