diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2014-07-19 08:53:52 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2014-07-19 08:53:52 +0000 |
commit | 00d86ac99f5dd6afa5bbd7c38ffe1c585edd2387 (patch) | |
tree | b988e32ea14a3dc1b4718b1fdfa47bab087ae96c /libgo/runtime/runtime.c | |
parent | bcf2fc6ee0a7edbe7de4299f28b66527c07bb0a2 (diff) | |
download | gcc-00d86ac99f5dd6afa5bbd7c38ffe1c585edd2387.zip gcc-00d86ac99f5dd6afa5bbd7c38ffe1c585edd2387.tar.gz gcc-00d86ac99f5dd6afa5bbd7c38ffe1c585edd2387.tar.bz2 |
libgo: Update to Go 1.3 release.
From-SVN: r212837
Diffstat (limited to 'libgo/runtime/runtime.c')
-rw-r--r-- | libgo/runtime/runtime.c | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/libgo/runtime/runtime.c b/libgo/runtime/runtime.c index 1678a45..33fe1e7 100644 --- a/libgo/runtime/runtime.c +++ b/libgo/runtime/runtime.c @@ -8,8 +8,20 @@ #include "config.h" #include "runtime.h" +#include "arch.h" #include "array.h" +enum { + maxround = sizeof(uintptr), +}; + +// Keep a cached value to make gotraceback fast, +// since we call it on every call to gentraceback. +// The cached value is a uint32 in which the low bit +// is the "crash" setting and the top 31 bits are the +// gotraceback value. +static uint32 traceback_cache = ~(uint32)0; + // The GOTRACEBACK environment variable controls the // behavior of a Go program that is crashing and exiting. // GOTRACEBACK=0 suppress all tracebacks @@ -20,18 +32,28 @@ int32 runtime_gotraceback(bool *crash) { const byte *p; + uint32 x; if(crash != nil) *crash = false; - p = runtime_getenv("GOTRACEBACK"); - if(p == nil || p[0] == '\0') - return 1; // default is on - if(runtime_strcmp((const char *)p, "crash") == 0) { - if(crash != nil) - *crash = true; - return 2; // extra information + if(runtime_m()->traceback != 0) + return runtime_m()->traceback; + x = runtime_atomicload(&traceback_cache); + if(x == ~(uint32)0) { + p = runtime_getenv("GOTRACEBACK"); + if(p == nil) + p = (const byte*)""; + if(p[0] == '\0') + x = 1<<1; + else if(runtime_strcmp((const char *)p, "crash") == 0) + x = (2<<1) | 1; + else + x = runtime_atoi(p)<<1; + runtime_atomicstore(&traceback_cache, x); } - return runtime_atoi(p); + if(crash != nil) + *crash = x&1; + return x>>1; } static int32 argc; @@ -90,6 +112,8 @@ runtime_goenvs_unix(void) syscall_Envs.__values = (void*)s; syscall_Envs.__count = n; syscall_Envs.__capacity = n; + + traceback_cache = ~(uint32)0; } int32 @@ -275,6 +299,7 @@ static struct { {"allocfreetrace", &runtime_debug.allocfreetrace}, {"efence", &runtime_debug.efence}, {"gctrace", &runtime_debug.gctrace}, + {"gcdead", &runtime_debug.gcdead}, {"scheddetail", &runtime_debug.scheddetail}, {"schedtrace", &runtime_debug.schedtrace}, }; |