devicescript icon indicating copy to clipboard operation
devicescript copied to clipboard

compacting GC

Open mmoskal opened this issue 2 years ago • 0 comments

Some notes on how to implement compacting/moving GC:

  • [ ] in addition to marking things as PENDING in too deep GC mark, also have a tmp list (16 elements or so)
  • [ ] devs_value_pin(value_t) -> devs_add_root(value_t*) or devs_add_root(void**)
  • [ ] we'll need separate malloc() area, for pointers that can't move

GC Process:

  • mark live pointers as today
  • compute final size S of the heap (sum of sizes of live objects)
  • rewrite first word of each live object forwarding pointer, while moving the existing header from first word to linked list past S
  • rewrite internal pointers and roots using forwarding pointers
  • compact the heap, while fixing the first word from forwarding pointer back into header

mmoskal avatar Mar 24 '23 17:03 mmoskal