From 89f185fe8a036b0fabce30b20c480cf1c832bdd7 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 26 Jun 2014 11:54:39 -0400 Subject: all: remove 'extern register M *m' from runtime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The runtime has historically held two dedicated values g (current goroutine) and m (current thread) in 'extern register' slots (TLS on x86, real registers backed by TLS on ARM). This CL removes the extern register m; code now uses g->m. On ARM, this frees up the register that formerly held m (R9). This is important for NaCl, because NaCl ARM code cannot use R9 at all. The Go 1 macrobenchmarks (those with per-op times >= 10 µs) are unaffected: BenchmarkBinaryTree17 5491374955 5471024381 -0.37% BenchmarkFannkuch11 4357101311 4275174828 -1.88% BenchmarkGobDecode 11029957 11364184 +3.03% BenchmarkGobEncode 6852205 6784822 -0.98% BenchmarkGzip 650795967 650152275 -0.10% BenchmarkGunzip 140962363 141041670 +0.06% BenchmarkHTTPClientServer 71581 73081 +2.10% BenchmarkJSONEncode 31928079 31913356 -0.05% BenchmarkJSONDecode 117470065 113689916 -3.22% BenchmarkMandelbrot200 6008923 5998712 -0.17% BenchmarkGoParse 6310917 6327487 +0.26% BenchmarkRegexpMatchMedium_1K 114568 114763 +0.17% BenchmarkRegexpMatchHard_1K 168977 169244 +0.16% BenchmarkRevcomp 935294971 914060918 -2.27% BenchmarkTemplate 145917123 148186096 +1.55% Minux previous reported larger variations, but these were caused by run-to-run noise, not repeatable slowdowns. Actual code changes by Minux. I only did the docs and the benchmarking. LGTM=dvyukov, iant, minux R=minux, josharian, iant, dave, bradfitz, dvyukov CC=golang-codereviews https://golang.org/cl/109050043 --- src/pkg/runtime/sys_linux_arm.s | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/pkg/runtime/sys_linux_arm.s') diff --git a/src/pkg/runtime/sys_linux_arm.s b/src/pkg/runtime/sys_linux_arm.s index c537a87223..8bfc72b571 100644 --- a/src/pkg/runtime/sys_linux_arm.s +++ b/src/pkg/runtime/sys_linux_arm.s @@ -244,11 +244,12 @@ TEXT runtime·clone(SB),NOSPLIT,$0 BEQ 2(PC) BL runtime·abort(SB) - MOVW 0(R13), m MOVW 4(R13), g + MOVW 0(R13), R8 + MOVW R8, g_m(g) // paranoia; check they are not nil - MOVW 0(m), R0 + MOVW 0(R8), R0 MOVW 0(g), R0 BL runtime·emptyfunc(SB) // fault if stack check is wrong @@ -256,7 +257,8 @@ TEXT runtime·clone(SB),NOSPLIT,$0 // Initialize m->procid to Linux tid MOVW $SYS_gettid, R7 SWI $0 - MOVW R0, m_procid(m) + MOVW g_m(g), R8 + MOVW R0, m_procid(R8) // Call fn MOVW 8(R13), R0 @@ -285,14 +287,14 @@ TEXT runtime·sigaltstack(SB),NOSPLIT,$0 TEXT runtime·sigtramp(SB),NOSPLIT,$24 // this might be called in external code context, - // where g and m are not set. - // first save R0, because runtime·load_gm will clobber it + // where g is not set. + // first save R0, because runtime·load_g will clobber it MOVW R0, 4(R13) MOVB runtime·iscgo(SB), R0 CMP $0, R0 - BL.NE runtime·load_gm(SB) + BL.NE runtime·load_g(SB) - CMP $0, m + CMP $0, g BNE 4(PC) // signal number is already prepared in 4(R13) MOVW $runtime·badsignal(SB), R11 @@ -304,7 +306,8 @@ TEXT runtime·sigtramp(SB),NOSPLIT,$24 MOVW g, 20(R13) // g = m->gsignal - MOVW m_gsignal(m), g + MOVW g_m(g), R8 + MOVW m_gsignal(R8), g // copy arguments for call to sighandler // R0 is already saved above -- cgit v1.3-5-g9baa