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/softfloat_arm.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/pkg/runtime/softfloat_arm.c') diff --git a/src/pkg/runtime/softfloat_arm.c b/src/pkg/runtime/softfloat_arm.c index 29a52bd0e4..41ce8bd753 100644 --- a/src/pkg/runtime/softfloat_arm.c +++ b/src/pkg/runtime/softfloat_arm.c @@ -32,20 +32,20 @@ fabort(void) static void putf(uint32 reg, uint32 val) { - m->freglo[reg] = val; + g->m->freglo[reg] = val; } static void putd(uint32 reg, uint64 val) { - m->freglo[reg] = (uint32)val; - m->freghi[reg] = (uint32)(val>>32); + g->m->freglo[reg] = (uint32)val; + g->m->freghi[reg] = (uint32)(val>>32); } static uint64 getd(uint32 reg) { - return (uint64)m->freglo[reg] | ((uint64)m->freghi[reg]<<32); + return (uint64)g->m->freglo[reg] | ((uint64)g->m->freghi[reg]<<32); } static void @@ -53,7 +53,7 @@ fprint(void) { uint32 i; for (i = 0; i < 16; i++) { - runtime·printf("\tf%d:\t%X %X\n", i, m->freghi[i], m->freglo[i]); + runtime·printf("\tf%d:\t%X %X\n", i, g->m->freghi[i], g->m->freglo[i]); } } @@ -111,7 +111,11 @@ stepflt(uint32 *pc, uint32 *regs) int64 sval; bool nan, ok; int32 cmp; + M *m; + // m is locked in vlop_arm.s, so g->m cannot change during this function call, + // so caching it in a local variable is safe. + m = g->m; i = *pc; if(trace) -- cgit v1.3