runtime: always pass type to mallocgc when allocating scannable memory

We allocate scannable memory w/o type only in few places in runtime.
All these cases are not-performance critical (e.g. G or finq args buffer),
and in long term they all need to go away.
It's not worth it to have special code for this case in mallocgc.
So use special fake "notype" type for such allocations.

LGTM=khr
R=golang-codereviews, khr
CC=golang-codereviews, rlh, rsc
https://golang.org/cl/127450044
This commit is contained in:
Dmitriy Vyukov 2014-08-19 15:59:42 +04:00
parent 9198ed4bd6
commit fb44fb6cb7
3 changed files with 57 additions and 49 deletions

View file

@ -21,7 +21,10 @@ MHeap runtime·mheap;
#pragma dataflag NOPTR
MStats runtime·memstats;
static Type* notype;
void runtime·cmallocgc(uintptr size, Type *typ, uint32 flag, void **ret);
void runtime·gc_notype_ptr(Eface*);
void*
runtime·mallocgc(uintptr size, Type *typ, uint32 flag)
@ -31,6 +34,8 @@ runtime·mallocgc(uintptr size, Type *typ, uint32 flag)
// Call into the Go version of mallocgc.
// TODO: maybe someday we can get rid of this. It is
// probably the only location where we run Go code on the M stack.
if((flag&FlagNoScan) == 0 && typ == nil)
typ = notype;
runtime·cmallocgc(size, typ, flag, &ret);
return ret;
}
@ -124,6 +129,7 @@ runtime·mallocinit(void)
uintptr limit;
uint64 i;
bool reserved;
Eface notype_eface;
p = nil;
p_size = 0;
@ -251,6 +257,9 @@ runtime·mallocinit(void)
// Initialize the rest of the allocator.
runtime·MHeap_Init(&runtime·mheap);
g->m->mcache = runtime·allocmcache();
runtime·gc_notype_ptr(&notype_eface);
notype = notype_eface.type;
}
void*