]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: save some stack space for racecall on ARM64
authorCherry Mui <cherryyz@google.com>
Fri, 18 Feb 2022 00:45:50 +0000 (19:45 -0500)
committerCherry Mui <cherryyz@google.com>
Fri, 18 Feb 2022 18:47:47 +0000 (18:47 +0000)
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 <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/runtime/race_arm64.s

index 59fade02eeeb451e1169a4caa106e6b84cf790e6..95fec0b9c63d58ba51c89cdeb0f2c4333f296756 100644 (file)
@@ -396,12 +396,12 @@ racecallatomic_ignore:
        // Addr is outside the good range.
        // Call __tsan_go_ignore_sync_begin to ignore synchronization during the atomic op.
        // An attempt to synchronize on the address would cause crash.
-       MOVD    R9, R20 // remember the original function
+       MOVD    R9, R21 // remember the original function
        MOVD    $__tsan_go_ignore_sync_begin(SB), R9
        load_g
        MOVD    g_racectx(g), R0        // goroutine context
        BL      racecall<>(SB)
-       MOVD    R20, R9 // restore the original function
+       MOVD    R21, R9 // restore the original function
        // Call the atomic function.
        // racecall will call LLVM race code which might clobber R28 (g)
        load_g
@@ -428,10 +428,12 @@ TEXT      runtime·racecall(SB), NOSPLIT, $0-0
        JMP     racecall<>(SB)
 
 // Switches SP to g0 stack and calls (R9). Arguments already set.
-TEXT   racecall<>(SB), NOSPLIT, $0-0
+// Clobbers R19, R20.
+TEXT   racecall<>(SB), NOSPLIT|NOFRAME, $0-0
        MOVD    g_m(g), R10
        // Switch to g0 stack.
        MOVD    RSP, R19        // callee-saved, preserved across the CALL
+       MOVD    R30, R20        // callee-saved, preserved across the CALL
        MOVD    m_g0(R10), R11
        CMP     R11, g
        BEQ     call    // already on g0
@@ -440,7 +442,7 @@ TEXT        racecall<>(SB), NOSPLIT, $0-0
 call:
        BL      R9
        MOVD    R19, RSP
-       RET
+       JMP     (R20)
 
 // C->Go callback thunk that allows to call runtime·racesymbolize from C code.
 // Direct Go->C race call has only switched SP, finish g->g0 switch by setting correct g.