mirror of
https://github.com/golang/go
synced 2024-11-19 06:04:39 -07:00
runtime: fix dump of data/bss
Fixes #8530. LGTM=khr R=golang-codereviews, khr CC=golang-codereviews, rsc https://golang.org/cl/124440043
This commit is contained in:
parent
30940cfad6
commit
101c00a44f
@ -23,8 +23,6 @@ extern byte data[];
|
|||||||
extern byte edata[];
|
extern byte edata[];
|
||||||
extern byte bss[];
|
extern byte bss[];
|
||||||
extern byte ebss[];
|
extern byte ebss[];
|
||||||
extern byte gcdata[];
|
|
||||||
extern byte gcbss[];
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
FieldKindEol = 0,
|
FieldKindEol = 0,
|
||||||
@ -497,13 +495,13 @@ dumproots(void)
|
|||||||
dumpint(TagData);
|
dumpint(TagData);
|
||||||
dumpint((uintptr)data);
|
dumpint((uintptr)data);
|
||||||
dumpmemrange(data, edata - data);
|
dumpmemrange(data, edata - data);
|
||||||
dumpfields((BitVector){(edata - data)*8, (uint32*)gcdata});
|
dumpfields((BitVector){(edata - data)*8, (uint32*)runtime·gcdatamask});
|
||||||
|
|
||||||
// bss segment
|
// bss segment
|
||||||
dumpint(TagBss);
|
dumpint(TagBss);
|
||||||
dumpint((uintptr)bss);
|
dumpint((uintptr)bss);
|
||||||
dumpmemrange(bss, ebss - bss);
|
dumpmemrange(bss, ebss - bss);
|
||||||
dumpfields((BitVector){(ebss - bss)*8, (uint32*)gcbss});
|
dumpfields((BitVector){(ebss - bss)*8, (uint32*)runtime·gcbssmask});
|
||||||
|
|
||||||
// MSpan.types
|
// MSpan.types
|
||||||
allspans = runtime·mheap.allspans;
|
allspans = runtime·mheap.allspans;
|
||||||
|
@ -78,10 +78,9 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define ScanConservatively ((byte*)1)
|
#define ScanConservatively ((byte*)1)
|
||||||
#define GcpercentUnknown (-2)
|
|
||||||
|
|
||||||
// Initialized from $GOGC. GOGC=off means no gc.
|
// Initialized from $GOGC. GOGC=off means no gc.
|
||||||
extern int32 runtime·gcpercent = GcpercentUnknown;
|
extern int32 runtime·gcpercent;
|
||||||
|
|
||||||
static FuncVal* poolcleanup;
|
static FuncVal* poolcleanup;
|
||||||
|
|
||||||
@ -172,6 +171,8 @@ static FinBlock *finc; // cache of free blocks
|
|||||||
static FinBlock *allfin; // list of all blocks
|
static FinBlock *allfin; // list of all blocks
|
||||||
bool runtime·fingwait;
|
bool runtime·fingwait;
|
||||||
bool runtime·fingwake;
|
bool runtime·fingwake;
|
||||||
|
byte* runtime·gcdatamask;
|
||||||
|
byte* runtime·gcbssmask;
|
||||||
|
|
||||||
static Lock gclock;
|
static Lock gclock;
|
||||||
|
|
||||||
@ -200,8 +201,6 @@ static struct {
|
|||||||
volatile uint32 ndone;
|
volatile uint32 ndone;
|
||||||
Note alldone;
|
Note alldone;
|
||||||
ParFor* markfor;
|
ParFor* markfor;
|
||||||
byte* gcdata;
|
|
||||||
byte* gcbss;
|
|
||||||
} work;
|
} work;
|
||||||
|
|
||||||
// scanblock scans a block of n bytes starting at pointer b for references
|
// scanblock scans a block of n bytes starting at pointer b for references
|
||||||
@ -517,11 +516,11 @@ markroot(ParFor *desc, uint32 i)
|
|||||||
// Note: if you add a case here, please also update heapdump.c:dumproots.
|
// Note: if you add a case here, please also update heapdump.c:dumproots.
|
||||||
switch(i) {
|
switch(i) {
|
||||||
case RootData:
|
case RootData:
|
||||||
scanblock(data, edata - data, work.gcdata);
|
scanblock(data, edata - data, runtime·gcdatamask);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RootBss:
|
case RootBss:
|
||||||
scanblock(bss, ebss - bss, work.gcbss);
|
scanblock(bss, ebss - bss, runtime·gcbssmask);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RootFinalizers:
|
case RootFinalizers:
|
||||||
@ -1300,6 +1299,18 @@ runtime·readgogc(void)
|
|||||||
return runtime·atoi(p);
|
return runtime·atoi(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
runtime·gcinit(void)
|
||||||
|
{
|
||||||
|
if(sizeof(Workbuf) != WorkbufSize)
|
||||||
|
runtime·throw("runtime: size of Workbuf is suboptimal");
|
||||||
|
|
||||||
|
work.markfor = runtime·parforalloc(MaxGcproc);
|
||||||
|
runtime·gcpercent = runtime·readgogc();
|
||||||
|
runtime·gcdatamask = unrollglobgcprog(gcdata, edata - data);
|
||||||
|
runtime·gcbssmask = unrollglobgcprog(gcbss, ebss - bss);
|
||||||
|
}
|
||||||
|
|
||||||
// force = 1 - do GC regardless of current heap usage
|
// force = 1 - do GC regardless of current heap usage
|
||||||
// force = 2 - go GC and eager sweep
|
// force = 2 - go GC and eager sweep
|
||||||
void
|
void
|
||||||
@ -1308,8 +1319,6 @@ runtime·gc(int32 force)
|
|||||||
struct gc_args a;
|
struct gc_args a;
|
||||||
int32 i;
|
int32 i;
|
||||||
|
|
||||||
if(sizeof(Workbuf) != WorkbufSize)
|
|
||||||
runtime·throw("runtime: size of Workbuf is suboptimal");
|
|
||||||
// The gc is turned off (via enablegc) until
|
// The gc is turned off (via enablegc) until
|
||||||
// the bootstrap has completed.
|
// the bootstrap has completed.
|
||||||
// Also, malloc gets called in the guts
|
// Also, malloc gets called in the guts
|
||||||
@ -1321,12 +1330,6 @@ runtime·gc(int32 force)
|
|||||||
if(!mstats.enablegc || g == g->m->g0 || g->m->locks > 0 || runtime·panicking)
|
if(!mstats.enablegc || g == g->m->g0 || g->m->locks > 0 || runtime·panicking)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(runtime·gcpercent == GcpercentUnknown) { // first time through
|
|
||||||
runtime·lock(&runtime·mheap.lock);
|
|
||||||
if(runtime·gcpercent == GcpercentUnknown)
|
|
||||||
runtime·gcpercent = runtime·readgogc();
|
|
||||||
runtime·unlock(&runtime·mheap.lock);
|
|
||||||
}
|
|
||||||
if(runtime·gcpercent < 0)
|
if(runtime·gcpercent < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1415,14 +1418,6 @@ gc(struct gc_args *args)
|
|||||||
t0 = args->start_time;
|
t0 = args->start_time;
|
||||||
work.tstart = args->start_time;
|
work.tstart = args->start_time;
|
||||||
|
|
||||||
if(work.gcdata == nil) {
|
|
||||||
work.gcdata = unrollglobgcprog(gcdata, edata - data);
|
|
||||||
work.gcbss = unrollglobgcprog(gcbss, ebss - bss);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(work.markfor == nil)
|
|
||||||
work.markfor = runtime·parforalloc(MaxGcproc);
|
|
||||||
|
|
||||||
t1 = 0;
|
t1 = 0;
|
||||||
if(runtime·debug.gctrace)
|
if(runtime·debug.gctrace)
|
||||||
t1 = runtime·nanotime();
|
t1 = runtime·nanotime();
|
||||||
@ -1598,8 +1593,6 @@ runtime·setgcpercent(int32 in) {
|
|||||||
int32 out;
|
int32 out;
|
||||||
|
|
||||||
runtime·lock(&runtime·mheap.lock);
|
runtime·lock(&runtime·mheap.lock);
|
||||||
if(runtime·gcpercent == GcpercentUnknown)
|
|
||||||
runtime·gcpercent = runtime·readgogc();
|
|
||||||
out = runtime·gcpercent;
|
out = runtime·gcpercent;
|
||||||
if(in < 0)
|
if(in < 0)
|
||||||
in = -1;
|
in = -1;
|
||||||
@ -2027,7 +2020,7 @@ runtime·getgcmask(byte *p, Type *t, byte **mask, uintptr *len)
|
|||||||
*mask = runtime·mallocgc(*len, nil, 0);
|
*mask = runtime·mallocgc(*len, nil, 0);
|
||||||
for(i = 0; i < n; i += PtrSize) {
|
for(i = 0; i < n; i += PtrSize) {
|
||||||
off = (p+i-data)/PtrSize;
|
off = (p+i-data)/PtrSize;
|
||||||
bits = (work.gcdata[off/PointersPerByte] >> ((off%PointersPerByte)*BitsPerPointer))&BitsMask;
|
bits = (runtime·gcdatamask[off/PointersPerByte] >> ((off%PointersPerByte)*BitsPerPointer))&BitsMask;
|
||||||
(*mask)[i/PtrSize] = bits;
|
(*mask)[i/PtrSize] = bits;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -2039,7 +2032,7 @@ runtime·getgcmask(byte *p, Type *t, byte **mask, uintptr *len)
|
|||||||
*mask = runtime·mallocgc(*len, nil, 0);
|
*mask = runtime·mallocgc(*len, nil, 0);
|
||||||
for(i = 0; i < n; i += PtrSize) {
|
for(i = 0; i < n; i += PtrSize) {
|
||||||
off = (p+i-bss)/PtrSize;
|
off = (p+i-bss)/PtrSize;
|
||||||
bits = (work.gcbss[off/PointersPerByte] >> ((off%PointersPerByte)*BitsPerPointer))&BitsMask;
|
bits = (runtime·gcbssmask[off/PointersPerByte] >> ((off%PointersPerByte)*BitsPerPointer))&BitsMask;
|
||||||
(*mask)[i/PtrSize] = bits;
|
(*mask)[i/PtrSize] = bits;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -158,6 +158,7 @@ runtime·schedinit(void)
|
|||||||
runtime·symtabinit();
|
runtime·symtabinit();
|
||||||
runtime·stackinit();
|
runtime·stackinit();
|
||||||
runtime·mallocinit();
|
runtime·mallocinit();
|
||||||
|
runtime·gcinit();
|
||||||
runtime·chaninit();
|
runtime·chaninit();
|
||||||
mcommoninit(g->m);
|
mcommoninit(g->m);
|
||||||
|
|
||||||
|
@ -779,6 +779,8 @@ extern uint32 runtime·cpuid_ecx;
|
|||||||
extern uint32 runtime·cpuid_edx;
|
extern uint32 runtime·cpuid_edx;
|
||||||
extern DebugVars runtime·debug;
|
extern DebugVars runtime·debug;
|
||||||
extern uintptr runtime·maxstacksize;
|
extern uintptr runtime·maxstacksize;
|
||||||
|
extern byte* runtime·gcdatamask;
|
||||||
|
extern byte* runtime·gcbssmask;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* common functions and data
|
* common functions and data
|
||||||
@ -880,6 +882,7 @@ void runtime·shrinkstack(G*);
|
|||||||
MCache* runtime·allocmcache(void);
|
MCache* runtime·allocmcache(void);
|
||||||
void runtime·freemcache(MCache*);
|
void runtime·freemcache(MCache*);
|
||||||
void runtime·mallocinit(void);
|
void runtime·mallocinit(void);
|
||||||
|
void runtime·gcinit(void);
|
||||||
void runtime·chaninit(void);
|
void runtime·chaninit(void);
|
||||||
void* runtime·mallocgc(uintptr size, Type* typ, uint32 flag);
|
void* runtime·mallocgc(uintptr size, Type* typ, uint32 flag);
|
||||||
void runtime·runpanic(Panic*);
|
void runtime·runpanic(Panic*);
|
||||||
|
Loading…
Reference in New Issue
Block a user