mirror of
https://github.com/golang/go
synced 2024-10-02 16:28:34 -06:00
runtime: remove dead code
Remove dead code related to allocation of type metadata with SysAlloc. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/12311045
This commit is contained in:
parent
77f21eea59
commit
0a904a3f2e
@ -116,7 +116,7 @@ runtime·mallocgc(uintptr size, uintptr typ, uint32 flag)
|
|||||||
|
|
||||||
m->mallocing = 0;
|
m->mallocing = 0;
|
||||||
if(UseSpanType && !(flag & FlagNoPointers) && typ != 0 && m->settype_bufsize == nelem(m->settype_buf))
|
if(UseSpanType && !(flag & FlagNoPointers) && typ != 0 && m->settype_bufsize == nelem(m->settype_buf))
|
||||||
runtime·settype_flush(m, false);
|
runtime·settype_flush(m);
|
||||||
m->locks--;
|
m->locks--;
|
||||||
if(m->locks == 0 && g->preempt) // restore the preemption request in case we've cleared it in newstack
|
if(m->locks == 0 && g->preempt) // restore the preemption request in case we've cleared it in newstack
|
||||||
g->stackguard0 = StackPreempt;
|
g->stackguard0 = StackPreempt;
|
||||||
@ -563,14 +563,13 @@ runtime·persistentalloc(uintptr size, uintptr align)
|
|||||||
static Lock settype_lock;
|
static Lock settype_lock;
|
||||||
|
|
||||||
void
|
void
|
||||||
runtime·settype_flush(M *mp, bool sysalloc)
|
runtime·settype_flush(M *mp)
|
||||||
{
|
{
|
||||||
uintptr *buf, *endbuf;
|
uintptr *buf, *endbuf;
|
||||||
uintptr size, ofs, j, t;
|
uintptr size, ofs, j, t;
|
||||||
uintptr ntypes, nbytes2, nbytes3;
|
uintptr ntypes, nbytes2, nbytes3;
|
||||||
uintptr *data2;
|
uintptr *data2;
|
||||||
byte *data3;
|
byte *data3;
|
||||||
bool sysalloc3;
|
|
||||||
void *v;
|
void *v;
|
||||||
uintptr typ, p;
|
uintptr typ, p;
|
||||||
MSpan *s;
|
MSpan *s;
|
||||||
@ -605,20 +604,9 @@ runtime·settype_flush(M *mp, bool sysalloc)
|
|||||||
case MTypes_Empty:
|
case MTypes_Empty:
|
||||||
ntypes = (s->npages << PageShift) / size;
|
ntypes = (s->npages << PageShift) / size;
|
||||||
nbytes3 = 8*sizeof(uintptr) + 1*ntypes;
|
nbytes3 = 8*sizeof(uintptr) + 1*ntypes;
|
||||||
|
data3 = runtime·mallocgc(nbytes3, 0, FlagNoProfiling|FlagNoPointers|FlagNoInvokeGC);
|
||||||
if(!sysalloc) {
|
|
||||||
data3 = runtime·mallocgc(nbytes3, 0, FlagNoProfiling|FlagNoPointers|FlagNoInvokeGC);
|
|
||||||
} else {
|
|
||||||
data3 = runtime·SysAlloc(nbytes3);
|
|
||||||
if(data3 == nil)
|
|
||||||
runtime·throw("runtime: cannot allocate memory");
|
|
||||||
if(0) runtime·printf("settype(0->3): SysAlloc(%x) --> %p\n", (uint32)nbytes3, data3);
|
|
||||||
}
|
|
||||||
|
|
||||||
s->types.compression = MTypes_Bytes;
|
s->types.compression = MTypes_Bytes;
|
||||||
s->types.sysalloc = sysalloc;
|
|
||||||
s->types.data = (uintptr)data3;
|
s->types.data = (uintptr)data3;
|
||||||
|
|
||||||
((uintptr*)data3)[1] = typ;
|
((uintptr*)data3)[1] = typ;
|
||||||
data3[8*sizeof(uintptr) + ofs] = 1;
|
data3[8*sizeof(uintptr) + ofs] = 1;
|
||||||
break;
|
break;
|
||||||
@ -643,20 +631,8 @@ runtime·settype_flush(M *mp, bool sysalloc)
|
|||||||
} else {
|
} else {
|
||||||
ntypes = (s->npages << PageShift) / size;
|
ntypes = (s->npages << PageShift) / size;
|
||||||
nbytes2 = ntypes * sizeof(uintptr);
|
nbytes2 = ntypes * sizeof(uintptr);
|
||||||
|
data2 = runtime·mallocgc(nbytes2, 0, FlagNoProfiling|FlagNoPointers|FlagNoInvokeGC);
|
||||||
if(!sysalloc) {
|
|
||||||
data2 = runtime·mallocgc(nbytes2, 0, FlagNoProfiling|FlagNoPointers|FlagNoInvokeGC);
|
|
||||||
} else {
|
|
||||||
data2 = runtime·SysAlloc(nbytes2);
|
|
||||||
if(data2 == nil)
|
|
||||||
runtime·throw("runtime: cannot allocate memory");
|
|
||||||
if(0) runtime·printf("settype.(3->2): SysAlloc(%x) --> %p\n", (uint32)nbytes2, data2);
|
|
||||||
}
|
|
||||||
|
|
||||||
sysalloc3 = s->types.sysalloc;
|
|
||||||
|
|
||||||
s->types.compression = MTypes_Words;
|
s->types.compression = MTypes_Words;
|
||||||
s->types.sysalloc = sysalloc;
|
|
||||||
s->types.data = (uintptr)data2;
|
s->types.data = (uintptr)data2;
|
||||||
|
|
||||||
// Move the contents of data3 to data2. Then deallocate data3.
|
// Move the contents of data3 to data2. Then deallocate data3.
|
||||||
@ -665,12 +641,6 @@ runtime·settype_flush(M *mp, bool sysalloc)
|
|||||||
t = ((uintptr*)data3)[t];
|
t = ((uintptr*)data3)[t];
|
||||||
data2[j] = t;
|
data2[j] = t;
|
||||||
}
|
}
|
||||||
if(sysalloc3) {
|
|
||||||
nbytes3 = 8*sizeof(uintptr) + 1*ntypes;
|
|
||||||
if(0) runtime·printf("settype.(3->2): SysFree(%p,%x)\n", data3, (uint32)nbytes3);
|
|
||||||
runtime·SysFree(data3, nbytes3);
|
|
||||||
}
|
|
||||||
|
|
||||||
data2[ofs] = typ;
|
data2[ofs] = typ;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -681,33 +651,6 @@ runtime·settype_flush(M *mp, bool sysalloc)
|
|||||||
mp->settype_bufsize = 0;
|
mp->settype_bufsize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
runtime·settype_sysfree(MSpan *s)
|
|
||||||
{
|
|
||||||
uintptr ntypes, nbytes;
|
|
||||||
|
|
||||||
if(!s->types.sysalloc)
|
|
||||||
return;
|
|
||||||
|
|
||||||
nbytes = (uintptr)-1;
|
|
||||||
|
|
||||||
switch (s->types.compression) {
|
|
||||||
case MTypes_Words:
|
|
||||||
ntypes = (s->npages << PageShift) / s->elemsize;
|
|
||||||
nbytes = ntypes * sizeof(uintptr);
|
|
||||||
break;
|
|
||||||
case MTypes_Bytes:
|
|
||||||
ntypes = (s->npages << PageShift) / s->elemsize;
|
|
||||||
nbytes = 8*sizeof(uintptr) + 1*ntypes;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(nbytes != (uintptr)-1) {
|
|
||||||
if(0) runtime·printf("settype: SysFree(%p,%x)\n", (void*)s->types.data, (uint32)nbytes);
|
|
||||||
runtime·SysFree((void*)s->types.data, nbytes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uintptr
|
uintptr
|
||||||
runtime·gettype(void *v)
|
runtime·gettype(void *v)
|
||||||
{
|
{
|
||||||
|
@ -334,7 +334,6 @@ enum
|
|||||||
struct MTypes
|
struct MTypes
|
||||||
{
|
{
|
||||||
byte compression; // one of MTypes_*
|
byte compression; // one of MTypes_*
|
||||||
bool sysalloc; // whether (void*)data is from runtime·SysAlloc
|
|
||||||
uintptr data;
|
uintptr data;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -459,7 +458,7 @@ void runtime·purgecachedstats(MCache*);
|
|||||||
void* runtime·cnew(Type*);
|
void* runtime·cnew(Type*);
|
||||||
void* runtime·cnewarray(Type*, intgo);
|
void* runtime·cnewarray(Type*, intgo);
|
||||||
|
|
||||||
void runtime·settype_flush(M*, bool);
|
void runtime·settype_flush(M*);
|
||||||
void runtime·settype_sysfree(MSpan*);
|
void runtime·settype_sysfree(MSpan*);
|
||||||
uintptr runtime·gettype(void*);
|
uintptr runtime·gettype(void*);
|
||||||
|
|
||||||
|
@ -2084,7 +2084,7 @@ gc(struct gc_args *args)
|
|||||||
runtime·memclr((byte*)&gcstats, sizeof(gcstats));
|
runtime·memclr((byte*)&gcstats, sizeof(gcstats));
|
||||||
|
|
||||||
for(mp=runtime·allm; mp; mp=mp->alllink)
|
for(mp=runtime·allm; mp; mp=mp->alllink)
|
||||||
runtime·settype_flush(mp, false);
|
runtime·settype_flush(mp);
|
||||||
|
|
||||||
heap0 = 0;
|
heap0 = 0;
|
||||||
obj0 = 0;
|
obj0 = 0;
|
||||||
|
@ -330,8 +330,6 @@ MHeap_FreeLocked(MHeap *h, MSpan *s)
|
|||||||
MSpan *t;
|
MSpan *t;
|
||||||
PageID p;
|
PageID p;
|
||||||
|
|
||||||
if(s->types.sysalloc)
|
|
||||||
runtime·settype_sysfree(s);
|
|
||||||
s->types.compression = MTypes_Empty;
|
s->types.compression = MTypes_Empty;
|
||||||
|
|
||||||
if(s->state != MSpanInUse || s->ref != 0) {
|
if(s->state != MSpanInUse || s->ref != 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user