src/gc/dod.c - Dead object destruction of the various headers


This file implements dead object destruction. This is documented in PDD 9 with supplementary notes in docs/dev/dod.pod.

It's possible to turn on/off the checking of the system stack and processor registers. The actual checking is implemented in src/cpu_dep.c.

There's also a verbose mode for garbage collection.


static void mark_special(PARROT_INTERP, NOTNULL(PMC *obj))

Mark a special PMC. If it has a PMC_EXT structure, append or prepend the next_for_GC pointer; otherwise, do the custom mark directly.

This should really be inline, so if inline isn't available, it would be better if it were a macro.

PARROT_API void pobject_lives(PARROT_INTERP, NOTNULL(PObj *obj))

RT#48260: Not yet documented!!!

int Parrot_dod_trace_root(PARROT_INTERP, int trace_stack)

Trace the root set. Returns 0 if it's a lazy DOD run and all objects that need timely destruction were found.

trace_stack can have these values:

 0 ... trace normal roots, no system areas
 1 ... trace whole root set
 2 ... trace system areas only
static int trace_active_PMCs(PARROT_INTERP, int trace_stack)

Do a full trace run and mark all the PMCs as active if they are. Returns whether the run completed, that is, whether it's safe to proceed with GC.

int Parrot_dod_trace_children(PARROT_INTERP, size_t how_many)

Returns whether the tracing process completed.

void Parrot_dod_trace_pmc_data(PARROT_INTERP, NOTNULL(PMC *const p))

RT#48260: Not yet documented!!!

void clear_cow(PARROT_INTERP, NOTNULL(Small_Object_Pool *pool), int cleanup)

Clear the COW ref count.

void used_cow(PARROT_INTERP, NOTNULL(Small_Object_Pool *pool), int cleanup)

Find other users of COW's bufstart.

void Parrot_dod_sweep(PARROT_INTERP, NOTNULL(Small_Object_Pool *pool))

Put any buffers/PMCs that are now unused onto the pool's free list. If GC_IS_MALLOC, bufstart gets freed too, if possible. Avoid buffers that are immune from collection (i.e. constant).

void Parrot_dod_free_pmc(PARROT_INTERP, NOTNULL(Small_Object_Pool *pool), NOTNULL(PObj *p))

RT#48260: Not yet documented!!!

void Parrot_free_pmc_ext(PARROT_INTERP, NOTNULL(PMC *p))

Frees the PMC_EXT structure attached to a PMC, if it exists.

void Parrot_dod_free_sysmem(PARROT_INTERP, NOTNULL(Small_Object_Pool *pool), NOTNULL(PObj *b))

RT#48260: Not yet documented!!!

void Parrot_dod_free_buffer_malloc(PARROT_INTERP, NOTNULL(Small_Object_Pool *pool), NOTNULL(PObj *b))

RT#48260: Not yet documented!!!

void Parrot_dod_free_buffer(PARROT_INTERP, NOTNULL(Small_Object_Pool *pool), NOTNULL(PObj *b))

RT#48260: Not yet documented!!!

PARROT_CONST_FUNCTION static size_t find_common_mask(PARROT_INTERP, size_t val1, size_t val2)

Find a mask covering the longest common bit-prefix of val1 and val2.

void trace_mem_block(PARROT_INTERP, size_t lo_var_ptr, size_t hi_var_ptr)

Traces the memory block between lo_var_ptr and hi_var_ptr.

static void clear_live_bits(NOTNULL(Small_Object_Pool *pool))

Run through all PMC arenas and clear live bits.

void Parrot_dod_clear_live_bits(PARROT_INTERP)

RT#48260: Not yet documented!!!

void Parrot_dod_profile_start(PARROT_INTERP)

Records the start time of a DOD run when profiling is enabled.

void Parrot_dod_profile_end(PARROT_INTERP, int what)

Records the end time of the DOD part what run when profiling is enabled. Also record start time of next part.

void Parrot_dod_ms_run_init(PARROT_INTERP)

Prepare for a mark & sweep DOD run.

static int sweep_cb(PARROT_INTERP, NOTNULL(Small_Object_Pool *pool), int flag, NOTNULL(void *arg))

RT#48260: Not yet documented!!!

void Parrot_dod_ms_run(PARROT_INTERP, int flags)

Run the stop-the-world mark & sweep collector.

void Parrot_do_dod_run(PARROT_INTERP, UINTVAL flags)

Call the configured garbage collector to reclaim unused headers.


include/parrot/dod.h, src/cpu_dep.c, docs/dev/ and docs/pdds/pdd09_gc.pod.


Initial version by Mike Lambert on 2002.05.27.