This repository has been archived by the owner on Nov 24, 2022. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Context
The current
asterius
garbage collector is a copying collector, traversing all live heap objects whenever invoked. Performing a complete ("major") garbage collection each time is quite expensive, and usual runtime systems employ generational collectors, where objects in the heap are segregated according to their age; most times, only the youngest objects are garbage collected ("minor" collection).Changes
This PR implements a simple generational GC, with two generations: gen 0 is the youngest and gen 1 the oldest. It requires inter-generational pointers (from gen 1 to gen 0) to be recorded, so to used them as roots during a minor collection. All young closures that survive a minor collection are promoted to gen 1 (i.e. generations are not divided in additional steps).
Special care has to be taken so to handle correctly "pinned" blocks: in the
asterius
runtime, the closures allocated in pinned blocks will not be moved by the garbage collector - this means that a different kind of promotion applies to pinned closures.Related PRs
HeapAlloc
Work in progress
There is mainly one feature missing: deciding when the collector should select a minor vs major collection. Probably need to fine tune the parameters and verify reduced running times of tests.