jorendorff / cell-gc

A very small GC in Rust, with a safe API
MIT License
62 stars 4 forks source link

Eliminate in-heap types #5

Open jorendorff opened 7 years ago

jorendorff commented 7 years ago

The layout of an "heap" (Storage) type is always identical to the layout of the corresponding "stack" type. E.g. the stack type Student is essentially identical to the heap type StudentStorage.

The design has two separate types because moving a value from/into the heap is not quite trivial: when moving a pointer-to-heap-value out, it must be wrapped in a GCRef, and the referent pinned. When moving a GCRef in, the referent must be unpinned. However I don't think the duplication of types is paying for itself.

Unifying the two types would probably lead to better destructor behavior.