kyren / gc-arena

Incremental garbage collection from safe Rust
Creative Commons Zero v1.0 Universal
436 stars 36 forks source link

Add a way to deterministically transition to `CollectionPhase::Collecting` #96

Closed kyren closed 1 month ago

kyren commented 2 months ago

This is necessary when trying to use finalization, because you want to be completely out of the marking phase once you have decided finalization is finished for this cycle.

kyren commented 1 month ago

Changed MarkedArena::collect to MarkedArena::start_collecting

Added a drive by change from self.metrics.allocation_debt() <= target_debt to !(self.metrics.allocation_debt() > target_debt) out of NaN paranoia.

Added an EarlyStop enum for Context::do_collection, rather than relying on another custom method.

Changed MarkedArena to own a &mut Arena instead of &Arena. These are equivalent since every method that produces a MarkedArena takes &mut self and Rust can't downgrade mutable borrows, but it expresses the intent better, and MarkedArena now actually calls Context::do_collection.