OpenJDK / jdk / jdk
changeset 59325:1ba9a9a3f948
8244433: Remove saving of RSP in Assembler::pusha_uncached()
Summary: Remove move instruction to save the actual value of RSP in Assembler::pusha_uncached() on x86.
Reviewed-by: eosterlund, thartmann, kvn
author | chagedorn |
---|---|
date | Mon, 18 May 2020 12:32:11 +0200 |
parents | a0a21978f3b9 |
children | 304e65936f8f |
files | src/hotspot/cpu/x86/assembler_x86.cpp src/hotspot/cpu/x86/macroAssembler_x86.cpp src/hotspot/cpu/x86/methodHandles_x86.cpp |
diffstat | 3 files changed, 23 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/hotspot/cpu/x86/assembler_x86.cpp Wed Apr 29 18:35:14 2020 +0200 +++ b/src/hotspot/cpu/x86/assembler_x86.cpp Mon May 18 12:32:11 2020 +0200 @@ -8789,7 +8789,8 @@ movq(rdi, Address(rsp, 8 * wordSize)); movq(rsi, Address(rsp, 9 * wordSize)); movq(rbp, Address(rsp, 10 * wordSize)); - // skip rsp + // Skip rsp as it is restored automatically to the value + // before the corresponding pusha when popa is done. movq(rbx, Address(rsp, 12 * wordSize)); movq(rdx, Address(rsp, 13 * wordSize)); movq(rcx, Address(rsp, 14 * wordSize)); @@ -8798,22 +8799,24 @@ addq(rsp, 16 * wordSize); } +// Does not actually store the value of rsp on the stack. +// The slot for rsp just contains an arbitrary value. void Assembler::pusha() { // 64bit emit_copy(code_section(), pusha_code, pusha_len); } +// Does not actually store the value of rsp on the stack. +// The slot for rsp just contains an arbitrary value. void Assembler::pusha_uncached() { // 64bit - // we have to store original rsp. ABI says that 128 bytes - // below rsp are local scratch. - movq(Address(rsp, -5 * wordSize), rsp); - subq(rsp, 16 * wordSize); movq(Address(rsp, 15 * wordSize), rax); movq(Address(rsp, 14 * wordSize), rcx); movq(Address(rsp, 13 * wordSize), rdx); movq(Address(rsp, 12 * wordSize), rbx); - // skip rsp + // Skip rsp as the value is normally not used. There are a few places where + // the original value of rsp needs to be known but that can be computed + // from the value of rsp immediately after pusha (rsp + 16 * wordSize). movq(Address(rsp, 10 * wordSize), rbp); movq(Address(rsp, 9 * wordSize), rsi); movq(Address(rsp, 8 * wordSize), rdi);
--- a/src/hotspot/cpu/x86/macroAssembler_x86.cpp Wed Apr 29 18:35:14 2020 +0200 +++ b/src/hotspot/cpu/x86/macroAssembler_x86.cpp Mon May 18 12:32:11 2020 +0200 @@ -898,7 +898,8 @@ PRINT_REG(rdi, regs[8]); PRINT_REG(rsi, regs[9]); PRINT_REG(rbp, regs[10]); - PRINT_REG(rsp, regs[11]); + // rsp is actually not stored by pusha(), compute the old rsp from regs (rsp after pusha): regs + 16 = old rsp + PRINT_REG(rsp, (intptr_t)(®s[16])); PRINT_REG(r8 , regs[7]); PRINT_REG(r9 , regs[6]); PRINT_REG(r10, regs[5]); @@ -908,8 +909,8 @@ PRINT_REG(r14, regs[1]); PRINT_REG(r15, regs[0]); #undef PRINT_REG - // Print some words near top of staack. - int64_t* rsp = (int64_t*) regs[11]; + // Print some words near the top of the stack. + int64_t* rsp = ®s[16]; int64_t* dump_sp = rsp; for (int col1 = 0; col1 < 8; col1++) { tty->print("(rsp+0x%03x) 0x%016lx: ", (int)((intptr_t)dump_sp - (intptr_t)rsp), (intptr_t)dump_sp);
--- a/src/hotspot/cpu/x86/methodHandles_x86.cpp Wed Apr 29 18:35:14 2020 +0200 +++ b/src/hotspot/cpu/x86/methodHandles_x86.cpp Mon May 18 12:32:11 2020 +0200 @@ -507,7 +507,17 @@ for (int i = 0; i < saved_regs_count; i++) { Register r = as_Register(i); // The registers are stored in reverse order on the stack (by pusha). +#ifdef AMD64 + assert(RegisterImpl::number_of_registers == 16, "sanity"); + if (r == rsp) { + // rsp is actually not stored by pusha(), compute the old rsp from saved_regs (rsp after pusha): saved_regs + 16 = old rsp + tty->print("%3s=" PTR_FORMAT, r->name(), (intptr_t)(&saved_regs[16])); + } else { + tty->print("%3s=" PTR_FORMAT, r->name(), saved_regs[((saved_regs_count - 1) - i)]); + } +#else tty->print("%3s=" PTR_FORMAT, r->name(), saved_regs[((saved_regs_count - 1) - i)]); +#endif if ((i + 1) % 4 == 0) { tty->cr(); } else {