rt.gc.cdgc.gc

This module contains the garbage collector implementation.

Members

Aliases

Bins
alias Bins = ubyte
Undocumented in source.
printf
alias printf = cstdio.printf
Undocumented in source.

Classes

GCLock
class GCLock
Undocumented in source.

Enums

B_16
anonymousenum B_16
Undocumented in source.
BlkAttr
enum BlkAttr
Undocumented in source.
PAGESIZE
anonymousenum PAGESIZE
Undocumented in source.

Functions

Invariant
bool Invariant()
Undocumented in source. Be warned that the author may not have intended to support it.
allocPage
int allocPage(Bins bin)

Allocate a page of bin's.

bigAlloc
void* bigAlloc(size_t npages, Pool* pool, size_t* pn, bool* collected)

Allocate a chunk of memory that is larger than a page. Return null if out of memory.

clrAttr
void clrAttr(Pool* pool, size_t bit_i, uint mask)
collect_in_progress
bool collect_in_progress()
Undocumented in source. Be warned that the author may not have intended to support it.
disable_fork
void disable_fork()
Undocumented in source. Be warned that the author may not have intended to support it.
early_collect
void early_collect()
Undocumented in source. Be warned that the author may not have intended to support it.
findBin
Bins findBin(size_t size)

Compute bin for size.

findPool
Pool* findPool(void* p)

Find Pool that pointer is in. Return null if not in a Pool. Assume pools is sorted.

fullcollect
size_t fullcollect(void* stackTop, bool early, bool force_block)
fullcollectshell
size_t fullcollectshell(bool early, bool force_block)

Return number of full pages free'd.

gc_addRange
void gc_addRange(void* p, size_t size)
Undocumented in source. Be warned that the author may not have intended to support it.
gc_addRoot
void gc_addRoot(void* p)
Undocumented in source. Be warned that the author may not have intended to support it.
gc_addrOf
void* gc_addrOf(void* p)
Undocumented in source. Be warned that the author may not have intended to support it.
gc_calloc
void* gc_calloc(size_t size, uint attrs, PointerMap ptrmap)
Undocumented in source. Be warned that the author may not have intended to support it.
gc_clrAttr
uint gc_clrAttr(void* p, uint attrs)
Undocumented in source. Be warned that the author may not have intended to support it.
gc_collect
void gc_collect()
Undocumented in source. Be warned that the author may not have intended to support it.
gc_disable
void gc_disable()
Undocumented in source. Be warned that the author may not have intended to support it.
gc_enable
void gc_enable()
Undocumented in source. Be warned that the author may not have intended to support it.
gc_extend
size_t gc_extend(void* p, size_t min_size, size_t max_size)
Undocumented in source. Be warned that the author may not have intended to support it.
gc_free
void gc_free(void* p)
Undocumented in source. Be warned that the author may not have intended to support it.
gc_getAttr
uint gc_getAttr(void* p)
Undocumented in source. Be warned that the author may not have intended to support it.
gc_getTermCleanupLevel
int gc_getTermCleanupLevel()

returns the cleanup level done by gc

gc_init
void gc_init()
Undocumented in source. Be warned that the author may not have intended to support it.
gc_malloc
void* gc_malloc(size_t size, uint attrs, PointerMap ptrmap)
Undocumented in source. Be warned that the author may not have intended to support it.
gc_minimize
void gc_minimize()
Undocumented in source. Be warned that the author may not have intended to support it.
gc_monitor
void gc_monitor(begin_del begin, end_del end)
Undocumented in source. Be warned that the author may not have intended to support it.
gc_query
BlkInfo gc_query(void* p)
Undocumented in source. Be warned that the author may not have intended to support it.
gc_realloc
void* gc_realloc(void* p, size_t size, uint attrs, PointerMap ptrmap)
Undocumented in source. Be warned that the author may not have intended to support it.
gc_removeRange
void gc_removeRange(void* p)
Undocumented in source. Be warned that the author may not have intended to support it.
gc_removeRoot
void gc_removeRoot(void* p)
Undocumented in source. Be warned that the author may not have intended to support it.
gc_reserve
size_t gc_reserve(size_t size)
Undocumented in source. Be warned that the author may not have intended to support it.
gc_setAttr
uint gc_setAttr(void* p, uint attrs)
Undocumented in source. Be warned that the author may not have intended to support it.
gc_setTermCleanupLevel
int gc_setTermCleanupLevel(int cLevel)

sets the cleanup level done by gc 0: none 1: fullCollect 2: fullCollect ignoring stack roots (might crash daemonThreads) result !=0 if the value was invalid

gc_sizeOf
size_t gc_sizeOf(void* p)
Undocumented in source. Be warned that the author may not have intended to support it.
gc_stats
GCStats gc_stats()
Undocumented in source. Be warned that the author may not have intended to support it.
gc_term
void gc_term()
Undocumented in source. Be warned that the author may not have intended to support it.
gc_weakpointerCreate
void* gc_weakpointerCreate(Object r)
Undocumented in source. Be warned that the author may not have intended to support it.
gc_weakpointerDestroy
void gc_weakpointerDestroy(void* wp)
Undocumented in source. Be warned that the author may not have intended to support it.
gc_weakpointerGet
Object gc_weakpointerGet(void* wp)
Undocumented in source. Be warned that the author may not have intended to support it.
getAttr
uint getAttr(Pool* pool, size_t bit_i)
getInfo
BlkInfo getInfo(void* p)

Determine the base address of the block containing p. If p is not a gc allocated pointer, return null.

has_pointermap
bool has_pointermap(uint attrs)
Undocumented in source. Be warned that the author may not have intended to support it.
initialize
void initialize()
Undocumented in source. Be warned that the author may not have intended to support it.
mark
void mark(void* stackTop)
mark_range
void mark_range(void* pbot, void* ptop, size_t* pm_bitmask)

Search a range of memory values and mark any pointers into the GC pool using type information (bitmask of pointer locations).

memset
void memset(void* dst, int c, size_t n)
Undocumented in source. Be warned that the author may not have intended to support it.
minimize
void minimize(bool full)

Minimizes physical memory usage by returning free pools to the OS.

newPool
Pool* newPool(size_t npages)

Allocate a new pool with at least npages in it. Sort it into pools. Return null if failed.

reserve
size_t reserve(size_t size)

Allocate a new pool of at least size bytes. Sort it into pools. Mark all memory in the pool as B_FREE. Return the actual number of bytes reserved or 0 on error.

sentinel_Invariant
void sentinel_Invariant(void* p)
Undocumented in source. Be warned that the author may not have intended to support it.
sentinel_add
void* sentinel_add(void* p)
Undocumented in source. Be warned that the author may not have intended to support it.
sentinel_init
void sentinel_init(void* p, size_t size)
Undocumented in source. Be warned that the author may not have intended to support it.
sentinel_post
ubyte* sentinel_post(void* p)
Undocumented in source. Be warned that the author may not have intended to support it.
sentinel_pre
size_t* sentinel_pre(void* p)
Undocumented in source. Be warned that the author may not have intended to support it.
sentinel_size
size_t* sentinel_size(void* p)
Undocumented in source. Be warned that the author may not have intended to support it.
sentinel_sub
void* sentinel_sub(void* p)
Undocumented in source. Be warned that the author may not have intended to support it.
setAttr
void setAttr(Pool* pool, size_t bit_i, uint mask)
sweep
size_t sweep()
weakpointerCreate
void* weakpointerCreate(Object r)

Create a weak pointer to the given object. Returns a pointer to an opaque struct allocated in C memory.

weakpointerDestroy
void weakpointerDestroy(void* p)

Destroy a weak pointer returned by weakpointerCreate(). If null is passed, nothing happens.

weakpointerGet
Object weakpointerGet(void* p)

Query a weak pointer and return either the object passed to weakpointerCreate, or null if it was free'd in the meantime. If null is passed, null is returned.

Structs

BlkInfo
struct BlkInfo
Undocumented in source.
GC
struct GC
Undocumented in source.
List
struct List
Undocumented in source.
Pool
struct Pool
Undocumented in source.
Range
struct Range
Undocumented in source.

Variables

SENTINEL_EXTRA
uint SENTINEL_EXTRA;
Undocumented in source.
SENTINEL_POST
ubyte SENTINEL_POST;
Undocumented in source.
SENTINEL_PRE
size_t SENTINEL_PRE;
Undocumented in source.
binsize
uint binsize;
Undocumented in source.
notbinsize
uint notbinsize;
Undocumented in source.

Meta

License

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, in both source and binary form, subject to the following restrictions:

o The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. o Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. o This notice may not be removed or altered from any source distribution.

Authors

Walter Bright, David Friedman, Sean Kelly