aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2024-04-22 17:40:53 -0400
committerCherry Mui <cherryyz@google.com>2024-04-22 22:46:08 +0000
commit0c39dc1ff72181d36f7e9fc61bfacc5a7b7c5c57 (patch)
treea11cc8d74f1aacea5f222e5fbd629a82e170c405
parent552faa8927a23fd5967435295c14af1741ac3653 (diff)
downloadgo-0c39dc1ff72181d36f7e9fc61bfacc5a7b7c5c57.tar.gz
go-0c39dc1ff72181d36f7e9fc61bfacc5a7b7c5c57.zip
runtime: reduce stack usage for asmcgocall on PPC64
Define it as ABIInternal, so the result does not take space on stack. Also use R10 as a temporary register for arithmetics on SP, so it is hidden from the assembler's SP delta calculation, which is irrelevant anyway as we are on the system stack. Change-Id: I8fed467601c19cad2d7afab26978246d15ce3147 Reviewed-on: https://go-review.googlesource.com/c/go/+/580918 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
-rw-r--r--src/runtime/asm_ppc64x.s21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/runtime/asm_ppc64x.s b/src/runtime/asm_ppc64x.s
index ff9b736430..97c2a370bd 100644
--- a/src/runtime/asm_ppc64x.s
+++ b/src/runtime/asm_ppc64x.s
@@ -615,9 +615,9 @@ TEXT ·asmcgocall_no_g(SB),NOSPLIT,$0-16
// Call fn(arg) on the scheduler stack,
// aligned appropriately for the gcc ABI.
// See cgocall.go for more details.
-TEXT ·asmcgocall(SB),NOSPLIT,$0-20
- MOVD fn+0(FP), R3
- MOVD arg+8(FP), R4
+TEXT ·asmcgocall<ABIInternal>(SB),NOSPLIT,$0-20
+ // R3 = fn
+ // R4 = arg
MOVD R1, R7 // save original stack pointer
CMP $0, g
@@ -651,8 +651,11 @@ TEXT ·asmcgocall(SB),NOSPLIT,$0-20
#endif
// Save room for two of our pointers, plus the callee
// save area that lives on the caller stack.
- SUB $(asmcgocallSaveOffset+16), R1
- RLDCR $0, R1, $~15, R1 // 16-byte alignment for gcc ABI
+ // Do arithmetics in R10 to hide from the assembler
+ // counting it as SP delta, which is irrelevant as we are
+ // on the system stack.
+ SUB $(asmcgocallSaveOffset+16), R1, R10
+ RLDCR $0, R10, $~15, R1 // 16-byte alignment for gcc ABI
MOVD R5, (asmcgocallSaveOffset+8)(R1) // save old g on stack
MOVD (g_stack+stack_hi)(R5), R5
SUB R7, R5
@@ -689,7 +692,7 @@ TEXT ·asmcgocall(SB),NOSPLIT,$0-20
MOVD R5, R1
BL runtime·save_g(SB)
- MOVW R3, ret+16(FP)
+ // ret = R3
RET
nosave:
@@ -703,8 +706,8 @@ nosave:
// Using this code for all "already on system stack" calls exercises it more,
// which should help keep it correct.
- SUB $(asmcgocallSaveOffset+8), R1
- RLDCR $0, R1, $~15, R1 // 16-byte alignment for gcc ABI
+ SUB $(asmcgocallSaveOffset+8), R1, R10
+ RLDCR $0, R10, $~15, R1 // 16-byte alignment for gcc ABI
MOVD R7, asmcgocallSaveOffset(R1) // Save original stack pointer.
MOVD R3, R12 // fn
@@ -724,7 +727,7 @@ nosave:
#ifndef GOOS_aix
MOVD 24(R1), R2
#endif
- MOVW R3, ret+16(FP)
+ // ret = R3
RET
// func cgocallback(fn, frame unsafe.Pointer, ctxt uintptr)