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 // Central free lists. | 5 // Central free lists. |
6 // | 6 // |
7 // See malloc.h for an overview. | 7 // See malloc.h for an overview. |
8 // | 8 // |
9 // The MCentral doesn't actually contain the list of free objects; the MSpan doe
s. | 9 // The MCentral doesn't actually contain the list of free objects; the MSpan doe
s. |
10 // Each MCentral is two lists of MSpans: those with free objects (c->nonempty) | 10 // Each MCentral is two lists of MSpans: those with free objects (c->nonempty) |
11 // and those that are completely allocated (c->empty). | 11 // and those that are completely allocated (c->empty). |
12 // | 12 // |
13 // TODO(rsc): tcmalloc uses a "transfer cache" to split the list | 13 // TODO(rsc): tcmalloc uses a "transfer cache" to split the list |
14 // into sections of class_to_transfercount[sizeclass] objects | 14 // into sections of class_to_transfercount[sizeclass] objects |
15 // so that it is faster to move those lists between MCaches and MCentrals. | 15 // so that it is faster to move those lists between MCaches and MCentrals. |
16 | 16 |
17 #include "runtime.h" | 17 #include "runtime.h" |
18 #include "arch.h" | 18 #include "arch_GOARCH.h" |
19 #include "malloc.h" | 19 #include "malloc.h" |
20 | 20 |
21 static bool MCentral_Grow(MCentral *c); | 21 static bool MCentral_Grow(MCentral *c); |
22 static void* MCentral_Alloc(MCentral *c); | 22 static void* MCentral_Alloc(MCentral *c); |
23 static void MCentral_Free(MCentral *c, void *v); | 23 static void MCentral_Free(MCentral *c, void *v); |
24 | 24 |
25 // Initialize a single central free list. | 25 // Initialize a single central free list. |
26 void | 26 void |
27 runtime·MCentral_Init(MCentral *c, int32 sizeclass) | 27 runtime·MCentral_Init(MCentral *c, int32 sizeclass) |
28 { | 28 { |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 p += size; | 192 p += size; |
193 } | 193 } |
194 *tailp = nil; | 194 *tailp = nil; |
195 runtime·markspan((byte*)(s->start<<PageShift), size, n, size*n < (s->npa
ges<<PageShift)); | 195 runtime·markspan((byte*)(s->start<<PageShift), size, n, size*n < (s->npa
ges<<PageShift)); |
196 | 196 |
197 runtime·lock(c); | 197 runtime·lock(c); |
198 c->nfree += n; | 198 c->nfree += n; |
199 runtime·MSpanList_Insert(&c->nonempty, s); | 199 runtime·MSpanList_Insert(&c->nonempty, s); |
200 return true; | 200 return true; |
201 } | 201 } |
LEFT | RIGHT |