From fb44fb6cb7fdadced51db03403b9f5d93fefa5a5 Mon Sep 17 00:00:00 2001 From: Dmitriy Vyukov Date: Tue, 19 Aug 2014 15:59:42 +0400 Subject: 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 --- src/pkg/runtime/malloc.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/pkg/runtime/malloc.c') diff --git a/src/pkg/runtime/malloc.c b/src/pkg/runtime/malloc.c index f4143669e7..ca8ebf5dd6 100644 --- a/src/pkg/runtime/malloc.c +++ b/src/pkg/runtime/malloc.c @@ -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(¬ype_eface); + notype = notype_eface.type; } void* -- cgit v1.3