From a413908dd064de6e3ea5b8d95d707a532bd3f4c8 Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Wed, 16 Sep 2020 16:59:58 -0400 Subject: all: add GOOS=ios Introduce GOOS=ios for iOS systems. GOOS=ios matches "darwin" build tag, like GOOS=android matches "linux" and GOOS=illumos matches "solaris". Only ios/arm64 is supported (ios/amd64 is not). GOOS=ios and GOOS=darwin remain essentially the same at this point. They will diverge at later time, to differentiate macOS and iOS. Uses of GOOS=="darwin" are changed to (GOOS=="darwin" || GOOS=="ios"), except if it clearly means macOS (e.g. GOOS=="darwin" && GOARCH=="amd64"), it remains GOOS=="darwin". Updates #38485. Change-Id: I4faacdc1008f42434599efb3c3ad90763a83b67c Reviewed-on: https://go-review.googlesource.com/c/go/+/254740 Trust: Cherry Zhang Run-TryBot: Cherry Zhang TryBot-Result: Go Bot Reviewed-by: Austin Clements --- src/runtime/tls_arm64.s | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/runtime/tls_arm64.s') diff --git a/src/runtime/tls_arm64.s b/src/runtime/tls_arm64.s index 999914d655..7846fac6c5 100644 --- a/src/runtime/tls_arm64.s +++ b/src/runtime/tls_arm64.s @@ -13,7 +13,7 @@ TEXT runtime·load_g(SB),NOSPLIT,$0 CBZ R0, nocgo MRS_TPIDR_R0 -#ifdef GOOS_darwin +#ifdef TLS_darwin // Darwin sometimes returns unaligned pointers AND $0xfffffffffffffff8, R0 #endif @@ -29,7 +29,7 @@ TEXT runtime·save_g(SB),NOSPLIT,$0 CBZ R0, nocgo MRS_TPIDR_R0 -#ifdef GOOS_darwin +#ifdef TLS_darwin // Darwin sometimes returns unaligned pointers AND $0xfffffffffffffff8, R0 #endif -- cgit v1.3 From a0a44397e91055cb92d5a69e3851d628a7227971 Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Sat, 24 Oct 2020 16:29:26 -0400 Subject: runtime: save/restore g unconditionally on darwin/arm64 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 Run-TryBot: Cherry Zhang TryBot-Result: Go Bot Reviewed-by: Austin Clements Reviewed-by: Joel Sing --- src/runtime/asm_arm64.s | 3 --- src/runtime/sys_darwin_arm64.s | 6 ++---- src/runtime/tls_arm64.s | 4 ++++ 3 files changed, 6 insertions(+), 7 deletions(-) (limited to 'src/runtime/tls_arm64.s') diff --git a/src/runtime/asm_arm64.s b/src/runtime/asm_arm64.s index 6257c1a183..a09172f0c9 100644 --- a/src/runtime/asm_arm64.s +++ b/src/runtime/asm_arm64.s @@ -977,10 +977,7 @@ TEXT ·cgocallback(SB),NOSPLIT,$24-24 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. diff --git a/src/runtime/sys_darwin_arm64.s b/src/runtime/sys_darwin_arm64.s index 31b997df13..fd713b7902 100644 --- a/src/runtime/sys_darwin_arm64.s +++ b/src/runtime/sys_darwin_arm64.s @@ -197,9 +197,6 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$192 // 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 @@ -381,7 +378,8 @@ TEXT runtime·mstart_stub(SB),NOSPLIT,$160 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) diff --git a/src/runtime/tls_arm64.s b/src/runtime/tls_arm64.s index 7846fac6c5..701abae105 100644 --- a/src/runtime/tls_arm64.s +++ b/src/runtime/tls_arm64.s @@ -9,8 +9,10 @@ #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 @@ -25,8 +27,10 @@ nocgo: 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 -- cgit v1.3 From 202aa085abfc2aa7f3095102b9d47c83e177fb84 Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Sat, 31 Oct 2020 17:21:40 -0400 Subject: runtime: use indexed load/store in ARM64 assembly Minor optimization. Spotted while working on that code. Change-Id: Ia02dee10d74bce79a0bef1eaba7fac1bfc27df38 Reviewed-on: https://go-review.googlesource.com/c/go/+/266899 Trust: Cherry Zhang Run-TryBot: Cherry Zhang TryBot-Result: Go Bot Reviewed-by: fannie zhang Reviewed-by: David Chase --- src/runtime/race_arm64.s | 3 +-- src/runtime/tls_arm64.s | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'src/runtime/tls_arm64.s') diff --git a/src/runtime/race_arm64.s b/src/runtime/race_arm64.s index 5b1a1cb89a..6bc389f69f 100644 --- a/src/runtime/race_arm64.s +++ b/src/runtime/race_arm64.s @@ -38,8 +38,7 @@ MRS_TPIDR_R0 \ TP_ALIGN \ MOVD runtime·tls_g(SB), R11 \ - ADD R11, R0 \ - MOVD 0(R0), g + MOVD (R0)(R11), g // func runtime·raceread(addr uintptr) // Called from instrumented code. diff --git a/src/runtime/tls_arm64.s b/src/runtime/tls_arm64.s index 701abae105..3f02974d5b 100644 --- a/src/runtime/tls_arm64.s +++ b/src/runtime/tls_arm64.s @@ -20,8 +20,7 @@ TEXT runtime·load_g(SB),NOSPLIT,$0 AND $0xfffffffffffffff8, R0 #endif MOVD runtime·tls_g(SB), R27 - ADD R27, R0 - MOVD 0(R0), g + MOVD (R0)(R27), g nocgo: RET @@ -38,8 +37,7 @@ TEXT runtime·save_g(SB),NOSPLIT,$0 AND $0xfffffffffffffff8, R0 #endif MOVD runtime·tls_g(SB), R27 - ADD R27, R0 - MOVD g, 0(R0) + MOVD g, (R0)(R27) nocgo: RET -- cgit v1.3