// know about packages). The gcc-compiled C function f calls GoF.
//
// GoF calls crosscall2(_cgoexp_GoF, frame, framesize). Crosscall2
-// (in cgo/$GOOS.S, a gcc-compiled assembly file) is a two-argument
+// (in cgo/gcc_$GOARCH.S, a gcc-compiled assembly file) is a two-argument
// adapter from the gcc function call ABI to the 6c function call ABI.
// It is called from gcc to call 6c functions. In this case it calls
// _cgoexp_GoF(frame, framesize), still running on m->g0's stack
void
runtime·NumCgoCall(int64 ret)
{
- M *m;
+ M *mp;
ret = 0;
- for(m=runtime·atomicloadp(&runtime·allm); m; m=m->alllink)
- ret += m->ncgocall;
+ for(mp=runtime·atomicloadp(&runtime·allm); mp; mp=mp->alllink)
+ ret += mp->ncgocall;
FLUSH(&ret);
}
static Lock settype_lock;
void
-runtime·settype_flush(M *m, bool sysalloc)
+runtime·settype_flush(M *mp, bool sysalloc)
{
uintptr *buf, *endbuf;
uintptr size, ofs, j, t;
uintptr typ, p;
MSpan *s;
- buf = m->settype_buf;
- endbuf = buf + m->settype_bufsize;
+ buf = mp->settype_buf;
+ endbuf = buf + mp->settype_bufsize;
runtime·lock(&settype_lock);
while(buf < endbuf) {
}
runtime·unlock(&settype_lock);
- m->settype_bufsize = 0;
+ mp->settype_bufsize = 0;
}
// It is forbidden to use this function if it is possible that
void
runtime·settype(void *v, uintptr t)
{
- M *m1;
+ M *mp;
uintptr *buf;
uintptr i;
MSpan *s;
if(t == 0)
runtime·throw("settype: zero type");
- m1 = m;
- buf = m1->settype_buf;
- i = m1->settype_bufsize;
+ mp = m;
+ buf = mp->settype_buf;
+ i = mp->settype_bufsize;
buf[i+0] = (uintptr)v;
buf[i+1] = t;
i += 2;
- m1->settype_bufsize = i;
+ mp->settype_bufsize = i;
- if(i == nelem(m1->settype_buf)) {
- runtime·settype_flush(m1, false);
+ if(i == nelem(mp->settype_buf)) {
+ runtime·settype_flush(mp, false);
}
if(DebugTypeAtBlockEnd) {
static void
stealcache(void)
{
- M *m;
+ M *mp;
- for(m=runtime·allm; m; m=m->alllink)
- runtime·MCache_ReleaseAll(m->mcache);
+ for(mp=runtime·allm; mp; mp=mp->alllink)
+ runtime·MCache_ReleaseAll(mp->mcache);
}
static void
cachestats(GCStats *stats)
{
- M *m;
+ M *mp;
MCache *c;
int32 i;
uint64 stacks_inuse;
runtime·memclr((byte*)stats, sizeof(*stats));
stacks_inuse = 0;
stacks_sys = 0;
- for(m=runtime·allm; m; m=m->alllink) {
- c = m->mcache;
+ for(mp=runtime·allm; mp; mp=mp->alllink) {
+ c = mp->mcache;
runtime·purgecachedstats(c);
- stacks_inuse += m->stackalloc->inuse;
- stacks_sys += m->stackalloc->sys;
+ stacks_inuse += mp->stackalloc->inuse;
+ stacks_sys += mp->stackalloc->sys;
if(stats) {
- src = (uint64*)&m->gcstats;
+ src = (uint64*)&mp->gcstats;
dst = (uint64*)stats;
for(i=0; i<sizeof(*stats)/sizeof(uint64); i++)
dst[i] += src[i];
- runtime·memclr((byte*)&m->gcstats, sizeof(m->gcstats));
+ runtime·memclr((byte*)&mp->gcstats, sizeof(mp->gcstats));
}
for(i=0; i<nelem(c->local_by_size); i++) {
mstats.by_size[i].nmalloc += c->local_by_size[i].nmalloc;
int64 t0, t1, t2, t3;
uint64 heap0, heap1, obj0, obj1;
GCStats stats;
- M *m1;
+ M *mp;
uint32 i;
runtime·semacquire(&runtime·worldsema);
m->gcing = 1;
runtime·stoptheworld();
- for(m1=runtime·allm; m1; m1=m1->alllink)
- runtime·settype_flush(m1, false);
+ for(mp=runtime·allm; mp; mp=mp->alllink)
+ runtime·settype_flush(mp, false);
heap0 = 0;
obj0 = 0;
func ThreadCreateProfile(p Slice) (n int, ok bool) {
TRecord *r;
- M *first, *m;
+ M *first, *mp;
first = runtime·atomicloadp(&runtime·allm);
n = 0;
- for(m=first; m; m=m->alllink)
+ for(mp=first; mp; mp=mp->alllink)
n++;
ok = false;
if(n <= p.len) {
ok = true;
r = (TRecord*)p.array;
- for(m=first; m; m=m->alllink) {
- runtime·memmove(r->stk, m->createstack, sizeof r->stk);
+ for(mp=first; mp; mp=mp->alllink) {
+ runtime·memmove(r->stk, mp->createstack, sizeof r->stk);
r++;
}
}
}
static void
-saveg(byte *pc, byte *sp, G *g, TRecord *r)
+saveg(byte *pc, byte *sp, G *gp, TRecord *r)
{
int32 n;
- n = runtime·gentraceback(pc, sp, 0, g, 0, r->stk, nelem(r->stk));
+ n = runtime·gentraceback(pc, sp, 0, gp, 0, r->stk, nelem(r->stk));
if(n < nelem(r->stk))
r->stk[n] = 0;
}
void runtime·exits(int8* msg);
intptr runtime·brk_(void*);
int32 runtime·sleep(int32 ms);
-int32 runtime·rfork(int32 flags, void *stk, M *m, G *g, void (*fn)(void));
+int32 runtime·rfork(int32 flags, void *stk, M *mp, G *gp, void (*fn)(void));
int32 runtime·plan9_semacquire(uint32 *addr, int32 block);
int32 runtime·plan9_tsemacquire(uint32 *addr, int32 ms);
int32 runtime·plan9_semrelease(uint32 *addr, int32 count);
static void
schedunlock(void)
{
- M *m;
+ M *mp;
- m = mwakeup;
+ mp = mwakeup;
mwakeup = nil;
runtime·unlock(&runtime·sched);
- if(m != nil)
- runtime·notewakeup(&m->havenextg);
+ if(mp != nil)
+ runtime·notewakeup(&mp->havenextg);
}
void
uint32 argsize;
uintptr cret;
byte *sp;
- G *g1;
+ G *gp;
int64 goid;
//printf("oldstack m->cret=%p\n", m->cret);
- g1 = m->curg;
- top = (Stktop*)g1->stackbase;
+ gp = m->curg;
+ top = (Stktop*)gp->stackbase;
sp = (byte*)top;
old = *top;
argsize = old.argsize;
USED(goid);
if(old.free != 0)
- runtime·stackfree((byte*)g1->stackguard - StackGuard, old.free);
- g1->stackbase = (uintptr)old.stackbase;
- g1->stackguard = (uintptr)old.stackguard;
+ runtime·stackfree((byte*)gp->stackguard - StackGuard, old.free);
+ gp->stackbase = (uintptr)old.stackbase;
+ gp->stackguard = (uintptr)old.stackguard;
cret = m->cret;
m->cret = 0; // drop reference
int32 framesize, minalloc, argsize;
Stktop *top;
byte *stk, *sp;
- G *g1;
+ G *gp;
Gobuf label;
bool reflectcall;
uintptr free;
framesize = m->moreframesize;
minalloc = m->moreframesize_minalloc;
argsize = m->moreargsize;
- g1 = m->curg;
+ gp = m->curg;
m->moreframesize_minalloc = 0;
- if(m->morebuf.sp < g1->stackguard - StackGuard) {
- runtime·printf("runtime: split stack overflow: %p < %p\n", m->morebuf.sp, g1->stackguard - StackGuard);
+ if(m->morebuf.sp < gp->stackguard - StackGuard) {
+ runtime·printf("runtime: split stack overflow: %p < %p\n", m->morebuf.sp, gp->stackguard - StackGuard);
runtime·throw("runtime: split stack overflow");
}
if(argsize % sizeof(uintptr) != 0) {
if(framesize < minalloc)
framesize = minalloc;
- if(reflectcall && minalloc == 0 && m->morebuf.sp - sizeof(Stktop) - argsize - 32 > g1->stackguard) {
+ if(reflectcall && minalloc == 0 && m->morebuf.sp - sizeof(Stktop) - argsize - 32 > gp->stackguard) {
// special case: called from reflect.call (framesize==1)
// to call code with an arbitrary argument size,
// and we have enough space on the current stack.
// the new Stktop* is necessary to unwind, but
// we don't need to create a new segment.
top = (Stktop*)(m->morebuf.sp - sizeof(*top));
- stk = (byte*)g1->stackguard - StackGuard;
+ stk = (byte*)gp->stackguard - StackGuard;
free = 0;
} else {
// allocate new segment.
if(0) {
runtime·printf("newstack framesize=%d argsize=%d morepc=%p moreargp=%p gobuf=%p, %p top=%p old=%p\n",
- framesize, argsize, m->morepc, m->moreargp, m->morebuf.pc, m->morebuf.sp, top, g1->stackbase);
+ framesize, argsize, m->morepc, m->moreargp, m->morebuf.pc, m->morebuf.sp, top, gp->stackbase);
}
- top->stackbase = (byte*)g1->stackbase;
- top->stackguard = (byte*)g1->stackguard;
+ top->stackbase = (byte*)gp->stackbase;
+ top->stackguard = (byte*)gp->stackguard;
top->gobuf = m->morebuf;
top->argp = m->moreargp;
top->argsize = argsize;
m->morebuf.sp = (uintptr)nil;
// copy flag from panic
- top->panic = g1->ispanic;
- g1->ispanic = false;
+ top->panic = gp->ispanic;
+ gp->ispanic = false;
- g1->stackbase = (uintptr)top;
- g1->stackguard = (uintptr)stk + StackGuard;
+ gp->stackbase = (uintptr)top;
+ gp->stackguard = (uintptr)stk + StackGuard;
sp = (byte*)top;
if(argsize > 0) {
void runtime·ready(G*);
byte* runtime·getenv(int8*);
int32 runtime·atoi(byte*);
-void runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void));
+void runtime·newosproc(M *mp, G *gp, void *stk, void (*fn)(void));
void runtime·signalstack(byte*, int32);
G* runtime·malg(int32);
void runtime·asminit(void);
}
void
-runtime·lwp_mcontext_init(McontextT *mc, void *stack, M *m, G *g, void (*fn)(void))
+runtime·lwp_mcontext_init(McontextT *mc, void *stack, M *mp, G *gp, void (*fn)(void))
{
mc->__gregs[REG_EIP] = (uint32)runtime·lwp_tramp;
mc->__gregs[REG_UESP] = (uint32)stack;
- mc->__gregs[REG_EBX] = (uint32)m;
- mc->__gregs[REG_EDX] = (uint32)g;
+ mc->__gregs[REG_EBX] = (uint32)mp;
+ mc->__gregs[REG_EDX] = (uint32)gp;
mc->__gregs[REG_ESI] = (uint32)fn;
}
}
void
-runtime·lwp_mcontext_init(McontextT *mc, void *stack, M *m, G *g, void (*fn)(void))
+runtime·lwp_mcontext_init(McontextT *mc, void *stack, M *mp, G *gp, void (*fn)(void))
{
// Machine dependent mcontext initialisation for LWP.
mc->__gregs[REG_RIP] = (uint64)runtime·lwp_tramp;
mc->__gregs[REG_RSP] = (uint64)stack;
- mc->__gregs[REG_R8] = (uint64)m;
- mc->__gregs[REG_R9] = (uint64)g;
+ mc->__gregs[REG_R8] = (uint64)mp;
+ mc->__gregs[REG_R9] = (uint64)gp;
mc->__gregs[REG_R12] = (uint64)fn;
}
INT $0x80
RET
-// void bsdthread_create(void *stk, M *m, G *g, void (*fn)(void))
+// void bsdthread_create(void *stk, M *mp, G *gp, void (*fn)(void))
// System call args are: func arg stack pthread flags.
TEXT runtime·bsdthread_create(SB),7,$32
MOVL $360, AX
SYSCALL
RET
-// void bsdthread_create(void *stk, M *m, G *g, void (*fn)(void))
+// void bsdthread_create(void *stk, M *mp, G *gp, void (*fn)(void))
TEXT runtime·bsdthread_create(SB),7,$0
// Set up arguments to bsdthread_create system call.
// The ones in quotes pass through to the thread callback
CALL *runtime·_vdso(SB)
RET
-// int32 clone(int32 flags, void *stack, M *m, G *g, void (*fn)(void));
+// int32 clone(int32 flags, void *stack, M *mp, G *gp, void (*fn)(void));
TEXT runtime·clone(SB),7,$0
MOVL $120, AX // clone
MOVL flags+4(SP), BX
MOVL $0, DX // parent tid ptr
MOVL $0, DI // child tid ptr
- // Copy m, g, fn off parent stack for use by child.
+ // Copy mp, gp, fn off parent stack for use by child.
SUBL $16, CX
MOVL mm+12(SP), SI
MOVL SI, 0(CX)
SYSCALL
RET
-// int64 clone(int32 flags, void *stack, M *m, G *g, void (*fn)(void));
+// int64 clone(int32 flags, void *stack, M *mp, G *gp, void (*fn)(void));
TEXT runtime·clone(SB),7,$0
MOVL flags+8(SP), DI
MOVQ stack+16(SP), SI
- // Copy m, g, fn off parent stack for use by child.
+ // Copy mp, gp, fn off parent stack for use by child.
// Careful: Linux system call clobbers CX and R11.
MOVQ mm+24(SP), R8
MOVQ gg+32(SP), R9
RET
-// int32 clone(int32 flags, void *stack, M *m, G *g, void (*fn)(void));
+// int32 clone(int32 flags, void *stack, M *mp, G *gp, void (*fn)(void));
TEXT runtime·clone(SB),7,$0
MOVW flags+0(FP), R0
MOVW stack+4(FP), R1
MOVW $0, R4 // child tid ptr
MOVW $0, R5
- // Copy m, g, fn off parent stack for use by child.
+ // Copy mp, gp, fn off parent stack for use by child.
// TODO(kaib): figure out which registers are clobbered by clone and avoid stack copying
MOVW $-16(R1), R1
MOVW mm+8(FP), R6
MOVL $0xf1, 0xf1 // crash
RET
-// int32 tfork(void *param, uintptr psize, M *m, G *g, void (*fn)(void));
+// int32 tfork(void *param, uintptr psize, M *mp, G *gp, void (*fn)(void));
TEXT runtime·tfork(SB),7,$12
- // Copy m, g and fn from the parent stack onto the child stack.
+ // Copy mp, gp and fn from the parent stack onto the child stack.
MOVL params+4(FP), AX
MOVL 8(AX), CX // tf_stack
SUBL $16, CX
#include "zasm_GOOS_GOARCH.h"
-// int64 tfork(void *param, uintptr psize, M *m, G *g, void (*fn)(void));
+// int64 tfork(void *param, uintptr psize, M *mp, G *gp, void (*fn)(void));
TEXT runtime·tfork(SB),7,$32
- // Copy m, g and fn off parent stack for use by child.
+ // Copy mp, gp and fn off parent stack for use by child.
MOVQ mm+16(FP), R8
MOVQ gg+24(FP), R9
MOVQ fn+32(FP), R12
}
void
-runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void))
+runtime·newosproc(M *mp, G *gp, void *stk, void (*fn)(void))
{
int32 errno;
Sigset oset;
- m->tls[0] = m->id; // so 386 asm can find it
+ mp->tls[0] = mp->id; // so 386 asm can find it
if(0){
runtime·printf("newosproc stk=%p m=%p g=%p fn=%p id=%d/%d ostk=%p\n",
- stk, m, g, fn, m->id, m->tls[0], &m);
+ stk, mp, gp, fn, mp->id, mp->tls[0], &mp);
}
runtime·sigprocmask(SIG_SETMASK, &sigset_all, &oset);
- errno = runtime·bsdthread_create(stk, m, g, fn);
+ errno = runtime·bsdthread_create(stk, mp, gp, fn);
runtime·sigprocmask(SIG_SETMASK, &oset, nil);
if(errno < 0) {
void runtime·thr_start(void*);
void
-runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void))
+runtime·newosproc(M *mp, G *gp, void *stk, void (*fn)(void))
{
ThrParam param;
Sigset oset;
USED(fn); // thr_start assumes fn == mstart
- USED(g); // thr_start assumes g == m->g0
+ USED(gp); // thr_start assumes gp == mp->g0
if(0){
runtime·printf("newosproc stk=%p m=%p g=%p fn=%p id=%d/%d ostk=%p\n",
- stk, m, g, fn, m->id, m->tls[0], &m);
+ stk, mp, gp, fn, mp->id, mp->tls[0], &mp);
}
runtime·sigprocmask(&sigset_all, &oset);
runtime·memclr((byte*)¶m, sizeof param);
param.start_func = runtime·thr_start;
- param.arg = (byte*)m;
- param.stack_base = (void*)g->stackbase;
- param.stack_size = (byte*)stk - (byte*)g->stackbase;
- param.child_tid = (intptr*)&m->procid;
+ param.arg = (byte*)mp;
+ param.stack_base = (void*)gp->stackbase;
+ param.stack_size = (byte*)stk - (byte*)gp->stackbase;
+ param.child_tid = (intptr*)&mp->procid;
param.parent_tid = nil;
- param.tls_base = (void*)&m->tls[0];
- param.tls_size = sizeof m->tls;
+ param.tls_base = (void*)&mp->tls[0];
+ param.tls_size = sizeof mp->tls;
- m->tls[0] = m->id; // so 386 asm can find it
+ mp->tls[0] = mp->id; // so 386 asm can find it
runtime·thr_new(¶m, sizeof param);
runtime·sigprocmask(&oset, nil);
};
void
-runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void))
+runtime·newosproc(M *mp, G *gp, void *stk, void (*fn)(void))
{
int32 ret;
int32 flags;
| CLONE_THREAD /* revisit - okay for now */
;
- m->tls[0] = m->id; // so 386 asm can find it
+ mp->tls[0] = mp->id; // so 386 asm can find it
if(0){
runtime·printf("newosproc stk=%p m=%p g=%p fn=%p clone=%p id=%d/%d ostk=%p\n",
- stk, m, g, fn, runtime·clone, m->id, m->tls[0], &m);
+ stk, mp, gp, fn, runtime·clone, mp->id, mp->tls[0], &mp);
}
// Disable signals during clone, so that the new thread starts
// with signals disabled. It will enable them in minit.
runtime·rtsigprocmask(SIG_SETMASK, &sigset_all, &oset, sizeof oset);
- ret = runtime·clone(flags, stk, m, g, fn);
+ ret = runtime·clone(flags, stk, mp, gp, fn);
runtime·rtsigprocmask(SIG_SETMASK, &oset, nil, sizeof oset);
if(ret < 0) {
extern void runtime·getcontext(UcontextT *context);
extern int32 runtime·lwp_create(UcontextT *context, uintptr flags, void *lwpid);
-extern void runtime·lwp_mcontext_init(void *mc, void *stack, M *m, G *g, void (*fn)(void));
+extern void runtime·lwp_mcontext_init(void *mc, void *stack, M *mp, G *gp, void (*fn)(void));
extern int32 runtime·lwp_park(Timespec *abstime, int32 unpark, void *hint, void *unparkhint);
extern int32 runtime·lwp_unpark(int32 lwp, void *hint);
extern int32 runtime·lwp_self(void);
#define _UC_CPU 0x04
void
-runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void))
+runtime·newosproc(M *mp, G *gp, void *stk, void (*fn)(void))
{
UcontextT uc;
int32 ret;
if(0) {
runtime·printf(
"newosproc stk=%p m=%p g=%p fn=%p id=%d/%d ostk=%p\n",
- stk, m, g, fn, m->id, m->tls[0], &m);
+ stk, mp, gp, fn, mp->id, mp->tls[0], &mp);
}
- m->tls[0] = m->id; // so 386 asm can find it
+ mp->tls[0] = mp->id; // so 386 asm can find it
runtime·getcontext(&uc);
uc.uc_link = nil;
uc.uc_sigmask = sigset_all;
- runtime·lwp_mcontext_init(&uc.uc_mcontext, stk, m, g, fn);
+ runtime·lwp_mcontext_init(&uc.uc_mcontext, stk, mp, gp, fn);
- ret = runtime·lwp_create(&uc, 0, &m->procid);
+ ret = runtime·lwp_create(&uc, 0, &mp->procid);
if(ret < 0) {
runtime·printf("runtime: failed to create new OS thread (have %d already; errno=%d)\n", runtime·mcount() - 1, -ret);
static Sigset sigset_all = ~(Sigset)0;
static Sigset sigset_none;
-extern int64 runtime·tfork(void *param, uintptr psize, M *m, G *g, void (*fn)(void));
+extern int64 runtime·tfork(void *param, uintptr psize, M *mp, G *gp, void (*fn)(void));
extern int32 runtime·thrsleep(void *ident, int32 clock_id, void *tsp, void *lock, const int32 *abort);
extern int32 runtime·thrwakeup(void *ident, int32 n);
}
void
-runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void))
+runtime·newosproc(M *mp, G *gp, void *stk, void (*fn)(void))
{
Tfork param;
Sigset oset;
if(0) {
runtime·printf(
"newosproc stk=%p m=%p g=%p fn=%p id=%d/%d ostk=%p\n",
- stk, m, g, fn, m->id, m->tls[0], &m);
+ stk, mp, gp, fn, mp->id, mp->tls[0], &mp);
}
- m->tls[0] = m->id; // so 386 asm can find it
+ mp->tls[0] = mp->id; // so 386 asm can find it
- param.tf_tcb = (byte*)&m->tls[0];
- param.tf_tid = (int32*)&m->procid;
+ param.tf_tcb = (byte*)&mp->tls[0];
+ param.tf_tid = (int32*)&mp->procid;
param.tf_stack = stk;
oset = runtime·sigprocmask(SIG_SETMASK, sigset_all);
- ret = runtime·tfork((byte*)¶m, sizeof(param), m, g, fn);
+ ret = runtime·tfork((byte*)¶m, sizeof(param), mp, gp, fn);
runtime·sigprocmask(SIG_SETMASK, oset);
if(ret < 0) {
void
goexitsall(void)
{
- M *m;
+ M *mp;
int32 pid;
pid = getpid();
- for(m=runtime·atomicloadp(&runtime·allm); m; m=m->alllink)
- if(m->procid != pid)
- runtime·postnote(m->procid, "gointr");
+ for(mp=runtime·atomicloadp(&runtime·allm); mp; mp=mp->alllink)
+ if(mp->procid != pid)
+ runtime·postnote(mp->procid, "gointr");
}
void
}
void
-runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void))
+runtime·newosproc(M *mp, G *gp, void *stk, void (*fn)(void))
{
- m->tls[0] = m->id; // so 386 asm can find it
+ mp->tls[0] = mp->id; // so 386 asm can find it
if(0){
runtime·printf("newosproc stk=%p m=%p g=%p fn=%p rfork=%p id=%d/%d ostk=%p\n",
- stk, m, g, fn, runtime·rfork, m->id, m->tls[0], &m);
+ stk, mp, gp, fn, runtime·rfork, mp->id, mp->tls[0], &mp);
}
- if(runtime·rfork(RFPROC|RFMEM|RFNOWAIT, stk, m, g, fn) < 0)
+ if(runtime·rfork(RFPROC|RFMEM|RFNOWAIT, stk, mp, gp, fn) < 0)
runtime·throw("newosproc: rfork failed");
}
#define STACK_SIZE_PARAM_IS_A_RESERVATION ((uintptr)0x00010000)
void
-runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void))
+runtime·newosproc(M *mp, G *gp, void *stk, void (*fn)(void))
{
void *thandle;
USED(stk);
- USED(g); // assuming g = m->g0
+ USED(gp); // assuming gp = mp->g0
USED(fn); // assuming fn = mstart
thandle = runtime·stdcall(runtime·CreateThread, 6,
- nil, (uintptr)0x20000, runtime·tstart_stdcall, m,
+ nil, (uintptr)0x20000, runtime·tstart_stdcall, mp,
STACK_SIZE_PARAM_IS_A_RESERVATION, nil);
if(thandle == nil) {
runtime·printf("runtime: failed to create new OS thread (have %d already; errno=%d)\n", runtime·mcount(), runtime·getlasterror());
runtime·throw("runtime.newosproc");
}
- runtime·atomicstorep(&m->thread, thandle);
+ runtime·atomicstorep(&mp->thread, thandle);
}
// Called to initialize a new m (including the bootstrap m).
void _modu(void);
int32
-runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr *pcbuf, int32 max)
+runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *gp, int32 skip, uintptr *pcbuf, int32 max)
{
int32 i, n, iter;
uintptr pc, lr, tracepc, x;
// If the PC is goexit, the goroutine hasn't started yet.
if(pc == (uintptr)runtime·goexit) {
- pc = (uintptr)g->entry;
+ pc = (uintptr)gp->entry;
lr = (uintptr)runtime·goexit;
}
}
n = 0;
- stk = (Stktop*)g->stackbase;
+ stk = (Stktop*)gp->stackbase;
for(iter = 0; iter < 100 && n < max; iter++) { // iter avoids looping forever
// Typically:
// pc is the PC of the running function.
waspanic = f->entry == (uintptr)runtime·sigpanic;
- if(pcbuf == nil && f->entry == (uintptr)runtime·newstack && g == m->g0) {
+ if(pcbuf == nil && f->entry == (uintptr)runtime·newstack && gp == m->g0) {
runtime·printf("----- newstack called from goroutine %D -----\n", m->curg->goid);
pc = (uintptr)m->morepc;
sp = (byte*)m->moreargp - sizeof(void*);
lr = (uintptr)m->morebuf.pc;
fp = (byte*)m->morebuf.sp;
- g = m->curg;
- stk = (Stktop*)g->stackbase;
+ gp = m->curg;
+ stk = (Stktop*)gp->stackbase;
continue;
}
- if(pcbuf == nil && f->entry == (uintptr)runtime·lessstack && g == m->g0) {
+ if(pcbuf == nil && f->entry == (uintptr)runtime·lessstack && gp == m->g0) {
runtime·printf("----- lessstack called from goroutine %D -----\n", m->curg->goid);
- g = m->curg;
- stk = (Stktop*)g->stackbase;
+ gp = m->curg;
+ stk = (Stktop*)gp->stackbase;
sp = (byte*)stk->gobuf.sp;
pc = (uintptr)stk->gobuf.pc;
fp = nil;
sp += 12;
}
- if(pcbuf == nil && (pc = g->gopc) != 0 && (f = runtime·findfunc(pc)) != nil && g->goid != 1) {
+ if(pcbuf == nil && (pc = gp->gopc) != 0 && (f = runtime·findfunc(pc)) != nil && gp->goid != 1) {
runtime·printf("created by %S\n", f->name);
tracepc = pc; // back up to CALL instruction for funcline.
if(n > 0 && pc > f->entry)
}
void
-runtime·traceback(byte *pc0, byte *sp, byte *lr, G *g)
+runtime·traceback(byte *pc0, byte *sp, byte *lr, G *gp)
{
- runtime·gentraceback(pc0, sp, lr, g, 0, nil, 100);
+ runtime·gentraceback(pc0, sp, lr, gp, 0, nil, 100);
}
// func caller(n int) (pc uintptr, file string, line int, ok bool)
// A little clunky to merge the two but avoids duplicating
// the code and all its subtlety.
int32
-runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr *pcbuf, int32 max)
+runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *gp, int32 skip, uintptr *pcbuf, int32 max)
{
byte *p;
int32 i, n, iter, sawnewstack;
waspanic = false;
// If the PC is goexit, the goroutine hasn't started yet.
- if(pc0 == g->sched.pc && sp == (byte*)g->sched.sp && pc0 == (byte*)runtime·goexit) {
+ if(pc0 == gp->sched.pc && sp == (byte*)gp->sched.sp && pc0 == (byte*)runtime·goexit) {
fp = sp;
lr = pc;
- pc = (uintptr)g->entry;
+ pc = (uintptr)gp->entry;
}
// If the PC is zero, it's likely a nil function call.
n = 0;
sawnewstack = 0;
- stk = (Stktop*)g->stackbase;
+ stk = (Stktop*)gp->stackbase;
for(iter = 0; iter < 100 && n < max; iter++) { // iter avoids looping forever
// Typically:
// pc is the PC of the running function.
if(f->entry == (uintptr)runtime·newstack)
sawnewstack = 1;
- if(pcbuf == nil && f->entry == (uintptr)runtime·morestack && g == m->g0 && sawnewstack) {
+ if(pcbuf == nil && f->entry == (uintptr)runtime·morestack && gp == m->g0 && sawnewstack) {
// The fact that we saw newstack means that morestack
// has managed to record its information in m, so we can
// use it to keep unwinding the stack.
lr = (uintptr)m->morebuf.pc;
fp = (byte*)m->morebuf.sp;
sawnewstack = 0;
- g = m->curg;
- stk = (Stktop*)g->stackbase;
+ gp = m->curg;
+ stk = (Stktop*)gp->stackbase;
continue;
}
- if(pcbuf == nil && f->entry == (uintptr)runtime·lessstack && g == m->g0) {
+ if(pcbuf == nil && f->entry == (uintptr)runtime·lessstack && gp == m->g0) {
// Lessstack is running on scheduler stack. Switch to original goroutine.
runtime·printf("----- lessstack called from goroutine %D -----\n", m->curg->goid);
- g = m->curg;
- stk = (Stktop*)g->stackbase;
+ gp = m->curg;
+ stk = (Stktop*)gp->stackbase;
sp = (byte*)stk->gobuf.sp;
pc = (uintptr)stk->gobuf.pc;
fp = nil;
}
// Show what created goroutine, except main goroutine (goid 1).
- if(pcbuf == nil && (pc = g->gopc) != 0 && (f = runtime·findfunc(pc)) != nil && g->goid != 1) {
+ if(pcbuf == nil && (pc = gp->gopc) != 0 && (f = runtime·findfunc(pc)) != nil && gp->goid != 1) {
runtime·printf("created by %S\n", f->name);
tracepc = pc; // back up to CALL instruction for funcline.
if(n > 0 && pc > f->entry)
}
void
-runtime·traceback(byte *pc0, byte *sp, byte*, G *g)
+runtime·traceback(byte *pc0, byte *sp, byte*, G *gp)
{
- runtime·gentraceback(pc0, sp, nil, g, 0, nil, 100);
+ runtime·gentraceback(pc0, sp, nil, gp, 0, nil, 100);
}
int32