mirror of
https://github.com/ProgramSnail/Lama.git
synced 2025-12-06 23:08:46 +00:00
Added some details about GC algorithm with references to code fragments
This commit is contained in:
parent
f78d7280c1
commit
e3f28b94b1
1 changed files with 20 additions and 0 deletions
20
runtime/gc.h
20
runtime/gc.h
|
|
@ -1,3 +1,23 @@
|
|||
// ============================================================================
|
||||
// GC
|
||||
// ============================================================================
|
||||
// This is an implementation of a compactifying garbage collection algorithm.
|
||||
// GC algorithm itself consists of two major stages:
|
||||
// 1. Marking roots
|
||||
// 2. Compacting stage
|
||||
// Compacting is implemented in a very similar fashion to LISP2 algorithm,
|
||||
// which is well-known.
|
||||
// Most important pieces of code to discover to understand how everything works:
|
||||
// - void *gc_alloc (size_t): this function is basically called whenever we are
|
||||
// not able to allocate memory on the existing heap via simple bump allocator.
|
||||
// - mark_phase(): this function will tell you everything you need to know
|
||||
// about marking. I would also recommend to pay attention to the fact that
|
||||
// marking is implemented without usage of any additional memory. Already
|
||||
// allocated space is sufficient (for details see 'void mark (void *obj)').
|
||||
// - void compact_phase (size_t additional_size): the whole compaction phase
|
||||
// can be understood by looking at this piece of code plus couple of other
|
||||
// functions used in there. It is basically an implementation of LISP2.
|
||||
|
||||
#ifndef __LAMA_GC__
|
||||
#define __LAMA_GC__
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue