Skip to main content

Abusing reborrowing for fun, profit, and a safepoint garbage collector

UB2.252A (Lameere) | Day 1 | 13:10 - 13:50 | Speakers: Aapo Alasuutari

Abusing reborrowing for fun, profit, and a safepoint garbage collector
A picture of a devroom at FOSDEM 2024
Open in browser

Notes

Abstract

Rust's references adhere to a strict "one exclusive XOR many shared" model, which gives the language much of its greatest safety guarantees. Reborrowing is a feature that seems on surface to break this rule: An exclusive reference can be turned into shared references and those shared references can be used together with the exclusive reference as long as these are all used as if they were shared references. Only once the exclusive reference is used as exclusive, all the derived or "reborrowed" shared references are invalidated. The XOR rule is upheld, but in a way that breaks a literal reading of the rule.

Usually reborrowing is used temporarily but what if we make it our modus operandi? This talk explores using and slightly abusing reborrowing and comes out the other side with an awkward but functional safepoint garbage collector built upon reborrowing a ZST marker and a whole load of typed indexes. The garbage collector is part of the Nova JavaScript engine.

https://trynova.dev/

Speakers

Aapo Alasuutari

Notice: The placeholder video image is licensed under CC BY-SA 4.0. The original image can be found hereChanges made to the image are: Cropped the image to a new ratio, part of the image was cut off.