OLD | NEW |
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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 MSpan* MHeap_LookupMaybe(MHeap *h, PageID p); | 311 MSpan* MHeap_LookupMaybe(MHeap *h, PageID p); |
312 | 312 |
313 void* mallocgc(uintptr size, uint32 flag, int32 dogc); | 313 void* mallocgc(uintptr size, uint32 flag, int32 dogc); |
314 int32 mlookup(void *v, byte **base, uintptr *size, uint32 **ref); | 314 int32 mlookup(void *v, byte **base, uintptr *size, uint32 **ref); |
315 void gc(int32 force); | 315 void gc(int32 force); |
316 | 316 |
317 void* SysAlloc(uintptr); | 317 void* SysAlloc(uintptr); |
318 void SysUnused(void*, uintptr); | 318 void SysUnused(void*, uintptr); |
319 void SysFree(void*, uintptr); | 319 void SysFree(void*, uintptr); |
320 | 320 |
321 void» addfinalizer(void*, void*); | 321 void*» getfinalizer(void*, bool, int32*); |
322 void*» getfinalizer(void*, bool); | |
323 | 322 |
324 enum | 323 enum |
325 { | 324 { |
326 RefcountOverhead = 4, // one uint32 per object | 325 RefcountOverhead = 4, // one uint32 per object |
327 | 326 |
328 RefFree = 0, // must be zero | 327 RefFree = 0, // must be zero |
329 RefStack, // stack segment - don't free and don't scan for
pointers | 328 RefStack, // stack segment - don't free and don't scan for
pointers |
330 RefNone, // no references | 329 RefNone, // no references |
331 RefSome, // some references | 330 RefSome, // some references |
332 RefFinalize, // ready to be finalized | 331 RefFinalize, // ready to be finalized |
333 RefNoPointers = 0x80000000U, // flag - no pointers here····· | 332 RefNoPointers = 0x80000000U, // flag - no pointers here····· |
334 }; | 333 }; |
OLD | NEW |