Now that we always have TLS set up, we can always save the G
register, regardless of whether cgo is used. This makes pure Go
programs signal-safe.
Updates #38485.
Change-Id: Icbc69acf0e2a5652fbcbbd074258a1a5efe87f1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/265119
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
NO_LOCAL_POINTERS
// Load g from thread-local storage.
- MOVB runtime·iscgo(SB), R3
- CBZ R3, nocgo
BL runtime·load_g(SB)
-nocgo:
// If g is nil, Go did not create the current thread.
// Call needm to obtain one for temporary use.
// this might be called in external code context,
// where g is not set.
- MOVB runtime·iscgo(SB), R0
- CMP $0, R0
- BEQ 2(PC)
BL runtime·load_g(SB)
#ifdef GOOS_ios
FMOVD F14, 144(RSP)
FMOVD F15, 152(RSP)
- MOVD m_g0(R0), g
+ MOVD m_g0(R0), g
+ BL ·save_g(SB)
BL runtime·mstart(SB)
#include "tls_arm64.h"
TEXT runtime·load_g(SB),NOSPLIT,$0
+#ifndef TLS_darwin
MOVB runtime·iscgo(SB), R0
CBZ R0, nocgo
+#endif
MRS_TPIDR_R0
#ifdef TLS_darwin
RET
TEXT runtime·save_g(SB),NOSPLIT,$0
+#ifndef TLS_darwin
MOVB runtime·iscgo(SB), R0
CBZ R0, nocgo
+#endif
MRS_TPIDR_R0
#ifdef TLS_darwin