2008-06-05 20:38:39 -06:00
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
/*
|
|
|
|
* basic types
|
|
|
|
*/
|
|
|
|
typedef signed char int8;
|
|
|
|
typedef unsigned char uint8;
|
|
|
|
typedef signed short int16;
|
|
|
|
typedef unsigned short uint16;
|
|
|
|
typedef signed int int32;
|
|
|
|
typedef unsigned int uint32;
|
|
|
|
typedef signed long long int int64;
|
|
|
|
typedef unsigned long long int uint64;
|
|
|
|
typedef float float32;
|
|
|
|
typedef double float64;
|
2009-03-30 01:01:07 -06:00
|
|
|
|
|
|
|
#ifdef _64BIT
|
2008-11-17 13:32:35 -07:00
|
|
|
typedef uint64 uintptr;
|
2009-11-18 10:11:39 -07:00
|
|
|
typedef int64 intptr;
|
2012-09-24 18:57:01 -06:00
|
|
|
typedef int64 intgo; // Go's int
|
|
|
|
typedef uint64 uintgo; // Go's uint
|
2009-03-30 01:01:07 -06:00
|
|
|
#else
|
|
|
|
typedef uint32 uintptr;
|
2012-09-24 12:58:34 -06:00
|
|
|
typedef int32 intptr;
|
|
|
|
typedef int32 intgo; // Go's int
|
|
|
|
typedef uint32 uintgo; // Go's uint
|
2009-03-30 01:01:07 -06:00
|
|
|
#endif
|
2008-06-05 20:38:39 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* get rid of C types
|
2008-11-23 18:08:55 -07:00
|
|
|
* the / / / forces a syntax error immediately,
|
|
|
|
* which will show "last name: XXunsigned".
|
2008-06-05 20:38:39 -06:00
|
|
|
*/
|
2008-11-23 18:08:55 -07:00
|
|
|
#define unsigned XXunsigned / / /
|
|
|
|
#define signed XXsigned / / /
|
|
|
|
#define char XXchar / / /
|
|
|
|
#define short XXshort / / /
|
|
|
|
#define int XXint / / /
|
|
|
|
#define long XXlong / / /
|
|
|
|
#define float XXfloat / / /
|
|
|
|
#define double XXdouble / / /
|
2008-06-05 20:38:39 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* defined types
|
|
|
|
*/
|
|
|
|
typedef uint8 bool;
|
|
|
|
typedef uint8 byte;
|
2008-11-23 18:08:55 -07:00
|
|
|
typedef struct Func Func;
|
2008-07-13 15:29:46 -06:00
|
|
|
typedef struct G G;
|
2008-11-23 18:08:55 -07:00
|
|
|
typedef struct Gobuf Gobuf;
|
2013-04-06 21:07:07 -06:00
|
|
|
typedef struct Lock Lock;
|
2008-11-23 18:08:55 -07:00
|
|
|
typedef struct M M;
|
2013-03-01 06:30:11 -07:00
|
|
|
typedef struct P P;
|
2013-04-06 21:09:02 -06:00
|
|
|
typedef struct Note Note;
|
2009-08-25 16:54:25 -06:00
|
|
|
typedef struct Slice Slice;
|
2008-11-23 18:08:55 -07:00
|
|
|
typedef struct Stktop Stktop;
|
2009-04-09 19:16:21 -06:00
|
|
|
typedef struct String String;
|
2013-02-21 15:01:13 -07:00
|
|
|
typedef struct FuncVal FuncVal;
|
2008-12-19 18:11:54 -07:00
|
|
|
typedef struct SigTab SigTab;
|
|
|
|
typedef struct MCache MCache;
|
runtime: parallelize garbage collector mark + sweep
Running test/garbage/parser.out.
On a 4-core Lenovo X201s (Linux):
31.12u 0.60s 31.74r 1 cpu, no atomics
32.27u 0.58s 32.86r 1 cpu, atomic instructions
33.04u 0.83s 27.47r 2 cpu
On a 16-core Xeon (Linux):
33.08u 0.65s 33.80r 1 cpu, no atomics
34.87u 1.12s 29.60r 2 cpu
36.00u 1.87s 28.43r 3 cpu
36.46u 2.34s 27.10r 4 cpu
38.28u 3.85s 26.92r 5 cpu
37.72u 5.25s 26.73r 6 cpu
39.63u 7.11s 26.95r 7 cpu
39.67u 8.10s 26.68r 8 cpu
On a 2-core MacBook Pro Core 2 Duo 2.26 (circa 2009, MacBookPro5,5):
39.43u 1.45s 41.27r 1 cpu, no atomics
43.98u 2.95s 38.69r 2 cpu
On a 2-core Mac Mini Core 2 Duo 1.83 (circa 2008; Macmini2,1):
48.81u 2.12s 51.76r 1 cpu, no atomics
57.15u 4.72s 51.54r 2 cpu
The handoff algorithm is really only good for two cores.
Beyond that we will need to so something more sophisticated,
like have each core hand off to the next one, around a circle.
Even so, the code is a good checkpoint; for now we'll limit the
number of gc procs to at most 2.
R=dvyukov
CC=golang-dev
https://golang.org/cl/4641082
2011-09-30 07:40:01 -06:00
|
|
|
typedef struct FixAlloc FixAlloc;
|
2008-12-19 18:11:54 -07:00
|
|
|
typedef struct Iface Iface;
|
2009-07-07 12:02:54 -06:00
|
|
|
typedef struct Itab Itab;
|
2012-11-01 11:13:20 -06:00
|
|
|
typedef struct InterfaceType InterfaceType;
|
2010-02-19 21:42:50 -07:00
|
|
|
typedef struct Eface Eface;
|
2009-07-07 12:02:54 -06:00
|
|
|
typedef struct Type Type;
|
2014-01-07 14:45:50 -07:00
|
|
|
typedef struct PtrType PtrType;
|
2011-08-17 13:54:17 -06:00
|
|
|
typedef struct ChanType ChanType;
|
2011-08-17 12:56:27 -06:00
|
|
|
typedef struct MapType MapType;
|
2009-01-27 13:03:53 -07:00
|
|
|
typedef struct Defer Defer;
|
2012-12-22 12:54:39 -07:00
|
|
|
typedef struct DeferChunk DeferChunk;
|
2010-03-31 12:46:01 -06:00
|
|
|
typedef struct Panic Panic;
|
2011-01-31 04:27:28 -07:00
|
|
|
typedef struct Hmap Hmap;
|
2009-07-08 16:00:54 -06:00
|
|
|
typedef struct Hchan Hchan;
|
2010-02-19 21:42:50 -07:00
|
|
|
typedef struct Complex64 Complex64;
|
|
|
|
typedef struct Complex128 Complex128;
|
2011-08-27 07:17:00 -06:00
|
|
|
typedef struct WinCall WinCall;
|
2012-05-29 23:10:54 -06:00
|
|
|
typedef struct SEH SEH;
|
2013-06-24 01:17:45 -06:00
|
|
|
typedef struct WinCallbackContext WinCallbackContext;
|
runtime: add timer support, use for package time
This looks like it is just moving some code from
time to runtime (and translating it to C), but the
runtime can do a better job managing the goroutines,
and it needs this functionality for its own maintenance
(for example, for the garbage collector to hand back
unused memory to the OS on a time delay).
Might as well have just one copy of the timer logic,
and runtime can't depend on time, so vice versa.
It also unifies Sleep, NewTicker, and NewTimer behind
one mechanism, so that there are no claims that one
is more efficient than another. (For example, today
people recommend using time.After instead of time.Sleep
to avoid blocking an OS thread.)
Fixes #1644.
Fixes #1731.
Fixes #2190.
R=golang-dev, r, hectorchu, iant, iant, jsing, alex.brainman, dvyukov
CC=golang-dev
https://golang.org/cl/5334051
2011-11-09 13:17:05 -07:00
|
|
|
typedef struct Timers Timers;
|
|
|
|
typedef struct Timer Timer;
|
2013-02-21 15:01:13 -07:00
|
|
|
typedef struct GCStats GCStats;
|
|
|
|
typedef struct LFNode LFNode;
|
|
|
|
typedef struct ParFor ParFor;
|
|
|
|
typedef struct ParForThread ParForThread;
|
|
|
|
typedef struct CgoMal CgoMal;
|
2013-03-14 00:38:37 -06:00
|
|
|
typedef struct PollDesc PollDesc;
|
2013-06-28 08:37:06 -06:00
|
|
|
typedef struct DebugVars DebugVars;
|
2008-07-13 15:29:46 -06:00
|
|
|
|
|
|
|
/*
|
2012-10-18 18:02:32 -06:00
|
|
|
* Per-CPU declaration.
|
2009-08-11 14:30:35 -06:00
|
|
|
*
|
2012-10-18 18:02:32 -06:00
|
|
|
* "extern register" is a special storage class implemented by 6c, 8c, etc.
|
|
|
|
* On the ARM, it is an actual register; elsewhere it is a slot in thread-
|
|
|
|
* local storage indexed by a segment register. See zasmhdr in
|
|
|
|
* src/cmd/dist/buildruntime.c for details, and be aware that the linker may
|
|
|
|
* make further OS-specific changes to the compiler's output. For example,
|
|
|
|
* 6l/linux rewrites 0(GS) as -16(FS).
|
2009-08-26 11:47:18 -06:00
|
|
|
*
|
2012-10-18 18:02:32 -06:00
|
|
|
* Every C file linked into a Go program must include runtime.h so that the
|
|
|
|
* C compiler (6c, 8c, etc.) knows to avoid other uses of these dedicated
|
|
|
|
* registers. The Go compiler (6g, 8g, etc.) knows to avoid them.
|
2008-07-13 15:29:46 -06:00
|
|
|
*/
|
2009-08-11 14:30:35 -06:00
|
|
|
extern register G* g;
|
|
|
|
extern register M* m;
|
2008-07-13 15:29:46 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* defined constants
|
|
|
|
*/
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
// G status
|
2010-04-08 14:24:53 -06:00
|
|
|
//
|
|
|
|
// If you add to this list, add to the list
|
|
|
|
// of "okay during garbage collection" status
|
|
|
|
// in mgc0.c too.
|
2008-07-13 15:29:46 -06:00
|
|
|
Gidle,
|
|
|
|
Grunnable,
|
2008-08-04 17:43:49 -06:00
|
|
|
Grunning,
|
2008-12-05 16:24:18 -07:00
|
|
|
Gsyscall,
|
2008-07-14 15:33:39 -06:00
|
|
|
Gwaiting,
|
2013-03-01 04:49:16 -07:00
|
|
|
Gmoribund_unused, // currently unused, but hardcoded in gdb scripts
|
2008-07-13 15:29:46 -06:00
|
|
|
Gdead,
|
|
|
|
};
|
|
|
|
enum
|
2013-03-01 04:49:16 -07:00
|
|
|
{
|
|
|
|
// P status
|
|
|
|
Pidle,
|
|
|
|
Prunning,
|
|
|
|
Psyscall,
|
|
|
|
Pgcstop,
|
|
|
|
Pdead,
|
|
|
|
};
|
|
|
|
enum
|
2008-07-13 15:29:46 -06:00
|
|
|
{
|
|
|
|
true = 1,
|
|
|
|
false = 0,
|
|
|
|
};
|
2012-09-17 15:18:21 -06:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PtrSize = sizeof(void*),
|
|
|
|
};
|
2013-01-09 22:57:06 -07:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
// Per-M stack segment cache size.
|
|
|
|
StackCacheSize = 32,
|
|
|
|
// Global <-> per-M stack segment cache transfer batch size.
|
|
|
|
StackCacheBatch = 16,
|
|
|
|
};
|
2008-07-13 15:29:46 -06:00
|
|
|
/*
|
|
|
|
* structures
|
|
|
|
*/
|
2013-04-06 21:07:07 -06:00
|
|
|
struct Lock
|
2008-08-04 17:43:49 -06:00
|
|
|
{
|
2013-04-06 21:07:07 -06:00
|
|
|
// Futex-based impl treats it as uint32 key,
|
|
|
|
// while sema-based impl as M* waitm.
|
|
|
|
// Used to be a union, but unions break precise GC.
|
|
|
|
uintptr key;
|
2008-09-24 11:25:28 -06:00
|
|
|
};
|
2013-04-06 21:09:02 -06:00
|
|
|
struct Note
|
2008-08-04 17:43:49 -06:00
|
|
|
{
|
2013-04-06 21:09:02 -06:00
|
|
|
// Futex-based impl treats it as uint32 key,
|
|
|
|
// while sema-based impl as M* waitm.
|
|
|
|
// Used to be a union, but unions break precise GC.
|
|
|
|
uintptr key;
|
2008-08-04 17:43:49 -06:00
|
|
|
};
|
2008-07-13 15:29:46 -06:00
|
|
|
struct String
|
2008-06-05 20:38:39 -06:00
|
|
|
{
|
2009-04-09 19:16:21 -06:00
|
|
|
byte* str;
|
2012-09-24 12:58:34 -06:00
|
|
|
intgo len;
|
2008-07-13 15:29:46 -06:00
|
|
|
};
|
2013-02-21 15:01:13 -07:00
|
|
|
struct FuncVal
|
|
|
|
{
|
|
|
|
void (*fn)(void);
|
|
|
|
// variable-size, fn-specific data here
|
|
|
|
};
|
2008-12-19 18:11:54 -07:00
|
|
|
struct Iface
|
|
|
|
{
|
2009-07-07 12:02:54 -06:00
|
|
|
Itab* tab;
|
2009-04-09 19:16:21 -06:00
|
|
|
void* data;
|
2008-12-19 18:11:54 -07:00
|
|
|
};
|
2009-05-20 15:57:55 -06:00
|
|
|
struct Eface
|
|
|
|
{
|
2009-07-07 12:02:54 -06:00
|
|
|
Type* type;
|
2009-05-20 15:57:55 -06:00
|
|
|
void* data;
|
|
|
|
};
|
2010-02-19 21:42:50 -07:00
|
|
|
struct Complex64
|
|
|
|
{
|
|
|
|
float32 real;
|
|
|
|
float32 imag;
|
|
|
|
};
|
|
|
|
struct Complex128
|
|
|
|
{
|
|
|
|
float64 real;
|
|
|
|
float64 imag;
|
|
|
|
};
|
2008-08-27 18:28:30 -06:00
|
|
|
|
2009-08-25 16:54:25 -06:00
|
|
|
struct Slice
|
2008-08-27 18:28:30 -06:00
|
|
|
{ // must not move anything
|
|
|
|
byte* array; // actual data
|
2012-09-24 12:58:34 -06:00
|
|
|
uintgo len; // number of elements
|
|
|
|
uintgo cap; // allocated number of elements
|
2008-08-27 18:28:30 -06:00
|
|
|
};
|
2008-07-11 20:16:39 -06:00
|
|
|
struct Gobuf
|
|
|
|
{
|
2013-06-12 13:22:26 -06:00
|
|
|
// The offsets of sp, pc, and g are known to (hard-coded in) libmach.
|
2012-05-30 11:07:52 -06:00
|
|
|
uintptr sp;
|
2013-06-12 06:49:38 -06:00
|
|
|
uintptr pc;
|
2009-06-17 16:12:16 -06:00
|
|
|
G* g;
|
2013-06-12 13:22:26 -06:00
|
|
|
uintptr ret;
|
|
|
|
void* ctxt;
|
|
|
|
uintptr lr;
|
2008-07-11 20:16:39 -06:00
|
|
|
};
|
2012-04-05 10:48:28 -06:00
|
|
|
struct GCStats
|
|
|
|
{
|
|
|
|
// the struct must consist of only uint64's,
|
|
|
|
// because it is casted to uint64[].
|
|
|
|
uint64 nhandoff;
|
|
|
|
uint64 nhandoffcnt;
|
|
|
|
uint64 nprocyield;
|
|
|
|
uint64 nosyield;
|
|
|
|
uint64 nsleep;
|
|
|
|
};
|
2013-07-29 12:22:34 -06:00
|
|
|
|
|
|
|
struct WinCall
|
|
|
|
{
|
|
|
|
void (*fn)(void*);
|
|
|
|
uintptr n; // number of parameters
|
|
|
|
void* args; // parameters
|
|
|
|
uintptr r1; // return values
|
|
|
|
uintptr r2;
|
|
|
|
uintptr err; // error number
|
|
|
|
};
|
|
|
|
struct SEH
|
|
|
|
{
|
|
|
|
void* prev;
|
|
|
|
void* handler;
|
|
|
|
};
|
|
|
|
// describes how to handle callback
|
|
|
|
struct WinCallbackContext
|
|
|
|
{
|
|
|
|
void* gobody; // Go function to call
|
|
|
|
uintptr argsize; // callback arguments size (in bytes)
|
|
|
|
uintptr restorestack; // adjust stack on return by (in bytes) (386 only)
|
2013-12-18 20:38:50 -07:00
|
|
|
bool cleanstack;
|
2013-07-29 12:22:34 -06:00
|
|
|
};
|
|
|
|
|
2008-07-09 12:35:26 -06:00
|
|
|
struct G
|
2008-07-08 18:19:17 -06:00
|
|
|
{
|
2013-06-03 02:28:24 -06:00
|
|
|
// stackguard0 can be set to StackPreempt as opposed to stackguard
|
|
|
|
uintptr stackguard0; // cannot move - also known to linker, libmach, runtime/cgo
|
2012-05-30 11:07:52 -06:00
|
|
|
uintptr stackbase; // cannot move - also known to libmach, runtime/cgo
|
runtime, cmd/gc, cmd/ld: ignore method wrappers in recover
Bug #1:
Issue 5406 identified an interesting case:
defer iface.M()
may end up calling a wrapper that copies an indirect receiver
from the iface value and then calls the real M method. That's
two calls down, not just one, and so recover() == nil always
in the real M method, even during a panic.
[For the purposes of this entire discussion, a wrapper's
implementation is a function containing an ordinary call, not
the optimized tail call form that is somtimes possible. The
tail call does not create a second frame, so it is already
handled correctly.]
Fix this bug by introducing g->panicwrap, which counts the
number of bytes on current stack segment that are due to
wrapper calls that should not count against the recover
check. All wrapper functions must now adjust g->panicwrap up
on entry and back down on exit. This adds slightly to their
expense; on the x86 it is a single instruction at entry and
exit; on the ARM it is three. However, the alternative is to
make a call to recover depend on being able to walk the stack,
which I very much want to avoid. We have enough problems
walking the stack for garbage collection and profiling.
Also, if performance is critical in a specific case, it is already
faster to use a pointer receiver and avoid this kind of wrapper
entirely.
Bug #2:
The old code, which did not consider the possibility of two
calls, already contained a check to see if the call had split
its stack and so the panic-created segment was one behind the
current segment. In the wrapper case, both of the two calls
might split their stacks, so the panic-created segment can be
two behind the current segment.
Fix this by propagating the Stktop.panic flag forward during
stack splits instead of looking backward during recover.
Fixes #5406.
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13367052
2013-09-12 12:00:16 -06:00
|
|
|
uint32 panicwrap; // cannot move - also known to linker
|
|
|
|
uint32 selgen; // valid sudog pointer
|
2009-06-17 16:12:16 -06:00
|
|
|
Defer* defer;
|
2010-03-31 12:46:01 -06:00
|
|
|
Panic* panic;
|
|
|
|
Gobuf sched;
|
2013-09-10 10:02:22 -06:00
|
|
|
uintptr syscallstack; // if status==Gsyscall, syscallstack = stackbase to use during gc
|
|
|
|
uintptr syscallsp; // if status==Gsyscall, syscallsp = sched.sp to use during gc
|
|
|
|
uintptr syscallpc; // if status==Gsyscall, syscallpc = sched.pc to use during gc
|
|
|
|
uintptr syscallguard; // if status==Gsyscall, syscallguard = stackguard to use during gc
|
2013-06-03 02:28:24 -06:00
|
|
|
uintptr stackguard; // same as stackguard0, but not set to StackPreempt
|
2012-05-30 11:07:52 -06:00
|
|
|
uintptr stack0;
|
2013-08-15 20:34:06 -06:00
|
|
|
uintptr stacksize;
|
2008-07-28 12:29:41 -06:00
|
|
|
G* alllink; // on allg
|
2008-07-25 16:55:12 -06:00
|
|
|
void* param; // passed parameter on wakeup
|
|
|
|
int16 status;
|
2012-10-26 00:13:06 -06:00
|
|
|
int64 goid;
|
2011-08-22 21:26:39 -06:00
|
|
|
int8* waitreason; // if status==Gwaiting
|
2008-08-05 15:18:47 -06:00
|
|
|
G* schedlink;
|
2010-03-31 12:46:01 -06:00
|
|
|
bool ispanic;
|
2013-03-12 07:21:44 -06:00
|
|
|
bool issystem; // do not output in stack dump
|
|
|
|
bool isbackground; // ignore in deadlock detector
|
2013-07-17 10:52:37 -06:00
|
|
|
bool preempt; // preemption signal, duplicates stackguard0 = StackPreempt
|
2013-03-12 07:21:44 -06:00
|
|
|
int8 raceignore; // ignore race detection events
|
2009-06-17 16:12:16 -06:00
|
|
|
M* m; // for debuggers, but offset not hard-coded
|
2009-07-13 18:28:39 -06:00
|
|
|
M* lockedm;
|
2010-04-08 19:15:30 -06:00
|
|
|
int32 sig;
|
2012-02-22 19:45:01 -07:00
|
|
|
int32 writenbuf;
|
|
|
|
byte* writebuf;
|
2013-07-30 13:48:18 -06:00
|
|
|
DeferChunk* dchunk;
|
|
|
|
DeferChunk* dchunknext;
|
2010-04-08 19:15:30 -06:00
|
|
|
uintptr sigcode0;
|
|
|
|
uintptr sigcode1;
|
2011-01-18 12:15:11 -07:00
|
|
|
uintptr sigpc;
|
2013-09-10 10:02:22 -06:00
|
|
|
uintptr gopc; // pc of go statement that created this goroutine
|
2013-02-06 00:40:54 -07:00
|
|
|
uintptr racectx;
|
2011-09-17 01:57:59 -06:00
|
|
|
uintptr end[];
|
2008-08-04 17:43:49 -06:00
|
|
|
};
|
2008-07-08 18:19:17 -06:00
|
|
|
struct M
|
|
|
|
{
|
2009-06-17 16:12:16 -06:00
|
|
|
G* g0; // goroutine with scheduling stack
|
2011-01-14 12:05:20 -07:00
|
|
|
void* moreargp; // argument pointer for more stack
|
2009-06-17 16:12:16 -06:00
|
|
|
Gobuf morebuf; // gobuf arg to morestack
|
|
|
|
|
2009-06-17 17:31:02 -06:00
|
|
|
// Fields not known to debuggers.
|
2011-01-14 12:05:20 -07:00
|
|
|
uint32 moreframesize; // size arguments to morestack
|
|
|
|
uint32 moreargsize;
|
2009-06-17 16:12:16 -06:00
|
|
|
uintptr cret; // return value from C
|
|
|
|
uint64 procid; // for debuggers, but offset not hard-coded
|
|
|
|
G* gsignal; // signal-handling G
|
2013-03-01 07:24:17 -07:00
|
|
|
uintptr tls[4]; // thread-local storage (for x86 extern register)
|
|
|
|
void (*mstartfn)(void);
|
2009-06-17 16:12:16 -06:00
|
|
|
G* curg; // current running goroutine
|
runtime: record proper goroutine state during stack split
Until now, the goroutine state has been scattered during the
execution of newstack and oldstack. It's all there, and those routines
know how to get back to a working goroutine, but other pieces of
the system, like stack traces, do not. If something does interrupt
the newstack or oldstack execution, the rest of the system can't
understand the goroutine. For example, if newstack decides there
is an overflow and calls throw, the stack tracer wouldn't dump the
goroutine correctly.
For newstack to save a useful state snapshot, it needs to be able
to rewind the PC in the function that triggered the split back to
the beginning of the function. (The PC is a few instructions in, just
after the call to morestack.) To make that possible, we change the
prologues to insert a jmp back to the beginning of the function
after the call to morestack. That is, the prologue used to be roughly:
TEXT myfunc
check for split
jmpcond nosplit
call morestack
nosplit:
sub $xxx, sp
Now an extra instruction is inserted after the call:
TEXT myfunc
start:
check for split
jmpcond nosplit
call morestack
jmp start
nosplit:
sub $xxx, sp
The jmp is not executed directly. It is decoded and simulated by
runtime.rewindmorestack to discover the beginning of the function,
and then the call to morestack returns directly to the start label
instead of to the jump instruction. So logically the jmp is still
executed, just not by the cpu.
The prologue thus repeats in the case of a function that needs a
stack split, but against the cost of the split itself, the extra few
instructions are noise. The repeated prologue has the nice effect of
making a stack split double-check that the new stack is big enough:
if morestack happens to return on a too-small stack, we'll now notice
before corruption happens.
The ability for newstack to rewind to the beginning of the function
should help preemption too. If newstack decides that it was called
for preemption instead of a stack split, it now has the goroutine state
correctly paused if rescheduling is needed, and when the goroutine
can run again, it can return to the start label on its original stack
and re-execute the split check.
Here is an example of a split stack overflow showing the full
trace, without any special cases in the stack printer.
(This one was triggered by making the split check incorrect.)
runtime: newstack framesize=0x0 argsize=0x18 sp=0x6aebd0 stack=[0x6b0000, 0x6b0fa0]
morebuf={pc:0x69f5b sp:0x6aebd8 lr:0x0}
sched={pc:0x68880 sp:0x6aebd0 lr:0x0 ctxt:0x34e700}
runtime: split stack overflow: 0x6aebd0 < 0x6b0000
fatal error: runtime: split stack overflow
goroutine 1 [stack split]:
runtime.mallocgc(0x290, 0x100000000, 0x1)
/Users/rsc/g/go/src/pkg/runtime/zmalloc_darwin_amd64.c:21 fp=0x6aebd8
runtime.new()
/Users/rsc/g/go/src/pkg/runtime/zmalloc_darwin_amd64.c:682 +0x5b fp=0x6aec08
go/build.(*Context).Import(0x5ae340, 0xc210030c71, 0xa, 0xc2100b4380, 0x1b, ...)
/Users/rsc/g/go/src/pkg/go/build/build.go:424 +0x3a fp=0x6b00a0
main.loadImport(0xc210030c71, 0xa, 0xc2100b4380, 0x1b, 0xc2100b42c0, ...)
/Users/rsc/g/go/src/cmd/go/pkg.go:249 +0x371 fp=0x6b01a8
main.(*Package).load(0xc21017c800, 0xc2100b42c0, 0xc2101828c0, 0x0, 0x0, ...)
/Users/rsc/g/go/src/cmd/go/pkg.go:431 +0x2801 fp=0x6b0c98
main.loadPackage(0x369040, 0x7, 0xc2100b42c0, 0x0)
/Users/rsc/g/go/src/cmd/go/pkg.go:709 +0x857 fp=0x6b0f80
----- stack segment boundary -----
main.(*builder).action(0xc2100902a0, 0x0, 0x0, 0xc2100e6c00, 0xc2100e5750, ...)
/Users/rsc/g/go/src/cmd/go/build.go:539 +0x437 fp=0x6b14a0
main.(*builder).action(0xc2100902a0, 0x0, 0x0, 0xc21015b400, 0x2, ...)
/Users/rsc/g/go/src/cmd/go/build.go:528 +0x1d2 fp=0x6b1658
main.(*builder).test(0xc2100902a0, 0xc210092000, 0x0, 0x0, 0xc21008ff60, ...)
/Users/rsc/g/go/src/cmd/go/test.go:622 +0x1b53 fp=0x6b1f68
----- stack segment boundary -----
main.runTest(0x5a6b20, 0xc21000a020, 0x2, 0x2)
/Users/rsc/g/go/src/cmd/go/test.go:366 +0xd09 fp=0x6a5cf0
main.main()
/Users/rsc/g/go/src/cmd/go/main.go:161 +0x4f9 fp=0x6a5f78
runtime.main()
/Users/rsc/g/go/src/pkg/runtime/proc.c:183 +0x92 fp=0x6a5fa0
runtime.goexit()
/Users/rsc/g/go/src/pkg/runtime/proc.c:1266 fp=0x6a5fa8
And here is a seg fault during oldstack:
SIGSEGV: segmentation violation
PC=0x1b2a6
runtime.oldstack()
/Users/rsc/g/go/src/pkg/runtime/stack.c:159 +0x76
runtime.lessstack()
/Users/rsc/g/go/src/pkg/runtime/asm_amd64.s:270 +0x22
goroutine 1 [stack unsplit]:
fmt.(*pp).printArg(0x2102e64e0, 0xe5c80, 0x2102c9220, 0x73, 0x0, ...)
/Users/rsc/g/go/src/pkg/fmt/print.go:818 +0x3d3 fp=0x221031e6f8
fmt.(*pp).doPrintf(0x2102e64e0, 0x12fb20, 0x2, 0x221031eb98, 0x1, ...)
/Users/rsc/g/go/src/pkg/fmt/print.go:1183 +0x15cb fp=0x221031eaf0
fmt.Sprintf(0x12fb20, 0x2, 0x221031eb98, 0x1, 0x1, ...)
/Users/rsc/g/go/src/pkg/fmt/print.go:234 +0x67 fp=0x221031eb40
flag.(*stringValue).String(0x2102c9210, 0x1, 0x0)
/Users/rsc/g/go/src/pkg/flag/flag.go:180 +0xb3 fp=0x221031ebb0
flag.(*FlagSet).Var(0x2102f6000, 0x293d38, 0x2102c9210, 0x143490, 0xa, ...)
/Users/rsc/g/go/src/pkg/flag/flag.go:633 +0x40 fp=0x221031eca0
flag.(*FlagSet).StringVar(0x2102f6000, 0x2102c9210, 0x143490, 0xa, 0x12fa60, ...)
/Users/rsc/g/go/src/pkg/flag/flag.go:550 +0x91 fp=0x221031ece8
flag.(*FlagSet).String(0x2102f6000, 0x143490, 0xa, 0x12fa60, 0x0, ...)
/Users/rsc/g/go/src/pkg/flag/flag.go:563 +0x87 fp=0x221031ed38
flag.String(0x143490, 0xa, 0x12fa60, 0x0, 0x161950, ...)
/Users/rsc/g/go/src/pkg/flag/flag.go:570 +0x6b fp=0x221031ed80
testing.init()
/Users/rsc/g/go/src/pkg/testing/testing.go:-531 +0xbb fp=0x221031edc0
strings_test.init()
/Users/rsc/g/go/src/pkg/strings/strings_test.go:1115 +0x62 fp=0x221031ef70
main.init()
strings/_test/_testmain.go:90 +0x3d fp=0x221031ef78
runtime.main()
/Users/rsc/g/go/src/pkg/runtime/proc.c:180 +0x8a fp=0x221031efa0
runtime.goexit()
/Users/rsc/g/go/src/pkg/runtime/proc.c:1269 fp=0x221031efa8
goroutine 2 [runnable]:
runtime.MHeap_Scavenger()
/Users/rsc/g/go/src/pkg/runtime/mheap.c:438
runtime.goexit()
/Users/rsc/g/go/src/pkg/runtime/proc.c:1269
created by runtime.main
/Users/rsc/g/go/src/pkg/runtime/proc.c:166
rax 0x23ccc0
rbx 0x23ccc0
rcx 0x0
rdx 0x38
rdi 0x2102c0170
rsi 0x221032cfe0
rbp 0x221032cfa0
rsp 0x7fff5fbff5b0
r8 0x2102c0120
r9 0x221032cfa0
r10 0x221032c000
r11 0x104ce8
r12 0xe5c80
r13 0x1be82baac718
r14 0x13091135f7d69200
r15 0x0
rip 0x1b2a6
rflags 0x10246
cs 0x2b
fs 0x0
gs 0x0
Fixes #5723.
R=r, dvyukov, go.peter.90, dave, iant
CC=golang-dev
https://golang.org/cl/10360048
2013-06-27 09:32:01 -06:00
|
|
|
G* caughtsig; // goroutine running during fatal signal
|
2013-03-01 04:49:16 -07:00
|
|
|
P* p; // attached P for executing Go code (nil if not executing Go code)
|
|
|
|
P* nextp;
|
2008-11-25 17:48:10 -07:00
|
|
|
int32 id;
|
2008-12-19 04:13:39 -07:00
|
|
|
int32 mallocing;
|
2013-01-29 03:57:11 -07:00
|
|
|
int32 throwing;
|
2009-06-15 22:31:56 -06:00
|
|
|
int32 gcing;
|
2009-01-26 18:37:05 -07:00
|
|
|
int32 locks;
|
2011-02-16 11:21:13 -07:00
|
|
|
int32 dying;
|
2011-03-23 09:43:37 -06:00
|
|
|
int32 profilehz;
|
runtime: parallelize garbage collector mark + sweep
Running test/garbage/parser.out.
On a 4-core Lenovo X201s (Linux):
31.12u 0.60s 31.74r 1 cpu, no atomics
32.27u 0.58s 32.86r 1 cpu, atomic instructions
33.04u 0.83s 27.47r 2 cpu
On a 16-core Xeon (Linux):
33.08u 0.65s 33.80r 1 cpu, no atomics
34.87u 1.12s 29.60r 2 cpu
36.00u 1.87s 28.43r 3 cpu
36.46u 2.34s 27.10r 4 cpu
38.28u 3.85s 26.92r 5 cpu
37.72u 5.25s 26.73r 6 cpu
39.63u 7.11s 26.95r 7 cpu
39.67u 8.10s 26.68r 8 cpu
On a 2-core MacBook Pro Core 2 Duo 2.26 (circa 2009, MacBookPro5,5):
39.43u 1.45s 41.27r 1 cpu, no atomics
43.98u 2.95s 38.69r 2 cpu
On a 2-core Mac Mini Core 2 Duo 1.83 (circa 2008; Macmini2,1):
48.81u 2.12s 51.76r 1 cpu, no atomics
57.15u 4.72s 51.54r 2 cpu
The handoff algorithm is really only good for two cores.
Beyond that we will need to so something more sophisticated,
like have each core hand off to the next one, around a circle.
Even so, the code is a good checkpoint; for now we'll limit the
number of gc procs to at most 2.
R=dvyukov
CC=golang-dev
https://golang.org/cl/4641082
2011-09-30 07:40:01 -06:00
|
|
|
int32 helpgc;
|
2013-03-01 04:49:16 -07:00
|
|
|
bool spinning;
|
2011-07-11 23:23:58 -06:00
|
|
|
uint32 fastrand;
|
2012-11-10 12:19:06 -07:00
|
|
|
uint64 ncgocall; // number of cgo calls in total
|
|
|
|
int32 ncgo; // number of cgo calls currently in progress
|
|
|
|
CgoMal* cgomal;
|
2013-03-01 04:49:16 -07:00
|
|
|
Note park;
|
2009-10-09 16:35:33 -06:00
|
|
|
M* alllink; // on allm
|
2008-08-05 15:18:47 -06:00
|
|
|
M* schedlink;
|
2008-09-09 12:50:14 -06:00
|
|
|
uint32 machport; // Return address for Mach IPC (OS X)
|
2013-07-30 13:48:18 -06:00
|
|
|
MCache* mcache;
|
2013-01-09 22:57:06 -07:00
|
|
|
int32 stackinuse;
|
|
|
|
uint32 stackcachepos;
|
|
|
|
uint32 stackcachecnt;
|
|
|
|
void* stackcache[StackCacheSize];
|
2009-07-13 18:28:39 -06:00
|
|
|
G* lockedg;
|
2013-09-10 10:02:22 -06:00
|
|
|
uintptr createstack[32];// Stack that created this thread.
|
2010-12-09 15:45:27 -07:00
|
|
|
uint32 freglo[16]; // D[i] lsb and F[i]
|
|
|
|
uint32 freghi[16]; // D[i] msb and F[i+16]
|
|
|
|
uint32 fflag; // floating point compare flags
|
2013-09-10 10:02:22 -06:00
|
|
|
uint32 locked; // tracking for LockOSThread
|
2011-11-02 07:42:01 -06:00
|
|
|
M* nextwaitm; // next M waiting for lock
|
|
|
|
uintptr waitsema; // semaphore for parking on locks
|
|
|
|
uint32 waitsemacount;
|
|
|
|
uint32 waitsemalock;
|
2012-04-05 10:48:28 -06:00
|
|
|
GCStats gcstats;
|
2012-10-07 12:05:32 -06:00
|
|
|
bool racecall;
|
2013-02-20 15:48:23 -07:00
|
|
|
bool needextram;
|
2013-03-01 04:49:16 -07:00
|
|
|
void (*waitunlockf)(Lock*);
|
2013-04-06 21:01:28 -06:00
|
|
|
void* waitlock;
|
runtime: add timer support, use for package time
This looks like it is just moving some code from
time to runtime (and translating it to C), but the
runtime can do a better job managing the goroutines,
and it needs this functionality for its own maintenance
(for example, for the garbage collector to hand back
unused memory to the OS on a time delay).
Might as well have just one copy of the timer logic,
and runtime can't depend on time, so vice versa.
It also unifies Sleep, NewTicker, and NewTimer behind
one mechanism, so that there are no claims that one
is more efficient than another. (For example, today
people recommend using time.After instead of time.Sleep
to avoid blocking an OS thread.)
Fixes #1644.
Fixes #1731.
Fixes #2190.
R=golang-dev, r, hectorchu, iant, iant, jsing, alex.brainman, dvyukov
CC=golang-dev
https://golang.org/cl/5334051
2011-11-09 13:17:05 -07:00
|
|
|
|
2012-09-24 18:08:05 -06:00
|
|
|
uintptr settype_buf[1024];
|
|
|
|
uintptr settype_bufsize;
|
|
|
|
|
2011-12-16 13:33:58 -07:00
|
|
|
#ifdef GOOS_windows
|
2011-09-17 01:57:59 -06:00
|
|
|
void* thread; // thread handle
|
2013-07-29 12:22:34 -06:00
|
|
|
WinCall wincall;
|
2013-01-30 03:53:56 -07:00
|
|
|
#endif
|
|
|
|
#ifdef GOOS_plan9
|
2013-07-30 13:48:18 -06:00
|
|
|
int8* notesig;
|
2013-03-07 16:54:44 -07:00
|
|
|
byte* errstr;
|
2011-09-14 18:23:21 -06:00
|
|
|
#endif
|
2012-05-29 23:10:54 -06:00
|
|
|
SEH* seh;
|
2011-09-17 01:57:59 -06:00
|
|
|
uintptr end[];
|
2008-07-11 20:16:39 -06:00
|
|
|
};
|
runtime: stack split + garbage collection bug
The g->sched.sp saved stack pointer and the
g->stackbase and g->stackguard stack bounds
can change even while "the world is stopped",
because a goroutine has to call functions (and
therefore might split its stack) when exiting a
system call to check whether the world is stopped
(and if so, wait until the world continues).
That means the garbage collector cannot access
those values safely (without a race) for goroutines
executing system calls. Instead, save a consistent
triple in g->gcsp, g->gcstack, g->gcguard during
entersyscall and have the garbage collector refer
to those.
The old code was occasionally seeing (because of
the race) an sp and stk that did not correspond to
each other, so that stk - sp was not the number of
stack bytes following sp. In that case, if sp < stk
then the call scanblock(sp, stk - sp) scanned too
many bytes (anything between the two pointers,
which pointed into different allocation blocks).
If sp > stk then stk - sp wrapped around.
On 32-bit, stk - sp is a uintptr (uint32) converted
to int64 in the call to scanblock, so a large (~4G)
but positive number. Scanblock would try to scan
that many bytes and eventually fault accessing
unmapped memory. On 64-bit, stk - sp is a uintptr (uint64)
promoted to int64 in the call to scanblock, so a negative
number. Scanblock would not scan anything, possibly
causing in-use blocks to be freed.
In short, 32-bit platforms would have seen either
ineffective garbage collection or crashes during garbage
collection, while 64-bit platforms would have seen
either ineffective or incorrect garbage collection.
You can see the invalid arguments to scanblock in the
stack traces in issue 1620.
Fixes #1620.
Fixes #1746.
R=iant, r
CC=golang-dev
https://golang.org/cl/4437075
2011-04-27 21:21:12 -06:00
|
|
|
|
2013-02-22 21:48:02 -07:00
|
|
|
struct P
|
|
|
|
{
|
|
|
|
Lock;
|
|
|
|
|
2013-08-13 14:30:55 -06:00
|
|
|
int32 id;
|
2013-09-10 10:02:22 -06:00
|
|
|
uint32 status; // one of Pidle/Prunning/...
|
2013-02-27 12:17:53 -07:00
|
|
|
P* link;
|
2013-08-13 12:14:04 -06:00
|
|
|
uint32 schedtick; // incremented on every scheduler call
|
|
|
|
uint32 syscalltick; // incremented on every system call
|
2013-09-10 10:02:22 -06:00
|
|
|
M* m; // back-link to associated M (nil if idle)
|
2013-03-01 04:49:16 -07:00
|
|
|
MCache* mcache;
|
2013-02-27 12:17:53 -07:00
|
|
|
|
2013-02-22 21:48:02 -07:00
|
|
|
// Queue of runnable goroutines.
|
|
|
|
G** runq;
|
|
|
|
int32 runqhead;
|
|
|
|
int32 runqtail;
|
|
|
|
int32 runqsize;
|
2013-02-27 12:17:53 -07:00
|
|
|
|
|
|
|
// Available G's (status == Gdead)
|
|
|
|
G* gfree;
|
|
|
|
int32 gfreecnt;
|
|
|
|
|
|
|
|
byte pad[64];
|
2013-02-22 21:48:02 -07:00
|
|
|
};
|
|
|
|
|
2013-07-22 06:37:31 -06:00
|
|
|
// The m->locked word holds two pieces of state counting active calls to LockOSThread/lockOSThread.
|
|
|
|
// The low bit (LockExternal) is a boolean reporting whether any LockOSThread call is active.
|
|
|
|
// External locks are not recursive; a second lock is silently ignored.
|
|
|
|
// The upper bits of m->lockedcount record the nesting depth of calls to lockOSThread
|
|
|
|
// (counting up by LockInternal), popped by unlockOSThread (counting down by LockInternal).
|
|
|
|
// Internal locks can be recursive. For instance, a lock for cgo can occur while the main
|
|
|
|
// goroutine is holding the lock during the initialization phase.
|
2013-02-01 09:34:41 -07:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
LockExternal = 1,
|
|
|
|
LockInternal = 2,
|
|
|
|
};
|
|
|
|
|
2008-07-14 15:33:39 -06:00
|
|
|
struct Stktop
|
2008-07-13 15:29:46 -06:00
|
|
|
{
|
2009-06-17 17:31:02 -06:00
|
|
|
// The offsets of these fields are known to (hard-coded in) libmach.
|
2013-06-12 06:49:38 -06:00
|
|
|
uintptr stackguard;
|
|
|
|
uintptr stackbase;
|
2009-06-17 16:12:16 -06:00
|
|
|
Gobuf gobuf;
|
2011-01-14 12:05:20 -07:00
|
|
|
uint32 argsize;
|
runtime, cmd/gc, cmd/ld: ignore method wrappers in recover
Bug #1:
Issue 5406 identified an interesting case:
defer iface.M()
may end up calling a wrapper that copies an indirect receiver
from the iface value and then calls the real M method. That's
two calls down, not just one, and so recover() == nil always
in the real M method, even during a panic.
[For the purposes of this entire discussion, a wrapper's
implementation is a function containing an ordinary call, not
the optimized tail call form that is somtimes possible. The
tail call does not create a second frame, so it is already
handled correctly.]
Fix this bug by introducing g->panicwrap, which counts the
number of bytes on current stack segment that are due to
wrapper calls that should not count against the recover
check. All wrapper functions must now adjust g->panicwrap up
on entry and back down on exit. This adds slightly to their
expense; on the x86 it is a single instruction at entry and
exit; on the ARM it is three. However, the alternative is to
make a call to recover depend on being able to walk the stack,
which I very much want to avoid. We have enough problems
walking the stack for garbage collection and profiling.
Also, if performance is critical in a specific case, it is already
faster to use a pointer receiver and avoid this kind of wrapper
entirely.
Bug #2:
The old code, which did not consider the possibility of two
calls, already contained a check to see if the call had split
its stack and so the panic-created segment was one behind the
current segment. In the wrapper case, both of the two calls
might split their stacks, so the panic-created segment can be
two behind the current segment.
Fix this by propagating the Stktop.panic flag forward during
stack splits instead of looking backward during recover.
Fixes #5406.
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/13367052
2013-09-12 12:00:16 -06:00
|
|
|
uint32 panicwrap;
|
2009-07-08 19:16:09 -06:00
|
|
|
|
2011-01-25 14:35:36 -07:00
|
|
|
uint8* argp; // pointer to arguments in old frame
|
|
|
|
uintptr free; // if free>0, call stackfree using free as size
|
2010-03-31 12:46:01 -06:00
|
|
|
bool panic; // is this frame the top of a panic?
|
2008-07-08 18:19:17 -06:00
|
|
|
};
|
2008-07-13 15:29:46 -06:00
|
|
|
struct SigTab
|
2008-06-05 20:38:39 -06:00
|
|
|
{
|
2008-12-03 15:21:28 -07:00
|
|
|
int32 flags;
|
2008-07-13 15:29:46 -06:00
|
|
|
int8 *name;
|
2008-06-05 20:38:39 -06:00
|
|
|
};
|
2008-12-03 15:21:28 -07:00
|
|
|
enum
|
|
|
|
{
|
os/signal: selective signal handling
Restore package os/signal, with new API:
Notify replaces Incoming, allowing clients
to ask for certain signals only. Also, signals
go to everyone who asks, not just one client.
This could plausibly move into package os now
that there are no magic side effects as a result
of the import.
Update runtime for new API: move common Unix
signal handling code into signal_unix.c.
(It's so easy to do this now that we don't have
to edit Makefiles!)
Tested on darwin,linux 386,amd64.
Fixes #1266.
R=r, dsymonds, bradfitz, iant, borman
CC=golang-dev
https://golang.org/cl/3749041
2012-02-13 11:52:37 -07:00
|
|
|
SigNotify = 1<<0, // let signal.Notify have signal, even if from kernel
|
2012-02-16 20:36:40 -07:00
|
|
|
SigKill = 1<<1, // if signal.Notify doesn't take it, exit quietly
|
|
|
|
SigThrow = 1<<2, // if signal.Notify doesn't take it, exit loudly
|
|
|
|
SigPanic = 1<<3, // if the signal is from the kernel, panic
|
|
|
|
SigDefault = 1<<4, // if the signal isn't explicitly requested, don't monitor it
|
2013-03-14 22:00:02 -06:00
|
|
|
SigHandling = 1<<5, // our signal handler is registered
|
|
|
|
SigIgnored = 1<<6, // the signal was ignored before we registered for it
|
2008-12-03 15:21:28 -07:00
|
|
|
};
|
2008-06-05 20:38:39 -06:00
|
|
|
|
2013-07-18 08:43:22 -06:00
|
|
|
// Layout of in-memory per-function information prepared by linker
|
2013-07-16 07:41:38 -06:00
|
|
|
// See http://golang.org/s/go12symtab.
|
2013-07-18 08:43:22 -06:00
|
|
|
// Keep in sync with linker and with ../../libmach/sym.c
|
|
|
|
// and with package debug/gosym.
|
2008-11-23 18:08:55 -07:00
|
|
|
struct Func
|
|
|
|
{
|
2013-07-16 07:41:38 -06:00
|
|
|
uintptr entry; // start pc
|
2013-09-10 10:02:22 -06:00
|
|
|
int32 nameoff;// function name
|
2013-07-16 07:41:38 -06:00
|
|
|
|
cmd/5g, cmd/5l, cmd/6l, cmd/8l, cmd/gc, cmd/ld, runtime: accurate args and locals information
Previously, the func structure contained an inaccurate value for
the args member and a 0 value for the locals member.
This change populates the func structure with args and locals
values computed by the compiler. The number of args was
already available in the ATEXT instruction. The number of
locals is now passed through in the new ALOCALS instruction.
This change also switches the unit of args and locals to be
bytes, just like the frame member, instead of 32-bit words.
R=golang-dev, bradfitz, cshapiro, dave, rsc
CC=golang-dev
https://golang.org/cl/7399045
2013-02-21 13:52:26 -07:00
|
|
|
int32 args; // in/out args size
|
2013-07-16 07:41:38 -06:00
|
|
|
int32 frame; // legacy frame size; use pcsp if possible
|
|
|
|
|
|
|
|
int32 pcsp;
|
|
|
|
int32 pcfile;
|
|
|
|
int32 pcln;
|
|
|
|
int32 npcdata;
|
|
|
|
int32 nfuncdata;
|
2008-11-23 18:08:55 -07:00
|
|
|
};
|
|
|
|
|
2012-11-01 11:13:20 -06:00
|
|
|
// layout of Itab known to compilers
|
2013-06-09 11:58:35 -06:00
|
|
|
// allocated in non-garbage-collected memory
|
2012-11-01 11:13:20 -06:00
|
|
|
struct Itab
|
|
|
|
{
|
|
|
|
InterfaceType* inter;
|
|
|
|
Type* type;
|
|
|
|
Itab* link;
|
|
|
|
int32 bad;
|
|
|
|
int32 unused;
|
|
|
|
void (*fun[])(void);
|
|
|
|
};
|
|
|
|
|
2011-12-16 13:33:58 -07:00
|
|
|
#ifdef GOOS_windows
|
2010-09-11 19:45:16 -06:00
|
|
|
enum {
|
|
|
|
Windows = 1
|
|
|
|
};
|
|
|
|
#else
|
|
|
|
enum {
|
|
|
|
Windows = 0
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
runtime: add timer support, use for package time
This looks like it is just moving some code from
time to runtime (and translating it to C), but the
runtime can do a better job managing the goroutines,
and it needs this functionality for its own maintenance
(for example, for the garbage collector to hand back
unused memory to the OS on a time delay).
Might as well have just one copy of the timer logic,
and runtime can't depend on time, so vice versa.
It also unifies Sleep, NewTicker, and NewTimer behind
one mechanism, so that there are no claims that one
is more efficient than another. (For example, today
people recommend using time.After instead of time.Sleep
to avoid blocking an OS thread.)
Fixes #1644.
Fixes #1731.
Fixes #2190.
R=golang-dev, r, hectorchu, iant, iant, jsing, alex.brainman, dvyukov
CC=golang-dev
https://golang.org/cl/5334051
2011-11-09 13:17:05 -07:00
|
|
|
struct Timers
|
|
|
|
{
|
|
|
|
Lock;
|
|
|
|
G *timerproc;
|
|
|
|
bool sleeping;
|
|
|
|
bool rescheduling;
|
|
|
|
Note waitnote;
|
|
|
|
Timer **t;
|
|
|
|
int32 len;
|
|
|
|
int32 cap;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Package time knows the layout of this structure.
|
|
|
|
// If this struct changes, adjust ../time/sleep.go:/runtimeTimer.
|
|
|
|
struct Timer
|
|
|
|
{
|
2013-09-10 10:02:22 -06:00
|
|
|
int32 i; // heap index
|
runtime: add timer support, use for package time
This looks like it is just moving some code from
time to runtime (and translating it to C), but the
runtime can do a better job managing the goroutines,
and it needs this functionality for its own maintenance
(for example, for the garbage collector to hand back
unused memory to the OS on a time delay).
Might as well have just one copy of the timer logic,
and runtime can't depend on time, so vice versa.
It also unifies Sleep, NewTicker, and NewTimer behind
one mechanism, so that there are no claims that one
is more efficient than another. (For example, today
people recommend using time.After instead of time.Sleep
to avoid blocking an OS thread.)
Fixes #1644.
Fixes #1731.
Fixes #2190.
R=golang-dev, r, hectorchu, iant, iant, jsing, alex.brainman, dvyukov
CC=golang-dev
https://golang.org/cl/5334051
2011-11-09 13:17:05 -07:00
|
|
|
|
|
|
|
// Timer wakes up at when, and then at when+period, ... (period > 0 only)
|
|
|
|
// each time calling f(now, arg) in the timer goroutine, so f must be
|
|
|
|
// a well-behaved function and not block.
|
|
|
|
int64 when;
|
|
|
|
int64 period;
|
2013-02-21 15:01:13 -07:00
|
|
|
FuncVal *fv;
|
runtime: add timer support, use for package time
This looks like it is just moving some code from
time to runtime (and translating it to C), but the
runtime can do a better job managing the goroutines,
and it needs this functionality for its own maintenance
(for example, for the garbage collector to hand back
unused memory to the OS on a time delay).
Might as well have just one copy of the timer logic,
and runtime can't depend on time, so vice versa.
It also unifies Sleep, NewTicker, and NewTimer behind
one mechanism, so that there are no claims that one
is more efficient than another. (For example, today
people recommend using time.After instead of time.Sleep
to avoid blocking an OS thread.)
Fixes #1644.
Fixes #1731.
Fixes #2190.
R=golang-dev, r, hectorchu, iant, iant, jsing, alex.brainman, dvyukov
CC=golang-dev
https://golang.org/cl/5334051
2011-11-09 13:17:05 -07:00
|
|
|
Eface arg;
|
|
|
|
};
|
|
|
|
|
2012-04-12 01:49:25 -06:00
|
|
|
// Lock-free stack node.
|
|
|
|
struct LFNode
|
|
|
|
{
|
|
|
|
LFNode *next;
|
|
|
|
uintptr pushcnt;
|
|
|
|
};
|
|
|
|
|
2012-05-11 00:50:03 -06:00
|
|
|
// Parallel for descriptor.
|
|
|
|
struct ParFor
|
|
|
|
{
|
|
|
|
void (*body)(ParFor*, uint32); // executed for each element
|
|
|
|
uint32 done; // number of idle threads
|
|
|
|
uint32 nthr; // total number of threads
|
|
|
|
uint32 nthrmax; // maximum number of threads
|
|
|
|
uint32 thrseq; // thread id sequencer
|
|
|
|
uint32 cnt; // iteration space [0, cnt)
|
|
|
|
void *ctx; // arbitrary user context
|
|
|
|
bool wait; // if true, wait while all threads finish processing,
|
|
|
|
// otherwise parfor may return while other threads are still working
|
|
|
|
ParForThread *thr; // array of thread descriptors
|
2013-03-10 10:46:11 -06:00
|
|
|
uint32 pad; // to align ParForThread.pos for 64-bit atomic operations
|
2012-05-11 00:50:03 -06:00
|
|
|
// stats
|
|
|
|
uint64 nsteal;
|
|
|
|
uint64 nstealcnt;
|
|
|
|
uint64 nprocyield;
|
|
|
|
uint64 nosyield;
|
|
|
|
uint64 nsleep;
|
|
|
|
};
|
|
|
|
|
2012-11-10 12:19:06 -07:00
|
|
|
// Track memory allocated by code not written in Go during a cgo call,
|
|
|
|
// so that the garbage collector can see them.
|
|
|
|
struct CgoMal
|
|
|
|
{
|
|
|
|
CgoMal *next;
|
2013-04-06 21:18:15 -06:00
|
|
|
void *alloc;
|
2012-11-10 12:19:06 -07:00
|
|
|
};
|
|
|
|
|
2013-06-28 08:37:06 -06:00
|
|
|
// Holds variables parsed from GODEBUG env var.
|
|
|
|
struct DebugVars
|
|
|
|
{
|
2013-12-03 15:42:38 -07:00
|
|
|
int32 allocfreetrace;
|
2013-12-06 15:40:45 -07:00
|
|
|
int32 efence;
|
2013-06-28 08:37:06 -06:00
|
|
|
int32 gctrace;
|
2013-08-13 14:30:55 -06:00
|
|
|
int32 scheddetail;
|
2013-12-03 15:42:38 -07:00
|
|
|
int32 schedtrace;
|
2013-06-28 08:37:06 -06:00
|
|
|
};
|
|
|
|
|
2013-09-16 18:26:10 -06:00
|
|
|
extern bool runtime·precisestack;
|
|
|
|
|
2008-06-05 20:38:39 -06:00
|
|
|
/*
|
|
|
|
* defined macros
|
2011-05-30 02:02:59 -06:00
|
|
|
* you need super-gopher-guru privilege
|
2008-06-05 20:38:39 -06:00
|
|
|
* to add this list.
|
|
|
|
*/
|
|
|
|
#define nelem(x) (sizeof(x)/sizeof((x)[0]))
|
|
|
|
#define nil ((void*)0)
|
2010-12-13 14:22:19 -07:00
|
|
|
#define offsetof(s,m) (uint32)(&(((s*)0)->m))
|
2012-05-29 12:02:29 -06:00
|
|
|
#define ROUND(x, n) (((x)+(n)-1)&~((n)-1)) /* all-caps to mark as macro: it evaluates n twice */
|
2008-06-05 20:38:39 -06:00
|
|
|
|
2008-12-19 13:05:22 -07:00
|
|
|
/*
|
|
|
|
* known to compiler
|
|
|
|
*/
|
2011-12-05 07:40:22 -07:00
|
|
|
enum {
|
|
|
|
Structrnd = sizeof(uintptr)
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* type algorithms - known to compiler
|
|
|
|
*/
|
2008-12-19 13:05:22 -07:00
|
|
|
enum
|
|
|
|
{
|
2009-01-26 10:56:42 -07:00
|
|
|
AMEM,
|
2012-01-19 23:32:55 -07:00
|
|
|
AMEM0,
|
2011-08-08 07:35:32 -06:00
|
|
|
AMEM8,
|
|
|
|
AMEM16,
|
|
|
|
AMEM32,
|
|
|
|
AMEM64,
|
|
|
|
AMEM128,
|
2011-12-12 20:22:09 -07:00
|
|
|
ANOEQ,
|
2012-01-19 23:32:55 -07:00
|
|
|
ANOEQ0,
|
2011-08-08 07:35:32 -06:00
|
|
|
ANOEQ8,
|
|
|
|
ANOEQ16,
|
|
|
|
ANOEQ32,
|
|
|
|
ANOEQ64,
|
|
|
|
ANOEQ128,
|
2011-12-12 20:22:09 -07:00
|
|
|
ASTRING,
|
|
|
|
AINTER,
|
|
|
|
ANILINTER,
|
|
|
|
ASLICE,
|
2012-01-26 14:25:07 -07:00
|
|
|
AFLOAT32,
|
|
|
|
AFLOAT64,
|
|
|
|
ACPLX64,
|
|
|
|
ACPLX128,
|
2009-01-26 10:56:42 -07:00
|
|
|
Amax
|
2008-12-19 13:05:22 -07:00
|
|
|
};
|
2011-12-05 07:40:22 -07:00
|
|
|
typedef struct Alg Alg;
|
|
|
|
struct Alg
|
|
|
|
{
|
|
|
|
void (*hash)(uintptr*, uintptr, void*);
|
|
|
|
void (*equal)(bool*, uintptr, void*, void*);
|
|
|
|
void (*print)(uintptr, void*);
|
|
|
|
void (*copy)(uintptr, void*, void*);
|
|
|
|
};
|
2008-12-19 13:05:22 -07:00
|
|
|
|
2011-12-05 07:40:22 -07:00
|
|
|
extern Alg runtime·algarray[Amax];
|
2009-07-02 22:25:46 -06:00
|
|
|
|
2013-03-12 11:47:44 -06:00
|
|
|
byte* runtime·startup_random_data;
|
|
|
|
uint32 runtime·startup_random_data_len;
|
|
|
|
void runtime·get_random_data(byte**, int32*);
|
|
|
|
|
|
|
|
enum {
|
|
|
|
// hashinit wants this many random bytes
|
|
|
|
HashRandomBytes = 32
|
|
|
|
};
|
|
|
|
void runtime·hashinit(void);
|
|
|
|
|
2011-12-05 07:40:22 -07:00
|
|
|
void runtime·memhash(uintptr*, uintptr, void*);
|
|
|
|
void runtime·nohash(uintptr*, uintptr, void*);
|
|
|
|
void runtime·strhash(uintptr*, uintptr, void*);
|
|
|
|
void runtime·interhash(uintptr*, uintptr, void*);
|
|
|
|
void runtime·nilinterhash(uintptr*, uintptr, void*);
|
2013-03-12 11:47:44 -06:00
|
|
|
void runtime·aeshash(uintptr*, uintptr, void*);
|
|
|
|
void runtime·aeshash32(uintptr*, uintptr, void*);
|
|
|
|
void runtime·aeshash64(uintptr*, uintptr, void*);
|
|
|
|
void runtime·aeshashstr(uintptr*, uintptr, void*);
|
2011-12-05 07:40:22 -07:00
|
|
|
|
|
|
|
void runtime·memequal(bool*, uintptr, void*, void*);
|
|
|
|
void runtime·noequal(bool*, uintptr, void*, void*);
|
|
|
|
void runtime·strequal(bool*, uintptr, void*, void*);
|
|
|
|
void runtime·interequal(bool*, uintptr, void*, void*);
|
|
|
|
void runtime·nilinterequal(bool*, uintptr, void*, void*);
|
|
|
|
|
2013-04-02 17:26:15 -06:00
|
|
|
bool runtime·memeq(void*, void*, uintptr);
|
|
|
|
|
2011-12-05 07:40:22 -07:00
|
|
|
void runtime·memprint(uintptr, void*);
|
|
|
|
void runtime·strprint(uintptr, void*);
|
|
|
|
void runtime·interprint(uintptr, void*);
|
|
|
|
void runtime·nilinterprint(uintptr, void*);
|
|
|
|
|
|
|
|
void runtime·memcopy(uintptr, void*, void*);
|
|
|
|
void runtime·memcopy8(uintptr, void*, void*);
|
|
|
|
void runtime·memcopy16(uintptr, void*, void*);
|
|
|
|
void runtime·memcopy32(uintptr, void*, void*);
|
|
|
|
void runtime·memcopy64(uintptr, void*, void*);
|
|
|
|
void runtime·memcopy128(uintptr, void*, void*);
|
|
|
|
void runtime·strcopy(uintptr, void*, void*);
|
|
|
|
void runtime·algslicecopy(uintptr, void*, void*);
|
|
|
|
void runtime·intercopy(uintptr, void*, void*);
|
|
|
|
void runtime·nilintercopy(uintptr, void*, void*);
|
2009-07-02 22:25:46 -06:00
|
|
|
|
2009-01-27 13:03:53 -07:00
|
|
|
/*
|
2009-01-27 14:23:28 -07:00
|
|
|
* deferred subroutine calls
|
2009-01-27 13:03:53 -07:00
|
|
|
*/
|
|
|
|
struct Defer
|
|
|
|
{
|
|
|
|
int32 siz;
|
2013-09-10 10:02:22 -06:00
|
|
|
bool special; // not part of defer frame
|
|
|
|
bool free; // if special, free when done
|
|
|
|
byte* argp; // where args were copied from
|
2010-03-31 12:46:01 -06:00
|
|
|
byte* pc;
|
2013-02-21 15:01:13 -07:00
|
|
|
FuncVal* fn;
|
2009-01-27 13:03:53 -07:00
|
|
|
Defer* link;
|
2012-05-30 11:07:52 -06:00
|
|
|
void* args[1]; // padded to actual size
|
2009-01-27 13:03:53 -07:00
|
|
|
};
|
|
|
|
|
2012-12-22 12:54:39 -07:00
|
|
|
struct DeferChunk
|
|
|
|
{
|
|
|
|
DeferChunk *prev;
|
|
|
|
uintptr off;
|
|
|
|
};
|
|
|
|
|
2010-03-31 12:46:01 -06:00
|
|
|
/*
|
|
|
|
* panics
|
|
|
|
*/
|
|
|
|
struct Panic
|
|
|
|
{
|
|
|
|
Eface arg; // argument to panic
|
2013-06-12 06:49:38 -06:00
|
|
|
uintptr stackbase; // g->stackbase in panic
|
2010-03-31 12:46:01 -06:00
|
|
|
Panic* link; // link to earlier panic
|
|
|
|
bool recovered; // whether this panic is over
|
|
|
|
};
|
|
|
|
|
2013-06-12 06:49:38 -06:00
|
|
|
/*
|
|
|
|
* stack traces
|
|
|
|
*/
|
|
|
|
typedef struct Stkframe Stkframe;
|
|
|
|
struct Stkframe
|
|
|
|
{
|
|
|
|
Func* fn; // function being run
|
|
|
|
uintptr pc; // program counter within fn
|
|
|
|
uintptr lr; // program counter at caller aka link register
|
|
|
|
uintptr sp; // stack pointer at pc
|
|
|
|
uintptr fp; // stack pointer at caller aka frame pointer
|
2013-09-10 10:02:22 -06:00
|
|
|
byte* varp; // top of local variables
|
2013-06-12 06:49:38 -06:00
|
|
|
byte* argp; // pointer to function arguments
|
|
|
|
uintptr arglen; // number of bytes at argp
|
|
|
|
};
|
|
|
|
|
runtime: record proper goroutine state during stack split
Until now, the goroutine state has been scattered during the
execution of newstack and oldstack. It's all there, and those routines
know how to get back to a working goroutine, but other pieces of
the system, like stack traces, do not. If something does interrupt
the newstack or oldstack execution, the rest of the system can't
understand the goroutine. For example, if newstack decides there
is an overflow and calls throw, the stack tracer wouldn't dump the
goroutine correctly.
For newstack to save a useful state snapshot, it needs to be able
to rewind the PC in the function that triggered the split back to
the beginning of the function. (The PC is a few instructions in, just
after the call to morestack.) To make that possible, we change the
prologues to insert a jmp back to the beginning of the function
after the call to morestack. That is, the prologue used to be roughly:
TEXT myfunc
check for split
jmpcond nosplit
call morestack
nosplit:
sub $xxx, sp
Now an extra instruction is inserted after the call:
TEXT myfunc
start:
check for split
jmpcond nosplit
call morestack
jmp start
nosplit:
sub $xxx, sp
The jmp is not executed directly. It is decoded and simulated by
runtime.rewindmorestack to discover the beginning of the function,
and then the call to morestack returns directly to the start label
instead of to the jump instruction. So logically the jmp is still
executed, just not by the cpu.
The prologue thus repeats in the case of a function that needs a
stack split, but against the cost of the split itself, the extra few
instructions are noise. The repeated prologue has the nice effect of
making a stack split double-check that the new stack is big enough:
if morestack happens to return on a too-small stack, we'll now notice
before corruption happens.
The ability for newstack to rewind to the beginning of the function
should help preemption too. If newstack decides that it was called
for preemption instead of a stack split, it now has the goroutine state
correctly paused if rescheduling is needed, and when the goroutine
can run again, it can return to the start label on its original stack
and re-execute the split check.
Here is an example of a split stack overflow showing the full
trace, without any special cases in the stack printer.
(This one was triggered by making the split check incorrect.)
runtime: newstack framesize=0x0 argsize=0x18 sp=0x6aebd0 stack=[0x6b0000, 0x6b0fa0]
morebuf={pc:0x69f5b sp:0x6aebd8 lr:0x0}
sched={pc:0x68880 sp:0x6aebd0 lr:0x0 ctxt:0x34e700}
runtime: split stack overflow: 0x6aebd0 < 0x6b0000
fatal error: runtime: split stack overflow
goroutine 1 [stack split]:
runtime.mallocgc(0x290, 0x100000000, 0x1)
/Users/rsc/g/go/src/pkg/runtime/zmalloc_darwin_amd64.c:21 fp=0x6aebd8
runtime.new()
/Users/rsc/g/go/src/pkg/runtime/zmalloc_darwin_amd64.c:682 +0x5b fp=0x6aec08
go/build.(*Context).Import(0x5ae340, 0xc210030c71, 0xa, 0xc2100b4380, 0x1b, ...)
/Users/rsc/g/go/src/pkg/go/build/build.go:424 +0x3a fp=0x6b00a0
main.loadImport(0xc210030c71, 0xa, 0xc2100b4380, 0x1b, 0xc2100b42c0, ...)
/Users/rsc/g/go/src/cmd/go/pkg.go:249 +0x371 fp=0x6b01a8
main.(*Package).load(0xc21017c800, 0xc2100b42c0, 0xc2101828c0, 0x0, 0x0, ...)
/Users/rsc/g/go/src/cmd/go/pkg.go:431 +0x2801 fp=0x6b0c98
main.loadPackage(0x369040, 0x7, 0xc2100b42c0, 0x0)
/Users/rsc/g/go/src/cmd/go/pkg.go:709 +0x857 fp=0x6b0f80
----- stack segment boundary -----
main.(*builder).action(0xc2100902a0, 0x0, 0x0, 0xc2100e6c00, 0xc2100e5750, ...)
/Users/rsc/g/go/src/cmd/go/build.go:539 +0x437 fp=0x6b14a0
main.(*builder).action(0xc2100902a0, 0x0, 0x0, 0xc21015b400, 0x2, ...)
/Users/rsc/g/go/src/cmd/go/build.go:528 +0x1d2 fp=0x6b1658
main.(*builder).test(0xc2100902a0, 0xc210092000, 0x0, 0x0, 0xc21008ff60, ...)
/Users/rsc/g/go/src/cmd/go/test.go:622 +0x1b53 fp=0x6b1f68
----- stack segment boundary -----
main.runTest(0x5a6b20, 0xc21000a020, 0x2, 0x2)
/Users/rsc/g/go/src/cmd/go/test.go:366 +0xd09 fp=0x6a5cf0
main.main()
/Users/rsc/g/go/src/cmd/go/main.go:161 +0x4f9 fp=0x6a5f78
runtime.main()
/Users/rsc/g/go/src/pkg/runtime/proc.c:183 +0x92 fp=0x6a5fa0
runtime.goexit()
/Users/rsc/g/go/src/pkg/runtime/proc.c:1266 fp=0x6a5fa8
And here is a seg fault during oldstack:
SIGSEGV: segmentation violation
PC=0x1b2a6
runtime.oldstack()
/Users/rsc/g/go/src/pkg/runtime/stack.c:159 +0x76
runtime.lessstack()
/Users/rsc/g/go/src/pkg/runtime/asm_amd64.s:270 +0x22
goroutine 1 [stack unsplit]:
fmt.(*pp).printArg(0x2102e64e0, 0xe5c80, 0x2102c9220, 0x73, 0x0, ...)
/Users/rsc/g/go/src/pkg/fmt/print.go:818 +0x3d3 fp=0x221031e6f8
fmt.(*pp).doPrintf(0x2102e64e0, 0x12fb20, 0x2, 0x221031eb98, 0x1, ...)
/Users/rsc/g/go/src/pkg/fmt/print.go:1183 +0x15cb fp=0x221031eaf0
fmt.Sprintf(0x12fb20, 0x2, 0x221031eb98, 0x1, 0x1, ...)
/Users/rsc/g/go/src/pkg/fmt/print.go:234 +0x67 fp=0x221031eb40
flag.(*stringValue).String(0x2102c9210, 0x1, 0x0)
/Users/rsc/g/go/src/pkg/flag/flag.go:180 +0xb3 fp=0x221031ebb0
flag.(*FlagSet).Var(0x2102f6000, 0x293d38, 0x2102c9210, 0x143490, 0xa, ...)
/Users/rsc/g/go/src/pkg/flag/flag.go:633 +0x40 fp=0x221031eca0
flag.(*FlagSet).StringVar(0x2102f6000, 0x2102c9210, 0x143490, 0xa, 0x12fa60, ...)
/Users/rsc/g/go/src/pkg/flag/flag.go:550 +0x91 fp=0x221031ece8
flag.(*FlagSet).String(0x2102f6000, 0x143490, 0xa, 0x12fa60, 0x0, ...)
/Users/rsc/g/go/src/pkg/flag/flag.go:563 +0x87 fp=0x221031ed38
flag.String(0x143490, 0xa, 0x12fa60, 0x0, 0x161950, ...)
/Users/rsc/g/go/src/pkg/flag/flag.go:570 +0x6b fp=0x221031ed80
testing.init()
/Users/rsc/g/go/src/pkg/testing/testing.go:-531 +0xbb fp=0x221031edc0
strings_test.init()
/Users/rsc/g/go/src/pkg/strings/strings_test.go:1115 +0x62 fp=0x221031ef70
main.init()
strings/_test/_testmain.go:90 +0x3d fp=0x221031ef78
runtime.main()
/Users/rsc/g/go/src/pkg/runtime/proc.c:180 +0x8a fp=0x221031efa0
runtime.goexit()
/Users/rsc/g/go/src/pkg/runtime/proc.c:1269 fp=0x221031efa8
goroutine 2 [runnable]:
runtime.MHeap_Scavenger()
/Users/rsc/g/go/src/pkg/runtime/mheap.c:438
runtime.goexit()
/Users/rsc/g/go/src/pkg/runtime/proc.c:1269
created by runtime.main
/Users/rsc/g/go/src/pkg/runtime/proc.c:166
rax 0x23ccc0
rbx 0x23ccc0
rcx 0x0
rdx 0x38
rdi 0x2102c0170
rsi 0x221032cfe0
rbp 0x221032cfa0
rsp 0x7fff5fbff5b0
r8 0x2102c0120
r9 0x221032cfa0
r10 0x221032c000
r11 0x104ce8
r12 0xe5c80
r13 0x1be82baac718
r14 0x13091135f7d69200
r15 0x0
rip 0x1b2a6
rflags 0x10246
cs 0x2b
fs 0x0
gs 0x0
Fixes #5723.
R=r, dvyukov, go.peter.90, dave, iant
CC=golang-dev
https://golang.org/cl/10360048
2013-06-27 09:32:01 -06:00
|
|
|
int32 runtime·gentraceback(uintptr, uintptr, uintptr, G*, int32, uintptr*, int32, void(*)(Stkframe*, void*), void*, bool);
|
2013-06-12 06:49:38 -06:00
|
|
|
void runtime·traceback(uintptr pc, uintptr sp, uintptr lr, G* gp);
|
|
|
|
void runtime·tracebackothers(G*);
|
2013-06-12 13:22:26 -06:00
|
|
|
bool runtime·haszeroargs(uintptr pc);
|
2013-07-17 10:47:18 -06:00
|
|
|
bool runtime·topofstack(Func*);
|
2013-06-12 06:49:38 -06:00
|
|
|
|
2008-07-13 15:29:46 -06:00
|
|
|
/*
|
|
|
|
* external data
|
|
|
|
*/
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
extern String runtime·emptystring;
|
2012-10-21 15:41:32 -06:00
|
|
|
extern uintptr runtime·zerobase;
|
2013-01-25 18:57:06 -07:00
|
|
|
extern G* runtime·allg;
|
|
|
|
extern G* runtime·lastg;
|
|
|
|
extern M* runtime·allm;
|
2013-03-01 04:49:16 -07:00
|
|
|
extern P** runtime·allp;
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
extern int32 runtime·gomaxprocs;
|
runtime: detect deadlocks in programs using cgo
When cgo is used, runtime creates an additional M to handle callbacks on threads not created by Go.
This effectively disabled deadlock detection, which is a right thing, because Go program can be blocked
and only serve callbacks on external threads.
This also disables deadlock detection under race detector, because it happens to use cgo.
With this change the additional M is created lazily on first cgo call. So deadlock detector
works for programs that import "C", "net" or "net/http/pprof" but do not use them in fact.
Also fixes deadlock detector under race detector.
It should be fine to create the M later, because C code can not call into Go before first cgo call,
because C code does not know when Go initialization has completed. So a Go program need to call into C
first either to create an external thread, or notify a thread created in global ctor that Go
initialization has completed.
Fixes #4973.
Fixes #5475.
R=golang-dev, minux.ma, iant
CC=golang-dev
https://golang.org/cl/9303046
2013-05-22 12:57:47 -06:00
|
|
|
extern uint32 runtime·needextram;
|
2011-02-16 11:21:13 -07:00
|
|
|
extern uint32 runtime·panicking;
|
2013-01-25 18:57:06 -07:00
|
|
|
extern int8* runtime·goos;
|
|
|
|
extern int32 runtime·ncpu;
|
2010-12-08 11:53:30 -07:00
|
|
|
extern bool runtime·iscgo;
|
2012-09-24 12:58:34 -06:00
|
|
|
extern void (*runtime·sysargs)(int32, uint8**);
|
2013-08-06 14:49:11 -06:00
|
|
|
extern uintptr runtime·maxstring;
|
2013-02-25 13:58:23 -07:00
|
|
|
extern uint32 runtime·Hchansize;
|
2013-03-12 11:47:44 -06:00
|
|
|
extern uint32 runtime·cpuid_ecx;
|
|
|
|
extern uint32 runtime·cpuid_edx;
|
2013-06-28 08:37:06 -06:00
|
|
|
extern DebugVars runtime·debug;
|
2013-08-15 20:34:06 -06:00
|
|
|
extern uintptr runtime·maxstacksize;
|
2008-07-13 15:29:46 -06:00
|
|
|
|
2008-06-30 12:50:36 -06:00
|
|
|
/*
|
|
|
|
* common functions and data
|
|
|
|
*/
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
int32 runtime·strcmp(byte*, byte*);
|
runtime: improve Linux mutex
The implementation is hybrid active/passive spin/blocking mutex.
The design minimizes amount of context switches and futex calls.
The idea is that all critical sections in runtime are intentially
small, so pure blocking mutex behaves badly causing
a lot of context switches, thread parking/unparking and kernel calls.
Note that some synthetic benchmarks become somewhat slower,
that's due to increased contention on other data structures,
it should not affect programs that do any real work.
On 2 x Intel E5620, 8 HT cores, 2.4GHz
benchmark old ns/op new ns/op delta
BenchmarkSelectContended 521.00 503.00 -3.45%
BenchmarkSelectContended-2 661.00 320.00 -51.59%
BenchmarkSelectContended-4 1139.00 629.00 -44.78%
BenchmarkSelectContended-8 2870.00 878.00 -69.41%
BenchmarkSelectContended-16 5276.00 818.00 -84.50%
BenchmarkChanContended 112.00 103.00 -8.04%
BenchmarkChanContended-2 631.00 174.00 -72.42%
BenchmarkChanContended-4 682.00 272.00 -60.12%
BenchmarkChanContended-8 1601.00 520.00 -67.52%
BenchmarkChanContended-16 3100.00 372.00 -88.00%
BenchmarkChanSync 253.00 239.00 -5.53%
BenchmarkChanSync-2 5030.00 4648.00 -7.59%
BenchmarkChanSync-4 4826.00 4694.00 -2.74%
BenchmarkChanSync-8 4778.00 4713.00 -1.36%
BenchmarkChanSync-16 5289.00 4710.00 -10.95%
BenchmarkChanProdCons0 273.00 254.00 -6.96%
BenchmarkChanProdCons0-2 599.00 400.00 -33.22%
BenchmarkChanProdCons0-4 1168.00 659.00 -43.58%
BenchmarkChanProdCons0-8 2831.00 1057.00 -62.66%
BenchmarkChanProdCons0-16 4197.00 1037.00 -75.29%
BenchmarkChanProdCons10 150.00 140.00 -6.67%
BenchmarkChanProdCons10-2 607.00 268.00 -55.85%
BenchmarkChanProdCons10-4 1137.00 404.00 -64.47%
BenchmarkChanProdCons10-8 2115.00 828.00 -60.85%
BenchmarkChanProdCons10-16 4283.00 855.00 -80.04%
BenchmarkChanProdCons100 117.00 110.00 -5.98%
BenchmarkChanProdCons100-2 558.00 218.00 -60.93%
BenchmarkChanProdCons100-4 722.00 287.00 -60.25%
BenchmarkChanProdCons100-8 1840.00 431.00 -76.58%
BenchmarkChanProdCons100-16 3394.00 448.00 -86.80%
BenchmarkChanProdConsWork0 2014.00 1996.00 -0.89%
BenchmarkChanProdConsWork0-2 1207.00 1127.00 -6.63%
BenchmarkChanProdConsWork0-4 1913.00 611.00 -68.06%
BenchmarkChanProdConsWork0-8 3016.00 949.00 -68.53%
BenchmarkChanProdConsWork0-16 4320.00 1154.00 -73.29%
BenchmarkChanProdConsWork10 1906.00 1897.00 -0.47%
BenchmarkChanProdConsWork10-2 1123.00 1033.00 -8.01%
BenchmarkChanProdConsWork10-4 1076.00 571.00 -46.93%
BenchmarkChanProdConsWork10-8 2748.00 1096.00 -60.12%
BenchmarkChanProdConsWork10-16 4600.00 1105.00 -75.98%
BenchmarkChanProdConsWork100 1884.00 1852.00 -1.70%
BenchmarkChanProdConsWork100-2 1235.00 1146.00 -7.21%
BenchmarkChanProdConsWork100-4 1217.00 619.00 -49.14%
BenchmarkChanProdConsWork100-8 1534.00 509.00 -66.82%
BenchmarkChanProdConsWork100-16 4126.00 918.00 -77.75%
BenchmarkSyscall 34.40 33.30 -3.20%
BenchmarkSyscall-2 160.00 121.00 -24.38%
BenchmarkSyscall-4 131.00 136.00 +3.82%
BenchmarkSyscall-8 139.00 131.00 -5.76%
BenchmarkSyscall-16 161.00 168.00 +4.35%
BenchmarkSyscallWork 950.00 950.00 +0.00%
BenchmarkSyscallWork-2 481.00 480.00 -0.21%
BenchmarkSyscallWork-4 268.00 270.00 +0.75%
BenchmarkSyscallWork-8 156.00 169.00 +8.33%
BenchmarkSyscallWork-16 188.00 184.00 -2.13%
BenchmarkSemaSyntNonblock 36.40 35.60 -2.20%
BenchmarkSemaSyntNonblock-2 81.40 45.10 -44.59%
BenchmarkSemaSyntNonblock-4 126.00 108.00 -14.29%
BenchmarkSemaSyntNonblock-8 112.00 112.00 +0.00%
BenchmarkSemaSyntNonblock-16 110.00 112.00 +1.82%
BenchmarkSemaSyntBlock 35.30 35.30 +0.00%
BenchmarkSemaSyntBlock-2 118.00 124.00 +5.08%
BenchmarkSemaSyntBlock-4 105.00 108.00 +2.86%
BenchmarkSemaSyntBlock-8 101.00 111.00 +9.90%
BenchmarkSemaSyntBlock-16 112.00 118.00 +5.36%
BenchmarkSemaWorkNonblock 810.00 811.00 +0.12%
BenchmarkSemaWorkNonblock-2 476.00 414.00 -13.03%
BenchmarkSemaWorkNonblock-4 238.00 228.00 -4.20%
BenchmarkSemaWorkNonblock-8 140.00 126.00 -10.00%
BenchmarkSemaWorkNonblock-16 117.00 116.00 -0.85%
BenchmarkSemaWorkBlock 810.00 811.00 +0.12%
BenchmarkSemaWorkBlock-2 454.00 466.00 +2.64%
BenchmarkSemaWorkBlock-4 243.00 241.00 -0.82%
BenchmarkSemaWorkBlock-8 145.00 137.00 -5.52%
BenchmarkSemaWorkBlock-16 132.00 123.00 -6.82%
BenchmarkContendedSemaphore 123.00 102.00 -17.07%
BenchmarkContendedSemaphore-2 34.80 34.90 +0.29%
BenchmarkContendedSemaphore-4 34.70 34.80 +0.29%
BenchmarkContendedSemaphore-8 34.70 34.70 +0.00%
BenchmarkContendedSemaphore-16 34.80 34.70 -0.29%
BenchmarkMutex 26.80 26.00 -2.99%
BenchmarkMutex-2 108.00 45.20 -58.15%
BenchmarkMutex-4 103.00 127.00 +23.30%
BenchmarkMutex-8 109.00 147.00 +34.86%
BenchmarkMutex-16 102.00 152.00 +49.02%
BenchmarkMutexSlack 27.00 26.90 -0.37%
BenchmarkMutexSlack-2 149.00 165.00 +10.74%
BenchmarkMutexSlack-4 121.00 209.00 +72.73%
BenchmarkMutexSlack-8 101.00 158.00 +56.44%
BenchmarkMutexSlack-16 97.00 129.00 +32.99%
BenchmarkMutexWork 792.00 794.00 +0.25%
BenchmarkMutexWork-2 407.00 409.00 +0.49%
BenchmarkMutexWork-4 220.00 209.00 -5.00%
BenchmarkMutexWork-8 267.00 160.00 -40.07%
BenchmarkMutexWork-16 315.00 300.00 -4.76%
BenchmarkMutexWorkSlack 792.00 793.00 +0.13%
BenchmarkMutexWorkSlack-2 406.00 404.00 -0.49%
BenchmarkMutexWorkSlack-4 225.00 212.00 -5.78%
BenchmarkMutexWorkSlack-8 268.00 136.00 -49.25%
BenchmarkMutexWorkSlack-16 300.00 300.00 +0.00%
BenchmarkRWMutexWrite100 27.10 27.00 -0.37%
BenchmarkRWMutexWrite100-2 33.10 40.80 +23.26%
BenchmarkRWMutexWrite100-4 113.00 88.10 -22.04%
BenchmarkRWMutexWrite100-8 119.00 95.30 -19.92%
BenchmarkRWMutexWrite100-16 148.00 109.00 -26.35%
BenchmarkRWMutexWrite10 29.60 29.40 -0.68%
BenchmarkRWMutexWrite10-2 111.00 61.40 -44.68%
BenchmarkRWMutexWrite10-4 270.00 208.00 -22.96%
BenchmarkRWMutexWrite10-8 204.00 185.00 -9.31%
BenchmarkRWMutexWrite10-16 261.00 190.00 -27.20%
BenchmarkRWMutexWorkWrite100 1040.00 1036.00 -0.38%
BenchmarkRWMutexWorkWrite100-2 593.00 580.00 -2.19%
BenchmarkRWMutexWorkWrite100-4 470.00 365.00 -22.34%
BenchmarkRWMutexWorkWrite100-8 468.00 289.00 -38.25%
BenchmarkRWMutexWorkWrite100-16 604.00 374.00 -38.08%
BenchmarkRWMutexWorkWrite10 951.00 951.00 +0.00%
BenchmarkRWMutexWorkWrite10-2 1001.00 928.00 -7.29%
BenchmarkRWMutexWorkWrite10-4 1555.00 1006.00 -35.31%
BenchmarkRWMutexWorkWrite10-8 2085.00 1171.00 -43.84%
BenchmarkRWMutexWorkWrite10-16 2082.00 1614.00 -22.48%
R=rsc, iant, msolo, fw, iant
CC=golang-dev
https://golang.org/cl/4711045
2011-07-29 10:44:06 -06:00
|
|
|
byte* runtime·strstr(byte*, byte*);
|
2013-08-06 05:49:03 -06:00
|
|
|
intgo runtime·findnull(byte*);
|
|
|
|
intgo runtime·findnullw(uint16*);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void runtime·dump(byte*, int32);
|
|
|
|
int32 runtime·runetochar(byte*, int32);
|
|
|
|
int32 runtime·charntorune(int32*, uint8*, int32);
|
2008-06-30 12:50:36 -06:00
|
|
|
|
2008-06-05 20:38:39 -06:00
|
|
|
/*
|
2008-06-16 23:34:50 -06:00
|
|
|
* very low level c-called
|
2008-06-05 20:38:39 -06:00
|
|
|
*/
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
#define FLUSH(x) USED(x)
|
|
|
|
|
2013-06-12 13:22:26 -06:00
|
|
|
void runtime·gogo(Gobuf*);
|
|
|
|
void runtime·gostartcall(Gobuf*, void(*)(void), void*);
|
|
|
|
void runtime·gostartcallfn(Gobuf*, FuncVal*);
|
runtime: scheduler, cgo reorganization
* Change use of m->g0 stack (aka scheduler stack).
* Provide runtime.mcall(f) to invoke f() on m->g0 stack.
* Replace scheduler loop entry with runtime.mcall(schedule).
Runtime.mcall eliminates the need for fake scheduler states that
exist just to run a bit of code on the m->g0 stack
(Grecovery, Gstackalloc).
The elimination of the scheduler as a loop that stops and
starts using gosave and gogo fixes a bad interaction with the
way cgo uses the m->g0 stack. Cgo runs external (gcc-compiled)
C functions on that stack, and then when calling back into Go,
it sets m->g0->sched.sp below the added call frames, so that
other uses of m->g0's stack will not interfere with those frames.
Unfortunately, gogo (longjmp) back to the scheduler loop at
this point would end up running scheduler with the lower
sp, which no longer points at a valid stack frame for
a call to scheduler. If scheduler then wrote any function call
arguments or local variables to where it expected the stack
frame to be, it would overwrite other data on the stack.
I realized this possibility while debugging a problem with
calling complex Go code in a Go -> C -> Go cgo callback.
This wasn't the bug I was looking for, it turns out, but I believe
it is a real bug nonetheless. Switching to runtime.mcall, which
only adds new frames to the stack and never jumps into
functions running in existing ones, fixes this bug.
* Move cgo-related code out of proc.c into cgocall.c.
* Add very large comment describing cgo call sequences.
* Simpilify, regularize cgo function implementations and names.
* Add test suite as misc/cgo/test.
Now the Go -> C path calls cgocall, which calls asmcgocall,
and the C -> Go path calls cgocallback, which calls cgocallbackg.
The shuffling, which affects mainly the callback case, moves
most of the callback implementation to cgocallback running
on the m->curg stack (not the m->g0 scheduler stack) and
only while accounted for with $GOMAXPROCS (between calls
to exitsyscall and entersyscall).
The previous callback code did not block in startcgocallback's
approximation to exitsyscall, so if, say, the garbage collector
were running, it would still barge in and start doing things
like call malloc. Similarly endcgocallback's approximation of
entersyscall did not call matchmg to kick off new OS threads
when necessary, which caused the bug in issue 1560.
Fixes #1560.
R=iant
CC=golang-dev
https://golang.org/cl/4253054
2011-03-07 08:37:42 -07:00
|
|
|
void runtime·gosave(Gobuf*);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void runtime·lessstack(void);
|
|
|
|
void runtime·goargs(void);
|
2011-01-11 17:48:15 -07:00
|
|
|
void runtime·goenvs(void);
|
|
|
|
void runtime·goenvs_unix(void);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void* runtime·getu(void);
|
|
|
|
void runtime·throw(int8*);
|
|
|
|
void runtime·panicstring(int8*);
|
|
|
|
void runtime·prints(int8*);
|
|
|
|
void runtime·printf(int8*, ...);
|
|
|
|
byte* runtime·mchr(byte*, byte, byte*);
|
2013-03-20 14:51:29 -06:00
|
|
|
int32 runtime·mcmp(byte*, byte*, uintptr);
|
2013-03-08 16:41:03 -07:00
|
|
|
void runtime·memmove(void*, void*, uintptr);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void* runtime·mal(uintptr);
|
|
|
|
String runtime·catstring(String, String);
|
|
|
|
String runtime·gostring(byte*);
|
2012-09-24 12:58:34 -06:00
|
|
|
String runtime·gostringn(byte*, intgo);
|
|
|
|
Slice runtime·gobytes(byte*, intgo);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
String runtime·gostringnocopy(byte*);
|
2011-01-11 17:48:15 -07:00
|
|
|
String runtime·gostringw(uint16*);
|
os/signal: selective signal handling
Restore package os/signal, with new API:
Notify replaces Incoming, allowing clients
to ask for certain signals only. Also, signals
go to everyone who asks, not just one client.
This could plausibly move into package os now
that there are no magic side effects as a result
of the import.
Update runtime for new API: move common Unix
signal handling code into signal_unix.c.
(It's so easy to do this now that we don't have
to edit Makefiles!)
Tested on darwin,linux 386,amd64.
Fixes #1266.
R=r, dsymonds, bradfitz, iant, borman
CC=golang-dev
https://golang.org/cl/3749041
2012-02-13 11:52:37 -07:00
|
|
|
void runtime·initsig(void);
|
2012-02-16 20:36:40 -07:00
|
|
|
void runtime·sigenable(uint32 sig);
|
2013-03-14 22:00:02 -06:00
|
|
|
void runtime·sigdisable(uint32 sig);
|
2013-03-14 23:11:03 -06:00
|
|
|
int32 runtime·gotraceback(bool *crash);
|
2011-08-22 21:26:39 -06:00
|
|
|
void runtime·goroutineheader(G*);
|
2013-03-12 11:47:44 -06:00
|
|
|
int32 runtime·open(int8*, int32, int32);
|
|
|
|
int32 runtime·read(int32, void*, int32);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
int32 runtime·write(int32, void*, int32);
|
2013-03-12 11:47:44 -06:00
|
|
|
int32 runtime·close(int32);
|
2011-06-07 22:50:10 -06:00
|
|
|
int32 runtime·mincore(void*, uintptr, byte*);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
bool runtime·cas(uint32*, uint32, uint32);
|
2013-07-11 22:03:32 -06:00
|
|
|
bool runtime·cas64(uint64*, uint64, uint64);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
bool runtime·casp(void**, void*, void*);
|
2011-06-28 13:09:53 -06:00
|
|
|
// Don't confuse with XADD x86 instruction,
|
|
|
|
// this one is actually 'addx', that is, add-and-fetch.
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
uint32 runtime·xadd(uint32 volatile*, int32);
|
2012-04-05 08:47:43 -06:00
|
|
|
uint64 runtime·xadd64(uint64 volatile*, int64);
|
runtime: improve Linux mutex
The implementation is hybrid active/passive spin/blocking mutex.
The design minimizes amount of context switches and futex calls.
The idea is that all critical sections in runtime are intentially
small, so pure blocking mutex behaves badly causing
a lot of context switches, thread parking/unparking and kernel calls.
Note that some synthetic benchmarks become somewhat slower,
that's due to increased contention on other data structures,
it should not affect programs that do any real work.
On 2 x Intel E5620, 8 HT cores, 2.4GHz
benchmark old ns/op new ns/op delta
BenchmarkSelectContended 521.00 503.00 -3.45%
BenchmarkSelectContended-2 661.00 320.00 -51.59%
BenchmarkSelectContended-4 1139.00 629.00 -44.78%
BenchmarkSelectContended-8 2870.00 878.00 -69.41%
BenchmarkSelectContended-16 5276.00 818.00 -84.50%
BenchmarkChanContended 112.00 103.00 -8.04%
BenchmarkChanContended-2 631.00 174.00 -72.42%
BenchmarkChanContended-4 682.00 272.00 -60.12%
BenchmarkChanContended-8 1601.00 520.00 -67.52%
BenchmarkChanContended-16 3100.00 372.00 -88.00%
BenchmarkChanSync 253.00 239.00 -5.53%
BenchmarkChanSync-2 5030.00 4648.00 -7.59%
BenchmarkChanSync-4 4826.00 4694.00 -2.74%
BenchmarkChanSync-8 4778.00 4713.00 -1.36%
BenchmarkChanSync-16 5289.00 4710.00 -10.95%
BenchmarkChanProdCons0 273.00 254.00 -6.96%
BenchmarkChanProdCons0-2 599.00 400.00 -33.22%
BenchmarkChanProdCons0-4 1168.00 659.00 -43.58%
BenchmarkChanProdCons0-8 2831.00 1057.00 -62.66%
BenchmarkChanProdCons0-16 4197.00 1037.00 -75.29%
BenchmarkChanProdCons10 150.00 140.00 -6.67%
BenchmarkChanProdCons10-2 607.00 268.00 -55.85%
BenchmarkChanProdCons10-4 1137.00 404.00 -64.47%
BenchmarkChanProdCons10-8 2115.00 828.00 -60.85%
BenchmarkChanProdCons10-16 4283.00 855.00 -80.04%
BenchmarkChanProdCons100 117.00 110.00 -5.98%
BenchmarkChanProdCons100-2 558.00 218.00 -60.93%
BenchmarkChanProdCons100-4 722.00 287.00 -60.25%
BenchmarkChanProdCons100-8 1840.00 431.00 -76.58%
BenchmarkChanProdCons100-16 3394.00 448.00 -86.80%
BenchmarkChanProdConsWork0 2014.00 1996.00 -0.89%
BenchmarkChanProdConsWork0-2 1207.00 1127.00 -6.63%
BenchmarkChanProdConsWork0-4 1913.00 611.00 -68.06%
BenchmarkChanProdConsWork0-8 3016.00 949.00 -68.53%
BenchmarkChanProdConsWork0-16 4320.00 1154.00 -73.29%
BenchmarkChanProdConsWork10 1906.00 1897.00 -0.47%
BenchmarkChanProdConsWork10-2 1123.00 1033.00 -8.01%
BenchmarkChanProdConsWork10-4 1076.00 571.00 -46.93%
BenchmarkChanProdConsWork10-8 2748.00 1096.00 -60.12%
BenchmarkChanProdConsWork10-16 4600.00 1105.00 -75.98%
BenchmarkChanProdConsWork100 1884.00 1852.00 -1.70%
BenchmarkChanProdConsWork100-2 1235.00 1146.00 -7.21%
BenchmarkChanProdConsWork100-4 1217.00 619.00 -49.14%
BenchmarkChanProdConsWork100-8 1534.00 509.00 -66.82%
BenchmarkChanProdConsWork100-16 4126.00 918.00 -77.75%
BenchmarkSyscall 34.40 33.30 -3.20%
BenchmarkSyscall-2 160.00 121.00 -24.38%
BenchmarkSyscall-4 131.00 136.00 +3.82%
BenchmarkSyscall-8 139.00 131.00 -5.76%
BenchmarkSyscall-16 161.00 168.00 +4.35%
BenchmarkSyscallWork 950.00 950.00 +0.00%
BenchmarkSyscallWork-2 481.00 480.00 -0.21%
BenchmarkSyscallWork-4 268.00 270.00 +0.75%
BenchmarkSyscallWork-8 156.00 169.00 +8.33%
BenchmarkSyscallWork-16 188.00 184.00 -2.13%
BenchmarkSemaSyntNonblock 36.40 35.60 -2.20%
BenchmarkSemaSyntNonblock-2 81.40 45.10 -44.59%
BenchmarkSemaSyntNonblock-4 126.00 108.00 -14.29%
BenchmarkSemaSyntNonblock-8 112.00 112.00 +0.00%
BenchmarkSemaSyntNonblock-16 110.00 112.00 +1.82%
BenchmarkSemaSyntBlock 35.30 35.30 +0.00%
BenchmarkSemaSyntBlock-2 118.00 124.00 +5.08%
BenchmarkSemaSyntBlock-4 105.00 108.00 +2.86%
BenchmarkSemaSyntBlock-8 101.00 111.00 +9.90%
BenchmarkSemaSyntBlock-16 112.00 118.00 +5.36%
BenchmarkSemaWorkNonblock 810.00 811.00 +0.12%
BenchmarkSemaWorkNonblock-2 476.00 414.00 -13.03%
BenchmarkSemaWorkNonblock-4 238.00 228.00 -4.20%
BenchmarkSemaWorkNonblock-8 140.00 126.00 -10.00%
BenchmarkSemaWorkNonblock-16 117.00 116.00 -0.85%
BenchmarkSemaWorkBlock 810.00 811.00 +0.12%
BenchmarkSemaWorkBlock-2 454.00 466.00 +2.64%
BenchmarkSemaWorkBlock-4 243.00 241.00 -0.82%
BenchmarkSemaWorkBlock-8 145.00 137.00 -5.52%
BenchmarkSemaWorkBlock-16 132.00 123.00 -6.82%
BenchmarkContendedSemaphore 123.00 102.00 -17.07%
BenchmarkContendedSemaphore-2 34.80 34.90 +0.29%
BenchmarkContendedSemaphore-4 34.70 34.80 +0.29%
BenchmarkContendedSemaphore-8 34.70 34.70 +0.00%
BenchmarkContendedSemaphore-16 34.80 34.70 -0.29%
BenchmarkMutex 26.80 26.00 -2.99%
BenchmarkMutex-2 108.00 45.20 -58.15%
BenchmarkMutex-4 103.00 127.00 +23.30%
BenchmarkMutex-8 109.00 147.00 +34.86%
BenchmarkMutex-16 102.00 152.00 +49.02%
BenchmarkMutexSlack 27.00 26.90 -0.37%
BenchmarkMutexSlack-2 149.00 165.00 +10.74%
BenchmarkMutexSlack-4 121.00 209.00 +72.73%
BenchmarkMutexSlack-8 101.00 158.00 +56.44%
BenchmarkMutexSlack-16 97.00 129.00 +32.99%
BenchmarkMutexWork 792.00 794.00 +0.25%
BenchmarkMutexWork-2 407.00 409.00 +0.49%
BenchmarkMutexWork-4 220.00 209.00 -5.00%
BenchmarkMutexWork-8 267.00 160.00 -40.07%
BenchmarkMutexWork-16 315.00 300.00 -4.76%
BenchmarkMutexWorkSlack 792.00 793.00 +0.13%
BenchmarkMutexWorkSlack-2 406.00 404.00 -0.49%
BenchmarkMutexWorkSlack-4 225.00 212.00 -5.78%
BenchmarkMutexWorkSlack-8 268.00 136.00 -49.25%
BenchmarkMutexWorkSlack-16 300.00 300.00 +0.00%
BenchmarkRWMutexWrite100 27.10 27.00 -0.37%
BenchmarkRWMutexWrite100-2 33.10 40.80 +23.26%
BenchmarkRWMutexWrite100-4 113.00 88.10 -22.04%
BenchmarkRWMutexWrite100-8 119.00 95.30 -19.92%
BenchmarkRWMutexWrite100-16 148.00 109.00 -26.35%
BenchmarkRWMutexWrite10 29.60 29.40 -0.68%
BenchmarkRWMutexWrite10-2 111.00 61.40 -44.68%
BenchmarkRWMutexWrite10-4 270.00 208.00 -22.96%
BenchmarkRWMutexWrite10-8 204.00 185.00 -9.31%
BenchmarkRWMutexWrite10-16 261.00 190.00 -27.20%
BenchmarkRWMutexWorkWrite100 1040.00 1036.00 -0.38%
BenchmarkRWMutexWorkWrite100-2 593.00 580.00 -2.19%
BenchmarkRWMutexWorkWrite100-4 470.00 365.00 -22.34%
BenchmarkRWMutexWorkWrite100-8 468.00 289.00 -38.25%
BenchmarkRWMutexWorkWrite100-16 604.00 374.00 -38.08%
BenchmarkRWMutexWorkWrite10 951.00 951.00 +0.00%
BenchmarkRWMutexWorkWrite10-2 1001.00 928.00 -7.29%
BenchmarkRWMutexWorkWrite10-4 1555.00 1006.00 -35.31%
BenchmarkRWMutexWorkWrite10-8 2085.00 1171.00 -43.84%
BenchmarkRWMutexWorkWrite10-16 2082.00 1614.00 -22.48%
R=rsc, iant, msolo, fw, iant
CC=golang-dev
https://golang.org/cl/4711045
2011-07-29 10:44:06 -06:00
|
|
|
uint32 runtime·xchg(uint32 volatile*, uint32);
|
2013-03-05 00:46:52 -07:00
|
|
|
uint64 runtime·xchg64(uint64 volatile*, uint64);
|
2011-07-13 12:22:41 -06:00
|
|
|
uint32 runtime·atomicload(uint32 volatile*);
|
2011-07-29 11:47:24 -06:00
|
|
|
void runtime·atomicstore(uint32 volatile*, uint32);
|
2012-04-05 08:47:43 -06:00
|
|
|
void runtime·atomicstore64(uint64 volatile*, uint64);
|
|
|
|
uint64 runtime·atomicload64(uint64 volatile*);
|
2011-07-13 12:22:41 -06:00
|
|
|
void* runtime·atomicloadp(void* volatile*);
|
|
|
|
void runtime·atomicstorep(void* volatile*, void*);
|
2013-02-21 15:01:13 -07:00
|
|
|
void runtime·jmpdefer(FuncVal*, void*);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void runtime·exit1(int32);
|
|
|
|
void runtime·ready(G*);
|
|
|
|
byte* runtime·getenv(int8*);
|
|
|
|
int32 runtime·atoi(byte*);
|
2013-03-01 09:44:43 -07:00
|
|
|
void runtime·newosproc(M *mp, void *stk);
|
|
|
|
void runtime·mstart(void);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
G* runtime·malg(int32);
|
2012-02-13 23:23:15 -07:00
|
|
|
void runtime·asminit(void);
|
2013-02-21 05:24:38 -07:00
|
|
|
void runtime·mpreinit(M*);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void runtime·minit(void);
|
2013-02-20 15:48:23 -07:00
|
|
|
void runtime·unminit(void);
|
|
|
|
void runtime·signalstack(byte*, int32);
|
2013-05-28 11:10:10 -06:00
|
|
|
void runtime·symtabinit(void);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
Func* runtime·findfunc(uintptr);
|
2013-07-16 07:41:38 -06:00
|
|
|
int32 runtime·funcline(Func*, uintptr, String*);
|
|
|
|
int32 runtime·funcarglen(Func*, uintptr);
|
|
|
|
int32 runtime·funcspdelta(Func*, uintptr);
|
2013-07-18 08:43:22 -06:00
|
|
|
int8* runtime·funcname(Func*);
|
2013-09-16 20:03:19 -06:00
|
|
|
int32 runtime·pcdatavalue(Func*, int32, uintptr);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void* runtime·stackalloc(uint32);
|
2011-01-25 14:35:36 -07:00
|
|
|
void runtime·stackfree(void*, uintptr);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
MCache* runtime·allocmcache(void);
|
2012-07-01 03:10:01 -06:00
|
|
|
void runtime·freemcache(MCache*);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void runtime·mallocinit(void);
|
|
|
|
bool runtime·ifaceeq_c(Iface, Iface);
|
|
|
|
bool runtime·efaceeq_c(Eface, Eface);
|
2013-01-04 08:53:42 -07:00
|
|
|
uintptr runtime·ifacehash(Iface, uintptr);
|
|
|
|
uintptr runtime·efacehash(Eface, uintptr);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void* runtime·malloc(uintptr size);
|
|
|
|
void runtime·free(void *v);
|
|
|
|
void runtime·runpanic(Panic*);
|
2013-06-12 06:49:38 -06:00
|
|
|
uintptr runtime·getcallersp(void*);
|
2011-01-28 13:03:26 -07:00
|
|
|
int32 runtime·mcount(void);
|
2012-02-22 19:45:01 -07:00
|
|
|
int32 runtime·gcount(void);
|
runtime: scheduler, cgo reorganization
* Change use of m->g0 stack (aka scheduler stack).
* Provide runtime.mcall(f) to invoke f() on m->g0 stack.
* Replace scheduler loop entry with runtime.mcall(schedule).
Runtime.mcall eliminates the need for fake scheduler states that
exist just to run a bit of code on the m->g0 stack
(Grecovery, Gstackalloc).
The elimination of the scheduler as a loop that stops and
starts using gosave and gogo fixes a bad interaction with the
way cgo uses the m->g0 stack. Cgo runs external (gcc-compiled)
C functions on that stack, and then when calling back into Go,
it sets m->g0->sched.sp below the added call frames, so that
other uses of m->g0's stack will not interfere with those frames.
Unfortunately, gogo (longjmp) back to the scheduler loop at
this point would end up running scheduler with the lower
sp, which no longer points at a valid stack frame for
a call to scheduler. If scheduler then wrote any function call
arguments or local variables to where it expected the stack
frame to be, it would overwrite other data on the stack.
I realized this possibility while debugging a problem with
calling complex Go code in a Go -> C -> Go cgo callback.
This wasn't the bug I was looking for, it turns out, but I believe
it is a real bug nonetheless. Switching to runtime.mcall, which
only adds new frames to the stack and never jumps into
functions running in existing ones, fixes this bug.
* Move cgo-related code out of proc.c into cgocall.c.
* Add very large comment describing cgo call sequences.
* Simpilify, regularize cgo function implementations and names.
* Add test suite as misc/cgo/test.
Now the Go -> C path calls cgocall, which calls asmcgocall,
and the C -> Go path calls cgocallback, which calls cgocallbackg.
The shuffling, which affects mainly the callback case, moves
most of the callback implementation to cgocallback running
on the m->curg stack (not the m->g0 scheduler stack) and
only while accounted for with $GOMAXPROCS (between calls
to exitsyscall and entersyscall).
The previous callback code did not block in startcgocallback's
approximation to exitsyscall, so if, say, the garbage collector
were running, it would still barge in and start doing things
like call malloc. Similarly endcgocallback's approximation of
entersyscall did not call matchmg to kick off new OS threads
when necessary, which caused the bug in issue 1560.
Fixes #1560.
R=iant
CC=golang-dev
https://golang.org/cl/4253054
2011-03-07 08:37:42 -07:00
|
|
|
void runtime·mcall(void(*)(G*));
|
2011-07-11 23:23:58 -06:00
|
|
|
uint32 runtime·fastrand1(void);
|
runtime: record proper goroutine state during stack split
Until now, the goroutine state has been scattered during the
execution of newstack and oldstack. It's all there, and those routines
know how to get back to a working goroutine, but other pieces of
the system, like stack traces, do not. If something does interrupt
the newstack or oldstack execution, the rest of the system can't
understand the goroutine. For example, if newstack decides there
is an overflow and calls throw, the stack tracer wouldn't dump the
goroutine correctly.
For newstack to save a useful state snapshot, it needs to be able
to rewind the PC in the function that triggered the split back to
the beginning of the function. (The PC is a few instructions in, just
after the call to morestack.) To make that possible, we change the
prologues to insert a jmp back to the beginning of the function
after the call to morestack. That is, the prologue used to be roughly:
TEXT myfunc
check for split
jmpcond nosplit
call morestack
nosplit:
sub $xxx, sp
Now an extra instruction is inserted after the call:
TEXT myfunc
start:
check for split
jmpcond nosplit
call morestack
jmp start
nosplit:
sub $xxx, sp
The jmp is not executed directly. It is decoded and simulated by
runtime.rewindmorestack to discover the beginning of the function,
and then the call to morestack returns directly to the start label
instead of to the jump instruction. So logically the jmp is still
executed, just not by the cpu.
The prologue thus repeats in the case of a function that needs a
stack split, but against the cost of the split itself, the extra few
instructions are noise. The repeated prologue has the nice effect of
making a stack split double-check that the new stack is big enough:
if morestack happens to return on a too-small stack, we'll now notice
before corruption happens.
The ability for newstack to rewind to the beginning of the function
should help preemption too. If newstack decides that it was called
for preemption instead of a stack split, it now has the goroutine state
correctly paused if rescheduling is needed, and when the goroutine
can run again, it can return to the start label on its original stack
and re-execute the split check.
Here is an example of a split stack overflow showing the full
trace, without any special cases in the stack printer.
(This one was triggered by making the split check incorrect.)
runtime: newstack framesize=0x0 argsize=0x18 sp=0x6aebd0 stack=[0x6b0000, 0x6b0fa0]
morebuf={pc:0x69f5b sp:0x6aebd8 lr:0x0}
sched={pc:0x68880 sp:0x6aebd0 lr:0x0 ctxt:0x34e700}
runtime: split stack overflow: 0x6aebd0 < 0x6b0000
fatal error: runtime: split stack overflow
goroutine 1 [stack split]:
runtime.mallocgc(0x290, 0x100000000, 0x1)
/Users/rsc/g/go/src/pkg/runtime/zmalloc_darwin_amd64.c:21 fp=0x6aebd8
runtime.new()
/Users/rsc/g/go/src/pkg/runtime/zmalloc_darwin_amd64.c:682 +0x5b fp=0x6aec08
go/build.(*Context).Import(0x5ae340, 0xc210030c71, 0xa, 0xc2100b4380, 0x1b, ...)
/Users/rsc/g/go/src/pkg/go/build/build.go:424 +0x3a fp=0x6b00a0
main.loadImport(0xc210030c71, 0xa, 0xc2100b4380, 0x1b, 0xc2100b42c0, ...)
/Users/rsc/g/go/src/cmd/go/pkg.go:249 +0x371 fp=0x6b01a8
main.(*Package).load(0xc21017c800, 0xc2100b42c0, 0xc2101828c0, 0x0, 0x0, ...)
/Users/rsc/g/go/src/cmd/go/pkg.go:431 +0x2801 fp=0x6b0c98
main.loadPackage(0x369040, 0x7, 0xc2100b42c0, 0x0)
/Users/rsc/g/go/src/cmd/go/pkg.go:709 +0x857 fp=0x6b0f80
----- stack segment boundary -----
main.(*builder).action(0xc2100902a0, 0x0, 0x0, 0xc2100e6c00, 0xc2100e5750, ...)
/Users/rsc/g/go/src/cmd/go/build.go:539 +0x437 fp=0x6b14a0
main.(*builder).action(0xc2100902a0, 0x0, 0x0, 0xc21015b400, 0x2, ...)
/Users/rsc/g/go/src/cmd/go/build.go:528 +0x1d2 fp=0x6b1658
main.(*builder).test(0xc2100902a0, 0xc210092000, 0x0, 0x0, 0xc21008ff60, ...)
/Users/rsc/g/go/src/cmd/go/test.go:622 +0x1b53 fp=0x6b1f68
----- stack segment boundary -----
main.runTest(0x5a6b20, 0xc21000a020, 0x2, 0x2)
/Users/rsc/g/go/src/cmd/go/test.go:366 +0xd09 fp=0x6a5cf0
main.main()
/Users/rsc/g/go/src/cmd/go/main.go:161 +0x4f9 fp=0x6a5f78
runtime.main()
/Users/rsc/g/go/src/pkg/runtime/proc.c:183 +0x92 fp=0x6a5fa0
runtime.goexit()
/Users/rsc/g/go/src/pkg/runtime/proc.c:1266 fp=0x6a5fa8
And here is a seg fault during oldstack:
SIGSEGV: segmentation violation
PC=0x1b2a6
runtime.oldstack()
/Users/rsc/g/go/src/pkg/runtime/stack.c:159 +0x76
runtime.lessstack()
/Users/rsc/g/go/src/pkg/runtime/asm_amd64.s:270 +0x22
goroutine 1 [stack unsplit]:
fmt.(*pp).printArg(0x2102e64e0, 0xe5c80, 0x2102c9220, 0x73, 0x0, ...)
/Users/rsc/g/go/src/pkg/fmt/print.go:818 +0x3d3 fp=0x221031e6f8
fmt.(*pp).doPrintf(0x2102e64e0, 0x12fb20, 0x2, 0x221031eb98, 0x1, ...)
/Users/rsc/g/go/src/pkg/fmt/print.go:1183 +0x15cb fp=0x221031eaf0
fmt.Sprintf(0x12fb20, 0x2, 0x221031eb98, 0x1, 0x1, ...)
/Users/rsc/g/go/src/pkg/fmt/print.go:234 +0x67 fp=0x221031eb40
flag.(*stringValue).String(0x2102c9210, 0x1, 0x0)
/Users/rsc/g/go/src/pkg/flag/flag.go:180 +0xb3 fp=0x221031ebb0
flag.(*FlagSet).Var(0x2102f6000, 0x293d38, 0x2102c9210, 0x143490, 0xa, ...)
/Users/rsc/g/go/src/pkg/flag/flag.go:633 +0x40 fp=0x221031eca0
flag.(*FlagSet).StringVar(0x2102f6000, 0x2102c9210, 0x143490, 0xa, 0x12fa60, ...)
/Users/rsc/g/go/src/pkg/flag/flag.go:550 +0x91 fp=0x221031ece8
flag.(*FlagSet).String(0x2102f6000, 0x143490, 0xa, 0x12fa60, 0x0, ...)
/Users/rsc/g/go/src/pkg/flag/flag.go:563 +0x87 fp=0x221031ed38
flag.String(0x143490, 0xa, 0x12fa60, 0x0, 0x161950, ...)
/Users/rsc/g/go/src/pkg/flag/flag.go:570 +0x6b fp=0x221031ed80
testing.init()
/Users/rsc/g/go/src/pkg/testing/testing.go:-531 +0xbb fp=0x221031edc0
strings_test.init()
/Users/rsc/g/go/src/pkg/strings/strings_test.go:1115 +0x62 fp=0x221031ef70
main.init()
strings/_test/_testmain.go:90 +0x3d fp=0x221031ef78
runtime.main()
/Users/rsc/g/go/src/pkg/runtime/proc.c:180 +0x8a fp=0x221031efa0
runtime.goexit()
/Users/rsc/g/go/src/pkg/runtime/proc.c:1269 fp=0x221031efa8
goroutine 2 [runnable]:
runtime.MHeap_Scavenger()
/Users/rsc/g/go/src/pkg/runtime/mheap.c:438
runtime.goexit()
/Users/rsc/g/go/src/pkg/runtime/proc.c:1269
created by runtime.main
/Users/rsc/g/go/src/pkg/runtime/proc.c:166
rax 0x23ccc0
rbx 0x23ccc0
rcx 0x0
rdx 0x38
rdi 0x2102c0170
rsi 0x221032cfe0
rbp 0x221032cfa0
rsp 0x7fff5fbff5b0
r8 0x2102c0120
r9 0x221032cfa0
r10 0x221032c000
r11 0x104ce8
r12 0xe5c80
r13 0x1be82baac718
r14 0x13091135f7d69200
r15 0x0
rip 0x1b2a6
rflags 0x10246
cs 0x2b
fs 0x0
gs 0x0
Fixes #5723.
R=r, dvyukov, go.peter.90, dave, iant
CC=golang-dev
https://golang.org/cl/10360048
2013-06-27 09:32:01 -06:00
|
|
|
void runtime·rewindmorestack(Gobuf*);
|
2013-07-29 12:22:34 -06:00
|
|
|
int32 runtime·timediv(int64, int32, int32*);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
|
2013-02-20 15:48:23 -07:00
|
|
|
void runtime·setmg(M*, G*);
|
|
|
|
void runtime·newextram(void);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void runtime·exit(int32);
|
|
|
|
void runtime·breakpoint(void);
|
|
|
|
void runtime·gosched(void);
|
2013-06-28 07:52:17 -06:00
|
|
|
void runtime·gosched0(G*);
|
2013-08-13 14:30:55 -06:00
|
|
|
void runtime·schedtrace(bool);
|
2012-09-18 11:15:46 -06:00
|
|
|
void runtime·park(void(*)(Lock*), Lock*, int8*);
|
|
|
|
void runtime·tsleep(int64, int8*);
|
runtime: add timer support, use for package time
This looks like it is just moving some code from
time to runtime (and translating it to C), but the
runtime can do a better job managing the goroutines,
and it needs this functionality for its own maintenance
(for example, for the garbage collector to hand back
unused memory to the OS on a time delay).
Might as well have just one copy of the timer logic,
and runtime can't depend on time, so vice versa.
It also unifies Sleep, NewTicker, and NewTimer behind
one mechanism, so that there are no claims that one
is more efficient than another. (For example, today
people recommend using time.After instead of time.Sleep
to avoid blocking an OS thread.)
Fixes #1644.
Fixes #1731.
Fixes #2190.
R=golang-dev, r, hectorchu, iant, iant, jsing, alex.brainman, dvyukov
CC=golang-dev
https://golang.org/cl/5334051
2011-11-09 13:17:05 -07:00
|
|
|
M* runtime·newm(void);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void runtime·goexit(void);
|
runtime: scheduler, cgo reorganization
* Change use of m->g0 stack (aka scheduler stack).
* Provide runtime.mcall(f) to invoke f() on m->g0 stack.
* Replace scheduler loop entry with runtime.mcall(schedule).
Runtime.mcall eliminates the need for fake scheduler states that
exist just to run a bit of code on the m->g0 stack
(Grecovery, Gstackalloc).
The elimination of the scheduler as a loop that stops and
starts using gosave and gogo fixes a bad interaction with the
way cgo uses the m->g0 stack. Cgo runs external (gcc-compiled)
C functions on that stack, and then when calling back into Go,
it sets m->g0->sched.sp below the added call frames, so that
other uses of m->g0's stack will not interfere with those frames.
Unfortunately, gogo (longjmp) back to the scheduler loop at
this point would end up running scheduler with the lower
sp, which no longer points at a valid stack frame for
a call to scheduler. If scheduler then wrote any function call
arguments or local variables to where it expected the stack
frame to be, it would overwrite other data on the stack.
I realized this possibility while debugging a problem with
calling complex Go code in a Go -> C -> Go cgo callback.
This wasn't the bug I was looking for, it turns out, but I believe
it is a real bug nonetheless. Switching to runtime.mcall, which
only adds new frames to the stack and never jumps into
functions running in existing ones, fixes this bug.
* Move cgo-related code out of proc.c into cgocall.c.
* Add very large comment describing cgo call sequences.
* Simpilify, regularize cgo function implementations and names.
* Add test suite as misc/cgo/test.
Now the Go -> C path calls cgocall, which calls asmcgocall,
and the C -> Go path calls cgocallback, which calls cgocallbackg.
The shuffling, which affects mainly the callback case, moves
most of the callback implementation to cgocallback running
on the m->curg stack (not the m->g0 scheduler stack) and
only while accounted for with $GOMAXPROCS (between calls
to exitsyscall and entersyscall).
The previous callback code did not block in startcgocallback's
approximation to exitsyscall, so if, say, the garbage collector
were running, it would still barge in and start doing things
like call malloc. Similarly endcgocallback's approximation of
entersyscall did not call matchmg to kick off new OS threads
when necessary, which caused the bug in issue 1560.
Fixes #1560.
R=iant
CC=golang-dev
https://golang.org/cl/4253054
2011-03-07 08:37:42 -07:00
|
|
|
void runtime·asmcgocall(void (*fn)(void*), void*);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void runtime·entersyscall(void);
|
2013-02-20 09:21:45 -07:00
|
|
|
void runtime·entersyscallblock(void);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void runtime·exitsyscall(void);
|
2013-02-21 15:01:13 -07:00
|
|
|
G* runtime·newproc1(FuncVal*, byte*, int32, int32, void*);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
bool runtime·sigsend(int32 sig);
|
|
|
|
int32 runtime·callers(int32, uintptr*, int32);
|
|
|
|
int64 runtime·nanotime(void);
|
|
|
|
void runtime·dopanic(int32);
|
2011-02-16 11:21:13 -07:00
|
|
|
void runtime·startpanic(void);
|
2013-08-09 02:53:35 -06:00
|
|
|
void runtime·freezetheworld(void);
|
2012-07-04 04:52:51 -06:00
|
|
|
void runtime·unwindstack(G*, byte*);
|
2011-03-23 09:43:37 -06:00
|
|
|
void runtime·sigprof(uint8 *pc, uint8 *sp, uint8 *lr, G *gp);
|
|
|
|
void runtime·resetcpuprofiler(int32);
|
|
|
|
void runtime·setcpuprofilerate(void(*)(uintptr*, int32), int32);
|
runtime: parallelize garbage collector mark + sweep
Running test/garbage/parser.out.
On a 4-core Lenovo X201s (Linux):
31.12u 0.60s 31.74r 1 cpu, no atomics
32.27u 0.58s 32.86r 1 cpu, atomic instructions
33.04u 0.83s 27.47r 2 cpu
On a 16-core Xeon (Linux):
33.08u 0.65s 33.80r 1 cpu, no atomics
34.87u 1.12s 29.60r 2 cpu
36.00u 1.87s 28.43r 3 cpu
36.46u 2.34s 27.10r 4 cpu
38.28u 3.85s 26.92r 5 cpu
37.72u 5.25s 26.73r 6 cpu
39.63u 7.11s 26.95r 7 cpu
39.67u 8.10s 26.68r 8 cpu
On a 2-core MacBook Pro Core 2 Duo 2.26 (circa 2009, MacBookPro5,5):
39.43u 1.45s 41.27r 1 cpu, no atomics
43.98u 2.95s 38.69r 2 cpu
On a 2-core Mac Mini Core 2 Duo 1.83 (circa 2008; Macmini2,1):
48.81u 2.12s 51.76r 1 cpu, no atomics
57.15u 4.72s 51.54r 2 cpu
The handoff algorithm is really only good for two cores.
Beyond that we will need to so something more sophisticated,
like have each core hand off to the next one, around a circle.
Even so, the code is a good checkpoint; for now we'll limit the
number of gc procs to at most 2.
R=dvyukov
CC=golang-dev
https://golang.org/cl/4641082
2011-09-30 07:40:01 -06:00
|
|
|
void runtime·usleep(uint32);
|
2012-02-02 12:09:27 -07:00
|
|
|
int64 runtime·cputicks(void);
|
pprof: add goroutine blocking profiling
The profiler collects goroutine blocking information similar to Google Perf Tools.
You may see an example of the profile (converted to svg) attached to
http://code.google.com/p/go/issues/detail?id=3946
The public API changes are:
+pkg runtime, func BlockProfile([]BlockProfileRecord) (int, bool)
+pkg runtime, func SetBlockProfileRate(int)
+pkg runtime, method (*BlockProfileRecord) Stack() []uintptr
+pkg runtime, type BlockProfileRecord struct
+pkg runtime, type BlockProfileRecord struct, Count int64
+pkg runtime, type BlockProfileRecord struct, Cycles int64
+pkg runtime, type BlockProfileRecord struct, embedded StackRecord
R=rsc, dave, minux.ma, r
CC=gobot, golang-dev, r, remyoudompheng
https://golang.org/cl/6443115
2012-10-06 02:56:04 -06:00
|
|
|
int64 runtime·tickspersecond(void);
|
|
|
|
void runtime·blockevent(int64, int32);
|
|
|
|
extern int64 runtime·blockprofilerate;
|
2013-03-05 00:38:15 -07:00
|
|
|
void runtime·addtimer(Timer*);
|
|
|
|
bool runtime·deltimer(Timer*);
|
2013-03-12 11:14:26 -06:00
|
|
|
G* runtime·netpoll(bool);
|
2013-03-14 00:38:37 -06:00
|
|
|
void runtime·netpollinit(void);
|
2013-05-19 20:55:50 -06:00
|
|
|
int32 runtime·netpollopen(uintptr, PollDesc*);
|
|
|
|
int32 runtime·netpollclose(uintptr);
|
2013-03-14 00:38:37 -06:00
|
|
|
void runtime·netpollready(G**, PollDesc*, int32);
|
2013-08-08 07:41:57 -06:00
|
|
|
uintptr runtime·netpollfd(PollDesc*);
|
2013-03-14 23:11:03 -06:00
|
|
|
void runtime·crash(void);
|
2013-06-28 08:37:06 -06:00
|
|
|
void runtime·parsedebugvars(void);
|
2013-06-12 06:49:38 -06:00
|
|
|
void _rt0_go(void);
|
2013-07-19 14:04:09 -06:00
|
|
|
void* runtime·funcdata(Func*, int32);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
|
|
|
|
#pragma varargck argpos runtime·printf 1
|
cmd/5l, cmd/6l, cmd/8l, cmd/gc, runtime: generate and use bitmaps of argument pointer locations
With this change the compiler emits a bitmap for each function
covering its stack frame arguments area. If an argument word
is known to contain a pointer, a bit is set. The garbage
collector reads this information when scanning the stack by
frames and uses it to ignores locations known to not contain a
pointer.
R=golang-dev, bradfitz, daniel.morsing, dvyukov, khr, khr, iant, cshapiro
CC=golang-dev
https://golang.org/cl/9223046
2013-05-28 18:59:10 -06:00
|
|
|
#pragma varargck type "c" int32
|
2008-12-15 11:50:33 -07:00
|
|
|
#pragma varargck type "d" int32
|
|
|
|
#pragma varargck type "d" uint32
|
|
|
|
#pragma varargck type "D" int64
|
|
|
|
#pragma varargck type "D" uint64
|
|
|
|
#pragma varargck type "x" int32
|
|
|
|
#pragma varargck type "x" uint32
|
|
|
|
#pragma varargck type "X" int64
|
|
|
|
#pragma varargck type "X" uint64
|
|
|
|
#pragma varargck type "p" void*
|
2009-03-30 01:01:07 -06:00
|
|
|
#pragma varargck type "p" uintptr
|
2008-12-15 11:50:33 -07:00
|
|
|
#pragma varargck type "s" int8*
|
|
|
|
#pragma varargck type "s" uint8*
|
2009-04-09 19:16:21 -06:00
|
|
|
#pragma varargck type "S" String
|
2008-12-15 11:50:33 -07:00
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void runtime·stoptheworld(void);
|
2012-05-15 09:10:16 -06:00
|
|
|
void runtime·starttheworld(void);
|
2012-02-22 19:45:01 -07:00
|
|
|
extern uint32 runtime·worldsema;
|
2008-12-05 16:24:18 -07:00
|
|
|
|
2008-08-04 17:43:49 -06:00
|
|
|
/*
|
|
|
|
* mutual exclusion locks. in the uncontended case,
|
|
|
|
* as fast as spin locks (just a few user-level instructions),
|
|
|
|
* but on the contention path they sleep in the kernel.
|
2008-08-05 15:18:47 -06:00
|
|
|
* a zeroed Lock is unlocked (no need to initialize each lock).
|
2008-08-04 17:43:49 -06:00
|
|
|
*/
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void runtime·lock(Lock*);
|
|
|
|
void runtime·unlock(Lock*);
|
2008-08-04 17:43:49 -06:00
|
|
|
|
|
|
|
/*
|
2009-10-14 14:02:05 -06:00
|
|
|
* sleep and wakeup on one-time events.
|
2008-08-05 15:21:42 -06:00
|
|
|
* before any calls to notesleep or notewakeup,
|
2008-08-05 15:18:47 -06:00
|
|
|
* must call noteclear to initialize the Note.
|
2011-08-03 13:51:55 -06:00
|
|
|
* then, exactly one thread can call notesleep
|
2008-08-05 15:18:47 -06:00
|
|
|
* and exactly one thread can call notewakeup (once).
|
2011-08-03 13:51:55 -06:00
|
|
|
* once notewakeup has been called, the notesleep
|
|
|
|
* will return. future notesleep will return immediately.
|
|
|
|
* subsequent noteclear must be called only after
|
|
|
|
* previous notesleep has returned, e.g. it's disallowed
|
|
|
|
* to call noteclear straight after notewakeup.
|
runtime: add timer support, use for package time
This looks like it is just moving some code from
time to runtime (and translating it to C), but the
runtime can do a better job managing the goroutines,
and it needs this functionality for its own maintenance
(for example, for the garbage collector to hand back
unused memory to the OS on a time delay).
Might as well have just one copy of the timer logic,
and runtime can't depend on time, so vice versa.
It also unifies Sleep, NewTicker, and NewTimer behind
one mechanism, so that there are no claims that one
is more efficient than another. (For example, today
people recommend using time.After instead of time.Sleep
to avoid blocking an OS thread.)
Fixes #1644.
Fixes #1731.
Fixes #2190.
R=golang-dev, r, hectorchu, iant, iant, jsing, alex.brainman, dvyukov
CC=golang-dev
https://golang.org/cl/5334051
2011-11-09 13:17:05 -07:00
|
|
|
*
|
|
|
|
* notetsleep is like notesleep but wakes up after
|
|
|
|
* a given number of nanoseconds even if the event
|
|
|
|
* has not yet happened. if a goroutine uses notetsleep to
|
|
|
|
* wake up early, it must wait to call noteclear until it
|
|
|
|
* can be sure that no other goroutine is calling
|
|
|
|
* notewakeup.
|
2013-07-22 13:02:27 -06:00
|
|
|
*
|
|
|
|
* notesleep/notetsleep are generally called on g0,
|
|
|
|
* notetsleepg is similar to notetsleep but is called on user g.
|
2008-08-04 17:43:49 -06:00
|
|
|
*/
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void runtime·noteclear(Note*);
|
|
|
|
void runtime·notesleep(Note*);
|
|
|
|
void runtime·notewakeup(Note*);
|
2013-05-29 01:49:45 -06:00
|
|
|
bool runtime·notetsleep(Note*, int64); // false - timeout
|
2013-07-22 13:02:27 -06:00
|
|
|
bool runtime·notetsleepg(Note*, int64); // false - timeout
|
runtime: add timer support, use for package time
This looks like it is just moving some code from
time to runtime (and translating it to C), but the
runtime can do a better job managing the goroutines,
and it needs this functionality for its own maintenance
(for example, for the garbage collector to hand back
unused memory to the OS on a time delay).
Might as well have just one copy of the timer logic,
and runtime can't depend on time, so vice versa.
It also unifies Sleep, NewTicker, and NewTimer behind
one mechanism, so that there are no claims that one
is more efficient than another. (For example, today
people recommend using time.After instead of time.Sleep
to avoid blocking an OS thread.)
Fixes #1644.
Fixes #1731.
Fixes #2190.
R=golang-dev, r, hectorchu, iant, iant, jsing, alex.brainman, dvyukov
CC=golang-dev
https://golang.org/cl/5334051
2011-11-09 13:17:05 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* low-level synchronization for implementing the above
|
|
|
|
*/
|
|
|
|
uintptr runtime·semacreate(void);
|
|
|
|
int32 runtime·semasleep(int64);
|
|
|
|
void runtime·semawakeup(M*);
|
|
|
|
// or
|
|
|
|
void runtime·futexsleep(uint32*, uint32, int64);
|
|
|
|
void runtime·futexwakeup(uint32*, uint32);
|
2009-01-13 10:55:24 -07:00
|
|
|
|
2012-04-12 01:49:25 -06:00
|
|
|
/*
|
|
|
|
* Lock-free stack.
|
|
|
|
* Initialize uint64 head to 0, compare with 0 to test for emptiness.
|
|
|
|
* The stack does not keep pointers to nodes,
|
|
|
|
* so they can be garbage collected if there are no other pointers to nodes.
|
|
|
|
*/
|
|
|
|
void runtime·lfstackpush(uint64 *head, LFNode *node);
|
|
|
|
LFNode* runtime·lfstackpop(uint64 *head);
|
|
|
|
|
2012-05-11 00:50:03 -06:00
|
|
|
/*
|
|
|
|
* Parallel for over [0, n).
|
|
|
|
* body() is executed for each iteration.
|
|
|
|
* nthr - total number of worker threads.
|
|
|
|
* ctx - arbitrary user context.
|
|
|
|
* if wait=true, threads return from parfor() when all work is done;
|
|
|
|
* otherwise, threads can return while other threads are still finishing processing.
|
|
|
|
*/
|
|
|
|
ParFor* runtime·parforalloc(uint32 nthrmax);
|
|
|
|
void runtime·parforsetup(ParFor *desc, uint32 nthr, uint32 n, void *ctx, bool wait, void (*body)(ParFor*, uint32));
|
|
|
|
void runtime·parfordo(ParFor *desc);
|
|
|
|
|
2009-11-13 11:08:51 -07:00
|
|
|
/*
|
|
|
|
* This is consistent across Linux and BSD.
|
|
|
|
* If a new OS is added that is different, move this to
|
|
|
|
* $GOOS/$GOARCH/defs.h.
|
|
|
|
*/
|
|
|
|
#define EACCES 13
|
|
|
|
|
2008-06-16 23:34:50 -06:00
|
|
|
/*
|
2011-01-25 14:35:36 -07:00
|
|
|
* low level C-called
|
2008-06-16 23:34:50 -06:00
|
|
|
*/
|
2012-09-20 23:50:02 -06:00
|
|
|
// for mmap, we only pass the lower 32 bits of file offset to the
|
|
|
|
// assembly routine; the higher bits (if required), should be provided
|
|
|
|
// by the assembly routine as 0.
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
uint8* runtime·mmap(byte*, uintptr, int32, int32, int32, uint32);
|
2011-12-20 15:54:40 -07:00
|
|
|
void runtime·munmap(byte*, uintptr);
|
|
|
|
void runtime·madvise(byte*, uintptr, int32);
|
2011-01-25 14:35:36 -07:00
|
|
|
void runtime·memclr(byte*, uintptr);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void runtime·setcallerpc(void*, void*);
|
|
|
|
void* runtime·getcallerpc(void*);
|
2008-06-05 20:38:39 -06:00
|
|
|
|
|
|
|
/*
|
2008-06-16 23:34:50 -06:00
|
|
|
* runtime go-called
|
2008-06-05 20:38:39 -06:00
|
|
|
*/
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void runtime·printbool(bool);
|
2013-02-19 19:05:44 -07:00
|
|
|
void runtime·printbyte(int8);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void runtime·printfloat(float64);
|
|
|
|
void runtime·printint(int64);
|
|
|
|
void runtime·printiface(Iface);
|
|
|
|
void runtime·printeface(Eface);
|
|
|
|
void runtime·printstring(String);
|
|
|
|
void runtime·printpc(void*);
|
|
|
|
void runtime·printpointer(void*);
|
|
|
|
void runtime·printuint(uint64);
|
|
|
|
void runtime·printhex(uint64);
|
|
|
|
void runtime·printslice(Slice);
|
|
|
|
void runtime·printcomplex(Complex128);
|
2013-08-02 14:03:14 -06:00
|
|
|
void runtime·newstackcall(FuncVal*, byte*, uint32);
|
2013-02-21 15:01:13 -07:00
|
|
|
void reflect·call(FuncVal*, byte*, uint32);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void runtime·panic(Eface);
|
|
|
|
void runtime·panicindex(void);
|
|
|
|
void runtime·panicslice(void);
|
2010-10-25 18:55:50 -06:00
|
|
|
|
2010-03-31 16:55:10 -06:00
|
|
|
/*
|
|
|
|
* runtime c-called (but written in Go)
|
|
|
|
*/
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void runtime·printany(Eface);
|
2012-02-12 21:26:20 -07:00
|
|
|
void runtime·newTypeAssertionError(String*, String*, String*, String*, Eface*);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void runtime·newErrorString(String, Eface*);
|
runtime: avoid allocation of internal panic values
If a fault happens in malloc, inevitably the next thing that happens
is a deadlock trying to allocate the panic value that says the fault
happened. Stop doing that, two ways.
First, reject panic in malloc just as we reject panic in garbage collection.
Second, runtime.panicstring was using an error implementation
backed by a Go string, so the interface held an allocated *string.
Since the actual errors are C strings, define a new error
implementation backed by a C char*, which needs no indirection
and therefore no allocation.
This second fix will avoid allocation for errors like nil panic derefs
or division by zero, so it is worth doing even though the first fix
should take care of faults during malloc.
Update #6419
R=golang-dev, dvyukov, dave
CC=golang-dev
https://golang.org/cl/13774043
2013-09-20 13:15:25 -06:00
|
|
|
void runtime·newErrorCString(int8*, Eface*);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void runtime·fadd64c(uint64, uint64, uint64*);
|
|
|
|
void runtime·fsub64c(uint64, uint64, uint64*);
|
|
|
|
void runtime·fmul64c(uint64, uint64, uint64*);
|
|
|
|
void runtime·fdiv64c(uint64, uint64, uint64*);
|
|
|
|
void runtime·fneg64c(uint64, uint64*);
|
|
|
|
void runtime·f32to64c(uint32, uint64*);
|
|
|
|
void runtime·f64to32c(uint64, uint32*);
|
|
|
|
void runtime·fcmp64c(uint64, uint64, int32*, bool*);
|
|
|
|
void runtime·fintto64c(int64, uint64*);
|
|
|
|
void runtime·f64tointc(uint64, int64*, bool*);
|
2008-07-08 11:36:43 -06:00
|
|
|
|
|
|
|
/*
|
2009-01-22 17:23:44 -07:00
|
|
|
* wrapped for go users
|
2008-07-08 11:36:43 -06:00
|
|
|
*/
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
float64 runtime·Inf(int32 sign);
|
|
|
|
float64 runtime·NaN(void);
|
|
|
|
float32 runtime·float32frombits(uint32 i);
|
|
|
|
uint32 runtime·float32tobits(float32 f);
|
|
|
|
float64 runtime·float64frombits(uint64 i);
|
|
|
|
uint64 runtime·float64tobits(float64 f);
|
|
|
|
float64 runtime·frexp(float64 d, int32 *ep);
|
|
|
|
bool runtime·isInf(float64 f, int32 sign);
|
|
|
|
bool runtime·isNaN(float64 f);
|
|
|
|
float64 runtime·ldexp(float64 d, int32 e);
|
|
|
|
float64 runtime·modf(float64 d, float64 *ip);
|
net: add special netFD mutex
The mutex, fdMutex, handles locking and lifetime of sysfd,
and serializes Read and Write methods.
This allows to strip 2 sync.Mutex.Lock calls,
2 sync.Mutex.Unlock calls, 1 defer and some amount
of misc overhead from every network operation.
On linux/amd64, Intel E5-2690:
benchmark old ns/op new ns/op delta
BenchmarkTCP4Persistent 9595 9454 -1.47%
BenchmarkTCP4Persistent-2 8978 8772 -2.29%
BenchmarkTCP4ConcurrentReadWrite 4900 4625 -5.61%
BenchmarkTCP4ConcurrentReadWrite-2 2603 2500 -3.96%
In general it strips 70-500 ns from every network operation depending
on processor model. On my relatively new E5-2690 it accounts to ~5%
of network op cost.
Fixes #6074.
R=golang-dev, bradfitz, alex.brainman, iant, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/12418043
2013-08-09 11:43:00 -06:00
|
|
|
void runtime·semacquire(uint32*, bool);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
void runtime·semrelease(uint32*);
|
|
|
|
int32 runtime·gomaxprocsfunc(int32 n);
|
runtime: improve Linux mutex
The implementation is hybrid active/passive spin/blocking mutex.
The design minimizes amount of context switches and futex calls.
The idea is that all critical sections in runtime are intentially
small, so pure blocking mutex behaves badly causing
a lot of context switches, thread parking/unparking and kernel calls.
Note that some synthetic benchmarks become somewhat slower,
that's due to increased contention on other data structures,
it should not affect programs that do any real work.
On 2 x Intel E5620, 8 HT cores, 2.4GHz
benchmark old ns/op new ns/op delta
BenchmarkSelectContended 521.00 503.00 -3.45%
BenchmarkSelectContended-2 661.00 320.00 -51.59%
BenchmarkSelectContended-4 1139.00 629.00 -44.78%
BenchmarkSelectContended-8 2870.00 878.00 -69.41%
BenchmarkSelectContended-16 5276.00 818.00 -84.50%
BenchmarkChanContended 112.00 103.00 -8.04%
BenchmarkChanContended-2 631.00 174.00 -72.42%
BenchmarkChanContended-4 682.00 272.00 -60.12%
BenchmarkChanContended-8 1601.00 520.00 -67.52%
BenchmarkChanContended-16 3100.00 372.00 -88.00%
BenchmarkChanSync 253.00 239.00 -5.53%
BenchmarkChanSync-2 5030.00 4648.00 -7.59%
BenchmarkChanSync-4 4826.00 4694.00 -2.74%
BenchmarkChanSync-8 4778.00 4713.00 -1.36%
BenchmarkChanSync-16 5289.00 4710.00 -10.95%
BenchmarkChanProdCons0 273.00 254.00 -6.96%
BenchmarkChanProdCons0-2 599.00 400.00 -33.22%
BenchmarkChanProdCons0-4 1168.00 659.00 -43.58%
BenchmarkChanProdCons0-8 2831.00 1057.00 -62.66%
BenchmarkChanProdCons0-16 4197.00 1037.00 -75.29%
BenchmarkChanProdCons10 150.00 140.00 -6.67%
BenchmarkChanProdCons10-2 607.00 268.00 -55.85%
BenchmarkChanProdCons10-4 1137.00 404.00 -64.47%
BenchmarkChanProdCons10-8 2115.00 828.00 -60.85%
BenchmarkChanProdCons10-16 4283.00 855.00 -80.04%
BenchmarkChanProdCons100 117.00 110.00 -5.98%
BenchmarkChanProdCons100-2 558.00 218.00 -60.93%
BenchmarkChanProdCons100-4 722.00 287.00 -60.25%
BenchmarkChanProdCons100-8 1840.00 431.00 -76.58%
BenchmarkChanProdCons100-16 3394.00 448.00 -86.80%
BenchmarkChanProdConsWork0 2014.00 1996.00 -0.89%
BenchmarkChanProdConsWork0-2 1207.00 1127.00 -6.63%
BenchmarkChanProdConsWork0-4 1913.00 611.00 -68.06%
BenchmarkChanProdConsWork0-8 3016.00 949.00 -68.53%
BenchmarkChanProdConsWork0-16 4320.00 1154.00 -73.29%
BenchmarkChanProdConsWork10 1906.00 1897.00 -0.47%
BenchmarkChanProdConsWork10-2 1123.00 1033.00 -8.01%
BenchmarkChanProdConsWork10-4 1076.00 571.00 -46.93%
BenchmarkChanProdConsWork10-8 2748.00 1096.00 -60.12%
BenchmarkChanProdConsWork10-16 4600.00 1105.00 -75.98%
BenchmarkChanProdConsWork100 1884.00 1852.00 -1.70%
BenchmarkChanProdConsWork100-2 1235.00 1146.00 -7.21%
BenchmarkChanProdConsWork100-4 1217.00 619.00 -49.14%
BenchmarkChanProdConsWork100-8 1534.00 509.00 -66.82%
BenchmarkChanProdConsWork100-16 4126.00 918.00 -77.75%
BenchmarkSyscall 34.40 33.30 -3.20%
BenchmarkSyscall-2 160.00 121.00 -24.38%
BenchmarkSyscall-4 131.00 136.00 +3.82%
BenchmarkSyscall-8 139.00 131.00 -5.76%
BenchmarkSyscall-16 161.00 168.00 +4.35%
BenchmarkSyscallWork 950.00 950.00 +0.00%
BenchmarkSyscallWork-2 481.00 480.00 -0.21%
BenchmarkSyscallWork-4 268.00 270.00 +0.75%
BenchmarkSyscallWork-8 156.00 169.00 +8.33%
BenchmarkSyscallWork-16 188.00 184.00 -2.13%
BenchmarkSemaSyntNonblock 36.40 35.60 -2.20%
BenchmarkSemaSyntNonblock-2 81.40 45.10 -44.59%
BenchmarkSemaSyntNonblock-4 126.00 108.00 -14.29%
BenchmarkSemaSyntNonblock-8 112.00 112.00 +0.00%
BenchmarkSemaSyntNonblock-16 110.00 112.00 +1.82%
BenchmarkSemaSyntBlock 35.30 35.30 +0.00%
BenchmarkSemaSyntBlock-2 118.00 124.00 +5.08%
BenchmarkSemaSyntBlock-4 105.00 108.00 +2.86%
BenchmarkSemaSyntBlock-8 101.00 111.00 +9.90%
BenchmarkSemaSyntBlock-16 112.00 118.00 +5.36%
BenchmarkSemaWorkNonblock 810.00 811.00 +0.12%
BenchmarkSemaWorkNonblock-2 476.00 414.00 -13.03%
BenchmarkSemaWorkNonblock-4 238.00 228.00 -4.20%
BenchmarkSemaWorkNonblock-8 140.00 126.00 -10.00%
BenchmarkSemaWorkNonblock-16 117.00 116.00 -0.85%
BenchmarkSemaWorkBlock 810.00 811.00 +0.12%
BenchmarkSemaWorkBlock-2 454.00 466.00 +2.64%
BenchmarkSemaWorkBlock-4 243.00 241.00 -0.82%
BenchmarkSemaWorkBlock-8 145.00 137.00 -5.52%
BenchmarkSemaWorkBlock-16 132.00 123.00 -6.82%
BenchmarkContendedSemaphore 123.00 102.00 -17.07%
BenchmarkContendedSemaphore-2 34.80 34.90 +0.29%
BenchmarkContendedSemaphore-4 34.70 34.80 +0.29%
BenchmarkContendedSemaphore-8 34.70 34.70 +0.00%
BenchmarkContendedSemaphore-16 34.80 34.70 -0.29%
BenchmarkMutex 26.80 26.00 -2.99%
BenchmarkMutex-2 108.00 45.20 -58.15%
BenchmarkMutex-4 103.00 127.00 +23.30%
BenchmarkMutex-8 109.00 147.00 +34.86%
BenchmarkMutex-16 102.00 152.00 +49.02%
BenchmarkMutexSlack 27.00 26.90 -0.37%
BenchmarkMutexSlack-2 149.00 165.00 +10.74%
BenchmarkMutexSlack-4 121.00 209.00 +72.73%
BenchmarkMutexSlack-8 101.00 158.00 +56.44%
BenchmarkMutexSlack-16 97.00 129.00 +32.99%
BenchmarkMutexWork 792.00 794.00 +0.25%
BenchmarkMutexWork-2 407.00 409.00 +0.49%
BenchmarkMutexWork-4 220.00 209.00 -5.00%
BenchmarkMutexWork-8 267.00 160.00 -40.07%
BenchmarkMutexWork-16 315.00 300.00 -4.76%
BenchmarkMutexWorkSlack 792.00 793.00 +0.13%
BenchmarkMutexWorkSlack-2 406.00 404.00 -0.49%
BenchmarkMutexWorkSlack-4 225.00 212.00 -5.78%
BenchmarkMutexWorkSlack-8 268.00 136.00 -49.25%
BenchmarkMutexWorkSlack-16 300.00 300.00 +0.00%
BenchmarkRWMutexWrite100 27.10 27.00 -0.37%
BenchmarkRWMutexWrite100-2 33.10 40.80 +23.26%
BenchmarkRWMutexWrite100-4 113.00 88.10 -22.04%
BenchmarkRWMutexWrite100-8 119.00 95.30 -19.92%
BenchmarkRWMutexWrite100-16 148.00 109.00 -26.35%
BenchmarkRWMutexWrite10 29.60 29.40 -0.68%
BenchmarkRWMutexWrite10-2 111.00 61.40 -44.68%
BenchmarkRWMutexWrite10-4 270.00 208.00 -22.96%
BenchmarkRWMutexWrite10-8 204.00 185.00 -9.31%
BenchmarkRWMutexWrite10-16 261.00 190.00 -27.20%
BenchmarkRWMutexWorkWrite100 1040.00 1036.00 -0.38%
BenchmarkRWMutexWorkWrite100-2 593.00 580.00 -2.19%
BenchmarkRWMutexWorkWrite100-4 470.00 365.00 -22.34%
BenchmarkRWMutexWorkWrite100-8 468.00 289.00 -38.25%
BenchmarkRWMutexWorkWrite100-16 604.00 374.00 -38.08%
BenchmarkRWMutexWorkWrite10 951.00 951.00 +0.00%
BenchmarkRWMutexWorkWrite10-2 1001.00 928.00 -7.29%
BenchmarkRWMutexWorkWrite10-4 1555.00 1006.00 -35.31%
BenchmarkRWMutexWorkWrite10-8 2085.00 1171.00 -43.84%
BenchmarkRWMutexWorkWrite10-16 2082.00 1614.00 -22.48%
R=rsc, iant, msolo, fw, iant
CC=golang-dev
https://golang.org/cl/4711045
2011-07-29 10:44:06 -06:00
|
|
|
void runtime·procyield(uint32);
|
|
|
|
void runtime·osyield(void);
|
2013-02-01 09:34:41 -07:00
|
|
|
void runtime·lockOSThread(void);
|
|
|
|
void runtime·unlockOSThread(void);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
|
2011-08-17 13:54:17 -06:00
|
|
|
Hchan* runtime·makechan_c(ChanType*, int64);
|
2012-10-07 12:05:32 -06:00
|
|
|
void runtime·chansend(ChanType*, Hchan*, byte*, bool*, void*);
|
2011-08-23 11:13:27 -06:00
|
|
|
void runtime·chanrecv(ChanType*, Hchan*, byte*, bool*, bool*);
|
runtime: record proper goroutine state during stack split
Until now, the goroutine state has been scattered during the
execution of newstack and oldstack. It's all there, and those routines
know how to get back to a working goroutine, but other pieces of
the system, like stack traces, do not. If something does interrupt
the newstack or oldstack execution, the rest of the system can't
understand the goroutine. For example, if newstack decides there
is an overflow and calls throw, the stack tracer wouldn't dump the
goroutine correctly.
For newstack to save a useful state snapshot, it needs to be able
to rewind the PC in the function that triggered the split back to
the beginning of the function. (The PC is a few instructions in, just
after the call to morestack.) To make that possible, we change the
prologues to insert a jmp back to the beginning of the function
after the call to morestack. That is, the prologue used to be roughly:
TEXT myfunc
check for split
jmpcond nosplit
call morestack
nosplit:
sub $xxx, sp
Now an extra instruction is inserted after the call:
TEXT myfunc
start:
check for split
jmpcond nosplit
call morestack
jmp start
nosplit:
sub $xxx, sp
The jmp is not executed directly. It is decoded and simulated by
runtime.rewindmorestack to discover the beginning of the function,
and then the call to morestack returns directly to the start label
instead of to the jump instruction. So logically the jmp is still
executed, just not by the cpu.
The prologue thus repeats in the case of a function that needs a
stack split, but against the cost of the split itself, the extra few
instructions are noise. The repeated prologue has the nice effect of
making a stack split double-check that the new stack is big enough:
if morestack happens to return on a too-small stack, we'll now notice
before corruption happens.
The ability for newstack to rewind to the beginning of the function
should help preemption too. If newstack decides that it was called
for preemption instead of a stack split, it now has the goroutine state
correctly paused if rescheduling is needed, and when the goroutine
can run again, it can return to the start label on its original stack
and re-execute the split check.
Here is an example of a split stack overflow showing the full
trace, without any special cases in the stack printer.
(This one was triggered by making the split check incorrect.)
runtime: newstack framesize=0x0 argsize=0x18 sp=0x6aebd0 stack=[0x6b0000, 0x6b0fa0]
morebuf={pc:0x69f5b sp:0x6aebd8 lr:0x0}
sched={pc:0x68880 sp:0x6aebd0 lr:0x0 ctxt:0x34e700}
runtime: split stack overflow: 0x6aebd0 < 0x6b0000
fatal error: runtime: split stack overflow
goroutine 1 [stack split]:
runtime.mallocgc(0x290, 0x100000000, 0x1)
/Users/rsc/g/go/src/pkg/runtime/zmalloc_darwin_amd64.c:21 fp=0x6aebd8
runtime.new()
/Users/rsc/g/go/src/pkg/runtime/zmalloc_darwin_amd64.c:682 +0x5b fp=0x6aec08
go/build.(*Context).Import(0x5ae340, 0xc210030c71, 0xa, 0xc2100b4380, 0x1b, ...)
/Users/rsc/g/go/src/pkg/go/build/build.go:424 +0x3a fp=0x6b00a0
main.loadImport(0xc210030c71, 0xa, 0xc2100b4380, 0x1b, 0xc2100b42c0, ...)
/Users/rsc/g/go/src/cmd/go/pkg.go:249 +0x371 fp=0x6b01a8
main.(*Package).load(0xc21017c800, 0xc2100b42c0, 0xc2101828c0, 0x0, 0x0, ...)
/Users/rsc/g/go/src/cmd/go/pkg.go:431 +0x2801 fp=0x6b0c98
main.loadPackage(0x369040, 0x7, 0xc2100b42c0, 0x0)
/Users/rsc/g/go/src/cmd/go/pkg.go:709 +0x857 fp=0x6b0f80
----- stack segment boundary -----
main.(*builder).action(0xc2100902a0, 0x0, 0x0, 0xc2100e6c00, 0xc2100e5750, ...)
/Users/rsc/g/go/src/cmd/go/build.go:539 +0x437 fp=0x6b14a0
main.(*builder).action(0xc2100902a0, 0x0, 0x0, 0xc21015b400, 0x2, ...)
/Users/rsc/g/go/src/cmd/go/build.go:528 +0x1d2 fp=0x6b1658
main.(*builder).test(0xc2100902a0, 0xc210092000, 0x0, 0x0, 0xc21008ff60, ...)
/Users/rsc/g/go/src/cmd/go/test.go:622 +0x1b53 fp=0x6b1f68
----- stack segment boundary -----
main.runTest(0x5a6b20, 0xc21000a020, 0x2, 0x2)
/Users/rsc/g/go/src/cmd/go/test.go:366 +0xd09 fp=0x6a5cf0
main.main()
/Users/rsc/g/go/src/cmd/go/main.go:161 +0x4f9 fp=0x6a5f78
runtime.main()
/Users/rsc/g/go/src/pkg/runtime/proc.c:183 +0x92 fp=0x6a5fa0
runtime.goexit()
/Users/rsc/g/go/src/pkg/runtime/proc.c:1266 fp=0x6a5fa8
And here is a seg fault during oldstack:
SIGSEGV: segmentation violation
PC=0x1b2a6
runtime.oldstack()
/Users/rsc/g/go/src/pkg/runtime/stack.c:159 +0x76
runtime.lessstack()
/Users/rsc/g/go/src/pkg/runtime/asm_amd64.s:270 +0x22
goroutine 1 [stack unsplit]:
fmt.(*pp).printArg(0x2102e64e0, 0xe5c80, 0x2102c9220, 0x73, 0x0, ...)
/Users/rsc/g/go/src/pkg/fmt/print.go:818 +0x3d3 fp=0x221031e6f8
fmt.(*pp).doPrintf(0x2102e64e0, 0x12fb20, 0x2, 0x221031eb98, 0x1, ...)
/Users/rsc/g/go/src/pkg/fmt/print.go:1183 +0x15cb fp=0x221031eaf0
fmt.Sprintf(0x12fb20, 0x2, 0x221031eb98, 0x1, 0x1, ...)
/Users/rsc/g/go/src/pkg/fmt/print.go:234 +0x67 fp=0x221031eb40
flag.(*stringValue).String(0x2102c9210, 0x1, 0x0)
/Users/rsc/g/go/src/pkg/flag/flag.go:180 +0xb3 fp=0x221031ebb0
flag.(*FlagSet).Var(0x2102f6000, 0x293d38, 0x2102c9210, 0x143490, 0xa, ...)
/Users/rsc/g/go/src/pkg/flag/flag.go:633 +0x40 fp=0x221031eca0
flag.(*FlagSet).StringVar(0x2102f6000, 0x2102c9210, 0x143490, 0xa, 0x12fa60, ...)
/Users/rsc/g/go/src/pkg/flag/flag.go:550 +0x91 fp=0x221031ece8
flag.(*FlagSet).String(0x2102f6000, 0x143490, 0xa, 0x12fa60, 0x0, ...)
/Users/rsc/g/go/src/pkg/flag/flag.go:563 +0x87 fp=0x221031ed38
flag.String(0x143490, 0xa, 0x12fa60, 0x0, 0x161950, ...)
/Users/rsc/g/go/src/pkg/flag/flag.go:570 +0x6b fp=0x221031ed80
testing.init()
/Users/rsc/g/go/src/pkg/testing/testing.go:-531 +0xbb fp=0x221031edc0
strings_test.init()
/Users/rsc/g/go/src/pkg/strings/strings_test.go:1115 +0x62 fp=0x221031ef70
main.init()
strings/_test/_testmain.go:90 +0x3d fp=0x221031ef78
runtime.main()
/Users/rsc/g/go/src/pkg/runtime/proc.c:180 +0x8a fp=0x221031efa0
runtime.goexit()
/Users/rsc/g/go/src/pkg/runtime/proc.c:1269 fp=0x221031efa8
goroutine 2 [runnable]:
runtime.MHeap_Scavenger()
/Users/rsc/g/go/src/pkg/runtime/mheap.c:438
runtime.goexit()
/Users/rsc/g/go/src/pkg/runtime/proc.c:1269
created by runtime.main
/Users/rsc/g/go/src/pkg/runtime/proc.c:166
rax 0x23ccc0
rbx 0x23ccc0
rcx 0x0
rdx 0x38
rdi 0x2102c0170
rsi 0x221032cfe0
rbp 0x221032cfa0
rsp 0x7fff5fbff5b0
r8 0x2102c0120
r9 0x221032cfa0
r10 0x221032c000
r11 0x104ce8
r12 0xe5c80
r13 0x1be82baac718
r14 0x13091135f7d69200
r15 0x0
rip 0x1b2a6
rflags 0x10246
cs 0x2b
fs 0x0
gs 0x0
Fixes #5723.
R=r, dvyukov, go.peter.90, dave, iant
CC=golang-dev
https://golang.org/cl/10360048
2013-06-27 09:32:01 -06:00
|
|
|
bool runtime·showframe(Func*, G*);
|
2013-08-01 09:28:38 -06:00
|
|
|
void runtime·printcreatedby(G*);
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
|
2012-11-01 11:13:20 -06:00
|
|
|
void runtime·ifaceE2I(InterfaceType*, Eface, Iface*);
|
2013-08-14 12:54:31 -06:00
|
|
|
bool runtime·ifaceE2I2(InterfaceType*, Eface, Iface*);
|
2012-02-24 13:28:51 -07:00
|
|
|
uintptr runtime·memlimit(void);
|
2012-02-28 14:18:24 -07:00
|
|
|
|
runtime: inline several float64 routines to speed up complex128 division
Depends on CL 6197045.
Result obtained on Core i7 620M, Darwin/amd64:
benchmark old ns/op new ns/op delta
BenchmarkComplex128DivNormal 57 28 -50.78%
BenchmarkComplex128DivNisNaN 49 15 -68.90%
BenchmarkComplex128DivDisNaN 49 15 -67.88%
BenchmarkComplex128DivNisInf 40 12 -68.50%
BenchmarkComplex128DivDisInf 33 13 -61.06%
Result obtained on Core i7 620M, Darwin/386:
benchmark old ns/op new ns/op delta
BenchmarkComplex128DivNormal 89 50 -44.05%
BenchmarkComplex128DivNisNaN 307 802 +161.24%
BenchmarkComplex128DivDisNaN 309 788 +155.02%
BenchmarkComplex128DivNisInf 278 237 -14.75%
BenchmarkComplex128DivDisInf 46 22 -52.46%
Result obtained on 700MHz OMAP4460, Linux/ARM:
benchmark old ns/op new ns/op delta
BenchmarkComplex128DivNormal 1557 465 -70.13%
BenchmarkComplex128DivNisNaN 1443 220 -84.75%
BenchmarkComplex128DivDisNaN 1481 218 -85.28%
BenchmarkComplex128DivNisInf 952 216 -77.31%
BenchmarkComplex128DivDisInf 861 231 -73.17%
The 386 version has a performance regression, but as we have
decided to use SSE2 instead of x87 FPU for 386 too (issue 3912),
I won't address this issue.
R=dsymonds, mchaten, iant, dave, mtj, rsc, r
CC=golang-dev
https://golang.org/cl/6024045
2012-08-07 09:45:50 -06:00
|
|
|
// float.c
|
|
|
|
extern float64 runtime·nan;
|
|
|
|
extern float64 runtime·posinf;
|
|
|
|
extern float64 runtime·neginf;
|
|
|
|
extern uint64 ·nan;
|
|
|
|
extern uint64 ·posinf;
|
|
|
|
extern uint64 ·neginf;
|
|
|
|
#define ISNAN(f) ((f) != (f))
|
2012-09-24 18:08:05 -06:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2013-03-14 03:48:19 -06:00
|
|
|
UseSpanType = 1,
|
2012-09-24 18:08:05 -06:00
|
|
|
};
|