1
0
mirror of https://github.com/golang/go synced 2024-11-23 03:20:03 -07:00

runtime: use "mp" and "gp" instead of "m" and "g" for local variable name to avoid confusion with the global "m" and "g".

R=golang-dev, minux.ma, rsc
CC=bradfitz, golang-dev
https://golang.org/cl/6939064
This commit is contained in:
Jingcheng Zhang 2012-12-19 00:30:29 +08:00 committed by Shenghou Ma
parent a9d8242311
commit 70e967b7bc
25 changed files with 145 additions and 145 deletions

View File

@ -42,7 +42,7 @@
// 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
@ -181,11 +181,11 @@ unlockm(void)
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);
}

View File

@ -470,7 +470,7 @@ runtime·MHeap_SysAlloc(MHeap *h, uintptr n)
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;
@ -482,8 +482,8 @@ runtime·settype_flush(M *m, bool sysalloc)
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) {
@ -581,7 +581,7 @@ runtime·settype_flush(M *m, bool sysalloc)
}
runtime·unlock(&settype_lock);
m->settype_bufsize = 0;
mp->settype_bufsize = 0;
}
// It is forbidden to use this function if it is possible that
@ -589,7 +589,7 @@ runtime·settype_flush(M *m, bool sysalloc)
void
runtime·settype(void *v, uintptr t)
{
M *m1;
M *mp;
uintptr *buf;
uintptr i;
MSpan *s;
@ -597,16 +597,16 @@ runtime·settype(void *v, uintptr t)
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) {

View File

@ -1160,16 +1160,16 @@ static int32 gcpercent = -2;
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;
@ -1180,17 +1180,17 @@ cachestats(GCStats *stats)
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;
@ -1270,7 +1270,7 @@ gc(struct gc_args *args)
int64 t0, t1, t2, t3;
uint64 heap0, heap1, obj0, obj1;
GCStats stats;
M *m1;
M *mp;
uint32 i;
runtime·semacquire(&runtime·worldsema);
@ -1284,8 +1284,8 @@ gc(struct gc_args *args)
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;

View File

@ -394,18 +394,18 @@ struct TRecord {
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++;
}
}
@ -445,11 +445,11 @@ func Stack(b Slice, all bool) (n int) {
}
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;
}

View File

@ -12,7 +12,7 @@ int32 runtime·close(int32 fd);
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);

View File

@ -264,13 +264,13 @@ schedlock(void)
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
@ -1099,13 +1099,13 @@ runtime·oldstack(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;
@ -1117,9 +1117,9 @@ runtime·oldstack(void)
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
@ -1137,7 +1137,7 @@ runtime·newstack(void)
int32 framesize, minalloc, argsize;
Stktop *top;
byte *stk, *sp;
G *g1;
G *gp;
Gobuf label;
bool reflectcall;
uintptr free;
@ -1145,12 +1145,12 @@ runtime·newstack(void)
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) {
@ -1165,14 +1165,14 @@ runtime·newstack(void)
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.
@ -1188,11 +1188,11 @@ runtime·newstack(void)
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;
@ -1202,11 +1202,11 @@ runtime·newstack(void)
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) {

View File

@ -620,7 +620,7 @@ void runtime·exit1(int32);
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);

View File

@ -139,11 +139,11 @@ runtime·setsig(int32 i, void (*fn)(int32, Siginfo*, void*, G*), bool restart)
}
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;
}

View File

@ -146,12 +146,12 @@ runtime·setsig(int32 i, void (*fn)(int32, Siginfo*, void*, G*), bool restart)
}
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;
}

View File

@ -292,7 +292,7 @@ TEXT runtime·usleep(SB),7,$32
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

View File

@ -254,7 +254,7 @@ TEXT runtime·usleep(SB),7,$16
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

View File

@ -259,7 +259,7 @@ TEXT runtime·futex(SB),7,$0
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
@ -267,7 +267,7 @@ TEXT runtime·clone(SB),7,$0
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)

View File

@ -268,12 +268,12 @@ TEXT runtime·futex(SB),7,$0
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

View File

@ -206,7 +206,7 @@ TEXT runtime·futex(SB),7,$0
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
@ -215,7 +215,7 @@ TEXT runtime·clone(SB),7,$0
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

View File

@ -195,10 +195,10 @@ TEXT runtime·sigtramp(SB),7,$44
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

View File

@ -8,10 +8,10 @@
#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

View File

@ -87,19 +87,19 @@ runtime·goenvs(void)
}
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) {

View File

@ -77,32 +77,32 @@ runtime·futexwakeup(uint32 *addr, uint32 cnt)
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*)&param, 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(&param, sizeof param);
runtime·sigprocmask(&oset, nil);

View File

@ -124,7 +124,7 @@ enum
};
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;
@ -140,16 +140,16 @@ runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void))
| 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) {

View File

@ -25,7 +25,7 @@ static Sigset sigset_none;
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);
@ -149,7 +149,7 @@ runtime·semawakeup(M *mp)
#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;
@ -157,10 +157,10 @@ runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void))
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);
@ -168,9 +168,9 @@ runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void))
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);

View File

@ -23,7 +23,7 @@ extern SigTab runtime·sigtab[];
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);
@ -123,7 +123,7 @@ runtime·semawakeup(M *mp)
}
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;
@ -132,17 +132,17 @@ runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void))
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*)&param, sizeof(param), m, g, fn);
ret = runtime·tfork((byte*)&param, sizeof(param), mp, gp, fn);
runtime·sigprocmask(SIG_SETMASK, oset);
if(ret < 0) {

View File

@ -171,13 +171,13 @@ runtime·itoa(int32 n, byte *p, uint32 len)
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
@ -254,15 +254,15 @@ runtime·exit(int32 e)
}
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");
}

View File

@ -186,22 +186,22 @@ runtime·semacreate(void)
#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).

View File

@ -17,7 +17,7 @@ void _divu(void);
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;
@ -33,7 +33,7 @@ runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr
// 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;
}
@ -45,7 +45,7 @@ runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr
}
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.
@ -146,21 +146,21 @@ runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr
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;
@ -184,7 +184,7 @@ runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr
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)
@ -199,9 +199,9 @@ runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr
}
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)

View File

@ -23,7 +23,7 @@ void runtime·sigpanic(void);
// 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;
@ -40,10 +40,10 @@ runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr
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.
@ -62,7 +62,7 @@ runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr
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.
@ -161,7 +161,7 @@ runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr
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.
@ -171,16 +171,16 @@ runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr
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;
@ -196,7 +196,7 @@ runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr
}
// 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)
@ -211,9 +211,9 @@ runtime·gentraceback(byte *pc0, byte *sp, byte *lr0, G *g, int32 skip, uintptr
}
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