LEFT | RIGHT |
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 // Memory allocator, based on tcmalloc. | 5 // Memory allocator, based on tcmalloc. |
6 // http://goog-perftools.sourceforge.net/doc/tcmalloc.html | 6 // http://goog-perftools.sourceforge.net/doc/tcmalloc.html |
7 | 7 |
8 // The main allocator works in runs of pages. | 8 // The main allocator works in runs of pages. |
9 // Small allocation sizes (up to and including 32 kB) are | 9 // Small allocation sizes (up to and including 32 kB) are |
10 // rounded to one of about 100 size classes, each of which | 10 // rounded to one of about 100 size classes, each of which |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 bool debuggc; | 229 bool debuggc; |
230 | 230 |
231 // Statistics about allocation size classes. | 231 // Statistics about allocation size classes. |
232 struct { | 232 struct { |
233 uint32 size; | 233 uint32 size; |
234 uint64 nmalloc; | 234 uint64 nmalloc; |
235 uint64 nfree; | 235 uint64 nfree; |
236 } by_size[NumSizeClasses]; | 236 } by_size[NumSizeClasses]; |
237 }; | 237 }; |
238 | 238 |
239 #define mstats runtime·MemStats»/* name shared with Go */ | 239 #define mstats runtime·memStats»/* name shared with Go */ |
240 extern MStats mstats; | 240 extern MStats mstats; |
241 | 241 |
242 | 242 |
243 // Size classes. Computed and initialized by InitSizes. | 243 // Size classes. Computed and initialized by InitSizes. |
244 // | 244 // |
245 // SizeToClass(0 <= n <= MaxSmallSize) returns the size class, | 245 // SizeToClass(0 <= n <= MaxSmallSize) returns the size class, |
246 // 1 <= sizeclass < NumSizeClasses, for n. | 246 // 1 <= sizeclass < NumSizeClasses, for n. |
247 // Size class 0 is reserved to mean "not small". | 247 // Size class 0 is reserved to mean "not small". |
248 // | 248 // |
249 // class_to_size[i] = largest size in class i | 249 // class_to_size[i] = largest size in class i |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 extern MHeap runtime·mheap; | 378 extern MHeap runtime·mheap; |
379 | 379 |
380 void runtime·MHeap_Init(MHeap *h, void *(*allocator)(uintptr)); | 380 void runtime·MHeap_Init(MHeap *h, void *(*allocator)(uintptr)); |
381 MSpan* runtime·MHeap_Alloc(MHeap *h, uintptr npage, int32 sizeclass, int32 acct
); | 381 MSpan* runtime·MHeap_Alloc(MHeap *h, uintptr npage, int32 sizeclass, int32 acct
); |
382 void runtime·MHeap_Free(MHeap *h, MSpan *s, int32 acct); | 382 void runtime·MHeap_Free(MHeap *h, MSpan *s, int32 acct); |
383 MSpan* runtime·MHeap_Lookup(MHeap *h, void *v); | 383 MSpan* runtime·MHeap_Lookup(MHeap *h, void *v); |
384 MSpan* runtime·MHeap_LookupMaybe(MHeap *h, void *v); | 384 MSpan* runtime·MHeap_LookupMaybe(MHeap *h, void *v); |
385 void runtime·MGetSizeClassInfo(int32 sizeclass, uintptr *size, int32 *npages,
int32 *nobj); | 385 void runtime·MGetSizeClassInfo(int32 sizeclass, uintptr *size, int32 *npages,
int32 *nobj); |
386 void* runtime·MHeap_SysAlloc(MHeap *h, uintptr n); | 386 void* runtime·MHeap_SysAlloc(MHeap *h, uintptr n); |
387 void runtime·MHeap_MapBits(MHeap *h); | 387 void runtime·MHeap_MapBits(MHeap *h); |
388 void» runtime·MHeap_Scavenger(); | 388 void» runtime·MHeap_Scavenger(void); |
389 | 389 |
390 void* runtime·mallocgc(uintptr size, uint32 flag, int32 dogc, int32 zeroed); | 390 void* runtime·mallocgc(uintptr size, uint32 flag, int32 dogc, int32 zeroed); |
391 int32 runtime·mlookup(void *v, byte **base, uintptr *size, MSpan **s); | 391 int32 runtime·mlookup(void *v, byte **base, uintptr *size, MSpan **s); |
392 void runtime·gc(int32 force); | 392 void runtime·gc(int32 force); |
393 void runtime·markallocated(void *v, uintptr n, bool noptr); | 393 void runtime·markallocated(void *v, uintptr n, bool noptr); |
394 void runtime·checkallocated(void *v, uintptr n); | 394 void runtime·checkallocated(void *v, uintptr n); |
395 void runtime·markfreed(void *v, uintptr n); | 395 void runtime·markfreed(void *v, uintptr n); |
396 void runtime·checkfreed(void *v, uintptr n); | 396 void runtime·checkfreed(void *v, uintptr n); |
397 int32 runtime·checking; | 397 int32 runtime·checking; |
398 void runtime·markspan(void *v, uintptr size, uintptr n, bool leftover); | 398 void runtime·markspan(void *v, uintptr size, uintptr n, bool leftover); |
(...skipping 19 matching lines...) Expand all Loading... |
418 // Must match definition in extern.go. | 418 // Must match definition in extern.go. |
419 enum { | 419 enum { |
420 MProf_None = 0, | 420 MProf_None = 0, |
421 MProf_Sample = 1, | 421 MProf_Sample = 1, |
422 MProf_All = 2, | 422 MProf_All = 2, |
423 }; | 423 }; |
424 extern int32 runtime·malloc_profile; | 424 extern int32 runtime·malloc_profile; |
425 | 425 |
426 bool runtime·getfinalizer(void *p, bool del, void (**fn)(void*), int32 *nret)
; | 426 bool runtime·getfinalizer(void *p, bool del, void (**fn)(void*), int32 *nret)
; |
427 void runtime·walkfintab(void (*fn)(void*)); | 427 void runtime·walkfintab(void (*fn)(void*)); |
LEFT | RIGHT |