diff options
| author | Dmitriy Vyukov <dvyukov@google.com> | 2014-08-19 15:59:42 +0400 |
|---|---|---|
| committer | Dmitriy Vyukov <dvyukov@google.com> | 2014-08-19 15:59:42 +0400 |
| commit | fb44fb6cb7fdadced51db03403b9f5d93fefa5a5 (patch) | |
| tree | dba74784865dd0d6a7544a67f5832a022e4c1d5e /src/pkg/runtime/malloc.c | |
| parent | 9198ed4bd6ec7b7dd37aa2797e96f15ddbb1e6cd (diff) | |
| download | go-fb44fb6cb7fdadced51db03403b9f5d93fefa5a5.tar.xz | |
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
Diffstat (limited to 'src/pkg/runtime/malloc.c')
| -rw-r--r-- | src/pkg/runtime/malloc.c | 9 |
1 files changed, 9 insertions, 0 deletions
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* |
