Expand description
Zero overhead tracing garbage collection for rust, by abusing the borrow checker.
§Features
- Easy to use, since
Gc<T>
isCopy
and coerces to a reference. - Absolutely zero overhead when modifying pointers, since
Gc<T>
isCopy
. - Implementation agnostic API
- Unsafe code has complete freedom to manipulate garbage collected pointers, and it doesn’t need to understand the distinction
- Uses rust’s lifetime system to ensure all roots are known at explicit safepoints, without any runtime overhead.
- Collection can only happen with an explicit
safepoint
call and has no overhead between these calls, - API supports moving objects (allowing copying/generational GCs)
Modules§
- cell
- Implements a GcCell to allow mutating values inside garbage collected objects.
- prelude
- The prelude for
zergogc
, containing a set of commonly used types and macros.
Macros§
- freeze_
context - Indicate its safe to begin a garbage collection (like safepoint!) and then “freeze” the specified context.
- safepoint
- Indicate it’s safe to begin a garbage collection, while keeping the specified root alive.
- safepoint_
recurse - Invoke the closure with a temporary GcContext, then perform a safepoint afterwards.
- unfreeze_
context - Unfreeze the context, allowing it to be used again
- unsafe_
gc_ brand - Unsafely assume that the generic implementation of [GcBrand] is valid, if and only if it’s valid for the generic lifetime and type parameters.
- unsafe_
immutable_ trace_ iterable - Unsafely implement
ImmutableTrace
for the specified iterable type, by iterating over the type to trace all objects. - unsafe_
trace_ deref - Unsafely implement
GarbageCollected
for the specified type, by converting the specified wrapper type in order to trace the underlying objects. - unsafe_
trace_ lock - Unsafely implement
GarbageCollected
for the specified type, by acquiring a ‘lock’ in order to trace the underlying value. - unsafe_
trace_ primitive - Unsafely implement
GarbageCollected
for the specified type, by assuming it’s a ‘primitive’ and never needs to be traced.
Structs§
- Assume
NotTraced - A wrapper type that assumes its contents don’t need to be traced
- Gc
- A garbage collected pointer to a value.
Traits§
- Collector
Id - Uniquely identifies the collector in case there are multiple collectors.
- GcBind
Handle - Trait for binding GcHandles to contexts using GcBindHandle::bind_to
- GcBrand
- Changes all references to garbage
collected objects to match
'new_gc
. - GcContext
- The context of garbage collection, which can be frozen at a safepoint.
- GcDirect
Barrier - Safely trigger a write barrier before writing to a garbage collected value.
- GcHandle
- A owned handle which points to a garbage collected object.
- GcHandle
System - A system which supports creating handles to Gc references.
- GcSafe
- Indicates that a type can be safely allocated by a garbage collector.
- GcSimple
Alloc - A simple interface to allocating from a GcContext.
- GcSystem
- A garbage collector implementation.
- GcVisitor
- Visits garbage collected objects
- Null
Trace - Marker types for types that don’t need to be traced
- Trace
- Indicates that a type can be traced by a garbage collector.
- Trace
Immutable - A type that can be safely traced/relocated without having to use a mutable reference