LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2009 The Go Authors. All rights reserved. | 1 // Copyright 2009 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // Per-P malloc cache for small objects. | 5 // Per-P malloc cache for small objects. |
6 // | 6 // |
7 // See malloc.h for an overview. | 7 // See malloc.h for an overview. |
8 | 8 |
9 #include "runtime.h" | 9 #include "runtime.h" |
10 #include "arch_GOARCH.h" | 10 #include "arch_GOARCH.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 void | 90 void |
91 runtime·MCache_Free(MCache *c, MLink *p, int32 sizeclass, uintptr size) | 91 runtime·MCache_Free(MCache *c, MLink *p, int32 sizeclass, uintptr size) |
92 { | 92 { |
93 MCacheList *l; | 93 MCacheList *l; |
94 | 94 |
95 // Put on free list. | 95 // Put on free list. |
96 l = &c->free[sizeclass]; | 96 l = &c->free[sizeclass]; |
97 p->next = l->list; | 97 p->next = l->list; |
98 l->list = p; | 98 l->list = p; |
99 l->nlist++; | 99 l->nlist++; |
100 c->local_cachealloc -= size; | |
101 | 100 |
102 // We transfer a span at a time from MCentral to MCache, | 101 // We transfer a span at a time from MCentral to MCache, |
103 // so we'll do the same in the other direction. | 102 // so we'll do the same in the other direction. |
104 if(l->nlist >= (runtime·class_to_allocnpages[sizeclass]<<PageShift)/size
) { | 103 if(l->nlist >= (runtime·class_to_allocnpages[sizeclass]<<PageShift)/size
) { |
105 runtime·MCentral_FreeList(&runtime·mheap.central[sizeclass], l->
list); | 104 runtime·MCentral_FreeList(&runtime·mheap.central[sizeclass], l->
list); |
106 l->list = nil; | 105 l->list = nil; |
107 l->nlist = 0; | 106 l->nlist = 0; |
108 } | 107 } |
109 } | 108 } |
110 | 109 |
(...skipping 11 matching lines...) Expand all Loading... |
122 c->alloc[i] = &emptymspan; | 121 c->alloc[i] = &emptymspan; |
123 } | 122 } |
124 l = &c->free[i]; | 123 l = &c->free[i]; |
125 if(l->nlist > 0) { | 124 if(l->nlist > 0) { |
126 runtime·MCentral_FreeList(&runtime·mheap.central[i], l->
list); | 125 runtime·MCentral_FreeList(&runtime·mheap.central[i], l->
list); |
127 l->list = nil; | 126 l->list = nil; |
128 l->nlist = 0; | 127 l->nlist = 0; |
129 } | 128 } |
130 } | 129 } |
131 } | 130 } |
LEFT | RIGHT |