mirror of
https://github.com/golang/go
synced 2024-11-22 01:14:40 -07:00
runtime: replace centralized ncgocall counter with a distributed one
R=golang-dev, rsc CC=golang-dev https://golang.org/cl/4809042
This commit is contained in:
parent
6c46afdf41
commit
d6ed1b70ad
@ -83,7 +83,6 @@
|
||||
// callee-save registers for gcc and returns to GoF, which returns to f.
|
||||
|
||||
void *initcgo; /* filled in by dynamic linker when Cgo is available */
|
||||
int64 ncgocall;
|
||||
|
||||
static void unlockm(void);
|
||||
static void unwindm(void);
|
||||
@ -101,7 +100,7 @@ runtime·cgocall(void (*fn)(void*), void *arg)
|
||||
if(fn == 0)
|
||||
runtime·throw("cgocall nil");
|
||||
|
||||
ncgocall++;
|
||||
m->ncgocall++;
|
||||
|
||||
/*
|
||||
* Lock g to m to ensure we stay on the same stack if we do a
|
||||
@ -155,7 +154,11 @@ unlockm(void)
|
||||
void
|
||||
runtime·Cgocalls(int64 ret)
|
||||
{
|
||||
ret = ncgocall;
|
||||
M *m;
|
||||
|
||||
ret = 0;
|
||||
for(m=runtime·atomicloadp(&runtime·allm); m; m=m->alllink)
|
||||
ret += m->ncgocall;
|
||||
FLUSH(&ret);
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,9 @@ mcommoninit(M *m)
|
||||
// Add to runtime·allm so garbage collector doesn't free m
|
||||
// when it is just in a register or thread-local storage.
|
||||
m->alllink = runtime·allm;
|
||||
runtime·allm = m;
|
||||
// runtime·Cgocalls() iterates over allm w/o schedlock,
|
||||
// so we need to publish it safely.
|
||||
runtime·atomicstorep(&runtime·allm, m);
|
||||
|
||||
m->id = runtime·sched.mcount++;
|
||||
m->fastrand = 0x49f6428aUL + m->id;
|
||||
|
@ -231,6 +231,7 @@ struct M
|
||||
int32 dying;
|
||||
int32 profilehz;
|
||||
uint32 fastrand;
|
||||
uint64 ncgocall;
|
||||
Note havenextg;
|
||||
G* nextg;
|
||||
M* alllink; // on allm
|
||||
|
Loading…
Reference in New Issue
Block a user