Expand description

Zero overhead tracing garbage collection for rust, by abusing the borrow checker.

Features

  1. Easy to use, since Gc<T> is Copy and coerces to a reference.
  2. Absolutely zero overhead when modifying pointers, since Gc<T> is Copy.
  3. Implementation agnostic API
  4. Unsafe code has complete freedom to manipulate garbage collected pointers, and it doesn’t need to understand the distinction
  5. Uses rust’s lifetime system to ensure all roots are known at explicit safepoints, without any runtime overhead.
  6. Collection can only happen with an explicit safepoint call and has no overhead between these calls,
  7. API supports moving objects (allowing copying/generational GCs)

Re-exports

pub use crate::array::GcArray;

Modules

Defines the interface to garbage collected arrays.

Implements a GcCell to allow mutating values inside garbage collected objects.

An “epsilon” garbage collector, which never garbage collects or frees memory until the garbage collector is dropped.

Internal traits intended only for implementations of zerogc

The prelude for zergogc, containing a set of commonly used types and macros.

Garbage collected vectors.

Macros

Indicate its safe to begin a garbage collection (like safepoint!) and then “freeze” the specified context.

Implement NullTrace for a type that lives for 'static

Implement Trace and TraceImmutable as a no-op, based on the fact that a type implements NullTrace

Indicate it’s safe to begin a garbage collection, while keeping the specified root alive.

Invoke the closure with a temporary GcContext, then perform a safepoint afterwards.

Implement Trace for a dynamically dispatched trait object

Unfreeze the context, allowing it to be used again

Unsafely implement GarbageCollected for the specified type, by acquiring a ‘lock’ in order to trace the underlying value.

Unsafely implement GarbageCollected for the specified type, by assuming it’s a ‘primitive’ and never needs to be traced.

Structs

A wrapper type that assumes its contents don’t need to be traced

A garbage collected pointer to a value.

Traits

Uniquely identifies the collector in case there are multiple collectors.

A type that can be traced via dynamic dispatch, specialized for a particular CollectorId.

The context of garbage collection, which can be frozen at a safepoint.

Safely trigger a write barrier before writing to a garbage collected value.

A owned handle which points to a garbage collected object.

Allows changing the lifetime of all Gc references.

A marker trait correlating all garbage collected pointers corresponding to the specified Id are valid for the 'gc lifetime.

A simple interface to allocating from a GcContext.

A garbage collector implementation.

Visits garbage collected objects

A CollectorId that supports allocating GcHandles

Indicates that a mutable reference to a type is safe to use without triggering a write barrier.

Marker types for types that don’t need to be traced

Indicates that a type can be traced by a garbage collector.

A type that can be safely traced/relocated without having to use a mutable reference

Indicates that a type’s Drop implementation is trusted not to resurrect any garbage collected object.

Derive Macros

Trait Aliases

A GcSafe type with all garbage-collected pointers erased to the 'static type.

A trait alias for CollectorIds that support GcSimpleAlloc