Skip to content

Commit d27248c

Browse files
committed
runtime: save some stack space for racecall on ARM64
To avoid nosplit overflow in -race -N -l build. For #51247. Change-Id: I48426bbd4adefd18eaf26ed51b4113c6a28305b8 Reviewed-on: https://go-review.googlesource.com/c/go/+/386716 Trust: Cherry Mui <[email protected]> Run-TryBot: Cherry Mui <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Michael Knyszek <[email protected]>
1 parent d93cc8c commit d27248c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/runtime/race_arm64.s

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,12 +396,12 @@ racecallatomic_ignore:
396396
// Addr is outside the good range.
397397
// Call __tsan_go_ignore_sync_begin to ignore synchronization during the atomic op.
398398
// An attempt to synchronize on the address would cause crash.
399-
MOVD R9, R20 // remember the original function
399+
MOVD R9, R21 // remember the original function
400400
MOVD $__tsan_go_ignore_sync_begin(SB), R9
401401
load_g
402402
MOVD g_racectx(g), R0 // goroutine context
403403
BL racecall<>(SB)
404-
MOVD R20, R9 // restore the original function
404+
MOVD R21, R9 // restore the original function
405405
// Call the atomic function.
406406
// racecall will call LLVM race code which might clobber R28 (g)
407407
load_g
@@ -428,10 +428,12 @@ TEXT runtime·racecall(SB), NOSPLIT, $0-0
428428
JMP racecall<>(SB)
429429

430430
// Switches SP to g0 stack and calls (R9). Arguments already set.
431-
TEXT racecall<>(SB), NOSPLIT, $0-0
431+
// Clobbers R19, R20.
432+
TEXT racecall<>(SB), NOSPLIT|NOFRAME, $0-0
432433
MOVD g_m(g), R10
433434
// Switch to g0 stack.
434435
MOVD RSP, R19 // callee-saved, preserved across the CALL
436+
MOVD R30, R20 // callee-saved, preserved across the CALL
435437
MOVD m_g0(R10), R11
436438
CMP R11, g
437439
BEQ call // already on g0
@@ -440,7 +442,7 @@ TEXT racecall<>(SB), NOSPLIT, $0-0
440442
call:
441443
BL R9
442444
MOVD R19, RSP
443-
RET
445+
JMP (R20)
444446

445447
// C->Go callback thunk that allows to call runtime·racesymbolize from C code.
446448
// Direct Go->C race call has only switched SP, finish g->g0 switch by setting correct g.

0 commit comments

Comments
 (0)