summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/malloc.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/runtime/malloc.h')
-rw-r--r--src/pkg/runtime/malloc.h88
1 files changed, 43 insertions, 45 deletions
diff --git a/src/pkg/runtime/malloc.h b/src/pkg/runtime/malloc.h
index 473e8a836..0cee6c0dd 100644
--- a/src/pkg/runtime/malloc.h
+++ b/src/pkg/runtime/malloc.h
@@ -135,10 +135,10 @@ struct MLink
// an out-of-memory error has been detected midway through
// an allocation. It is okay if SysFree is a no-op.
-void* SysAlloc(uintptr nbytes);
-void SysFree(void *v, uintptr nbytes);
-void SysUnused(void *v, uintptr nbytes);
-
+void* runtime·SysAlloc(uintptr nbytes);
+void runtime·SysFree(void *v, uintptr nbytes);
+void runtime·SysUnused(void *v, uintptr nbytes);
+void runtime·SysMemInit(void);
// FixAlloc is a simple free-list allocator for fixed size objects.
// Malloc uses a FixAlloc wrapped around SysAlloc to manages its
@@ -161,9 +161,9 @@ struct FixAlloc
uintptr sys; // bytes obtained from system
};
-void FixAlloc_Init(FixAlloc *f, uintptr size, void *(*alloc)(uintptr), void (*first)(void*, byte*), void *arg);
-void* FixAlloc_Alloc(FixAlloc *f);
-void FixAlloc_Free(FixAlloc *f, void *p);
+void runtime·FixAlloc_Init(FixAlloc *f, uintptr size, void *(*alloc)(uintptr), void (*first)(void*, byte*), void *arg);
+void* runtime·FixAlloc_Alloc(FixAlloc *f);
+void runtime·FixAlloc_Free(FixAlloc *f, void *p);
// Statistics.
@@ -183,6 +183,7 @@ struct MStats
uint64 heap_sys; // bytes obtained from system
uint64 heap_idle; // bytes in idle spans
uint64 heap_inuse; // bytes in non-idle spans
+ uint64 heap_objects; // total number of allocated objects
// Statistics about allocation of low-level fixed-size structures.
// Protected by FixAlloc locks.
@@ -212,7 +213,7 @@ struct MStats
} by_size[NumSizeClasses];
};
-#define mstats ·MemStats /* name shared with Go */
+#define mstats runtime·MemStats /* name shared with Go */
extern MStats mstats;
@@ -229,11 +230,11 @@ extern MStats mstats;
// taking a bunch of objects out of the central lists
// and putting them in the thread free list.
-int32 SizeToClass(int32);
-extern int32 class_to_size[NumSizeClasses];
-extern int32 class_to_allocnpages[NumSizeClasses];
-extern int32 class_to_transfercount[NumSizeClasses];
-extern void InitSizes(void);
+int32 runtime·SizeToClass(int32);
+extern int32 runtime·class_to_size[NumSizeClasses];
+extern int32 runtime·class_to_allocnpages[NumSizeClasses];
+extern int32 runtime·class_to_transfercount[NumSizeClasses];
+extern void runtime·InitSizes(void);
// Per-thread (in Go, per-M) cache for small objects.
@@ -251,12 +252,13 @@ struct MCache
MCacheList list[NumSizeClasses];
uint64 size;
int64 local_alloc; // bytes allocated (or freed) since last lock of heap
+ int64 local_objects; // objects allocated (or freed) since last lock of heap
int32 next_sample; // trigger heap sample after allocating this many bytes
};
-void* MCache_Alloc(MCache *c, int32 sizeclass, uintptr size, int32 zeroed);
-void MCache_Free(MCache *c, void *p, int32 sizeclass, uintptr size);
-void MCache_ReleaseAll(MCache *c);
+void* runtime·MCache_Alloc(MCache *c, int32 sizeclass, uintptr size, int32 zeroed);
+void runtime·MCache_Free(MCache *c, void *p, int32 sizeclass, uintptr size);
+void runtime·MCache_ReleaseAll(MCache *c);
// An MSpan is a run of pages.
enum
@@ -283,15 +285,15 @@ struct MSpan
};
};
-void MSpan_Init(MSpan *span, PageID start, uintptr npages);
+void runtime·MSpan_Init(MSpan *span, PageID start, uintptr npages);
// Every MSpan is in one doubly-linked list,
// either one of the MHeap's free lists or one of the
// MCentral's span lists. We use empty MSpan structures as list heads.
-void MSpanList_Init(MSpan *list);
-bool MSpanList_IsEmpty(MSpan *list);
-void MSpanList_Insert(MSpan *list, MSpan *span);
-void MSpanList_Remove(MSpan *span); // from whatever list it is in
+void runtime·MSpanList_Init(MSpan *list);
+bool runtime·MSpanList_IsEmpty(MSpan *list);
+void runtime·MSpanList_Insert(MSpan *list, MSpan *span);
+void runtime·MSpanList_Remove(MSpan *span); // from whatever list it is in
// Central list of free objects of a given size.
@@ -304,9 +306,9 @@ struct MCentral
int32 nfree;
};
-void MCentral_Init(MCentral *c, int32 sizeclass);
-int32 MCentral_AllocList(MCentral *c, int32 n, MLink **first);
-void MCentral_FreeList(MCentral *c, int32 n, MLink *first);
+void runtime·MCentral_Init(MCentral *c, int32 sizeclass);
+int32 runtime·MCentral_AllocList(MCentral *c, int32 n, MLink **first);
+void runtime·MCentral_FreeList(MCentral *c, int32 n, MLink *first);
// Main malloc heap.
// The heap itself is the "free[]" and "large" arrays,
@@ -325,10 +327,6 @@ struct MHeap
byte *min;
byte *max;
- // range of addresses we might see in a Native Client closure
- byte *closure_min;
- byte *closure_max;
-
// central free lists for small size classes.
// the union makes sure that the MCentrals are
// spaced 64 bytes apart, so that each MCentral.Lock
@@ -341,22 +339,22 @@ struct MHeap
FixAlloc spanalloc; // allocator for Span*
FixAlloc cachealloc; // allocator for MCache*
};
-extern MHeap mheap;
+extern MHeap runtime·mheap;
-void MHeap_Init(MHeap *h, void *(*allocator)(uintptr));
-MSpan* MHeap_Alloc(MHeap *h, uintptr npage, int32 sizeclass, int32 acct);
-void MHeap_Free(MHeap *h, MSpan *s, int32 acct);
-MSpan* MHeap_Lookup(MHeap *h, PageID p);
-MSpan* MHeap_LookupMaybe(MHeap *h, PageID p);
-void MGetSizeClassInfo(int32 sizeclass, int32 *size, int32 *npages, int32 *nobj);
+void runtime·MHeap_Init(MHeap *h, void *(*allocator)(uintptr));
+MSpan* runtime·MHeap_Alloc(MHeap *h, uintptr npage, int32 sizeclass, int32 acct);
+void runtime·MHeap_Free(MHeap *h, MSpan *s, int32 acct);
+MSpan* runtime·MHeap_Lookup(MHeap *h, PageID p);
+MSpan* runtime·MHeap_LookupMaybe(MHeap *h, PageID p);
+void runtime·MGetSizeClassInfo(int32 sizeclass, int32 *size, int32 *npages, int32 *nobj);
-void* mallocgc(uintptr size, uint32 flag, int32 dogc, int32 zeroed);
-int32 mlookup(void *v, byte **base, uintptr *size, MSpan **s, uint32 **ref);
-void gc(int32 force);
+void* runtime·mallocgc(uintptr size, uint32 flag, int32 dogc, int32 zeroed);
+int32 runtime·mlookup(void *v, byte **base, uintptr *size, MSpan **s, uint32 **ref);
+void runtime·gc(int32 force);
-void* SysAlloc(uintptr);
-void SysUnused(void*, uintptr);
-void SysFree(void*, uintptr);
+void* runtime·SysAlloc(uintptr);
+void runtime·SysUnused(void*, uintptr);
+void runtime·SysFree(void*, uintptr);
enum
{
@@ -373,8 +371,8 @@ enum
RefFlags = 0xFFFF0000U,
};
-void MProf_Malloc(void*, uintptr);
-void MProf_Free(void*, uintptr);
+void runtime·MProf_Malloc(void*, uintptr);
+void runtime·MProf_Free(void*, uintptr);
// Malloc profiling settings.
// Must match definition in extern.go.
@@ -383,7 +381,7 @@ enum {
MProf_Sample = 1,
MProf_All = 2,
};
-extern int32 malloc_profile;
+extern int32 runtime·malloc_profile;
typedef struct Finalizer Finalizer;
struct Finalizer
@@ -394,4 +392,4 @@ struct Finalizer
int32 nret;
};
-Finalizer* getfinalizer(void*, bool);
+Finalizer* runtime·getfinalizer(void*, bool);