Skip to content

Garbage collection #415

Closed as not planned
Closed as not planned
@glaebhoerl

Description

@glaebhoerl

We want to add support for garbage collection at some point.

We had a really long discussion about this back on the rust repository here. It also implicates the design for allocators.

My own belief is that the best plan would be precise tracing piggybacked off the existing trait and trait object system, i.e. compiler-derived trace routines (Trace impls) for each type, as outlined in my comment here. This would likely be very performant and avoid the need for any kind of headers on allocations, except for existentials (trait objects), which could/would have a Trace vtable pointer similarly to how Drop is currently done, i.e. this would also "just fall out" of the trait-based mechanism. By avoiding headers, we could also avoid imposing any costs on code which doesn't use GC.

(I am also not sure that we need to involve LLVM in any way, at least in the first round. My suspicion is that via the borrow checker and the type system (at least once we have static drops), we already have more information than would LLVM. Instead of stack maps, at least in the first iteration, in GC-using code we could have the compiler insert calls to register/unregister stack variables which may potentially contain managed data with the GC, based on borrow checker information.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-allocationProposals relating to allocation.A-machineProposals relating to Rust's abstract machine.T-langRelevant to the language team, which will review and decide on the RFC.T-libs-apiRelevant to the library API team, which will review and decide on the RFC.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions