Skip to main content

Module interner

Module interner 

Source
Expand description

Append-only interners for constants (literals and byte blobs), wrapped in an RwLock so they can be minted through a shared & reference โ€” the prerequisite for a function pass creating a constant while it holds only a ContextView. Interned ids are globally stable and never remapped.

Reads (Index) return a &T that outlives the read guard. This is sound because the backing Registry is address-stable: it never moves an element once pushed (see jstd::registry::Registry), so the reference stays valid for the life of the interner even as later mints grow it. The read lock only guards the brief indexing.

Structsยง

Interner
A generic append-only interner: an address-stable Registry behind an RwLock. Pushes take a write lock; reads (Index) take a read lock and hand back a stable &T.
LiteralInterner
The literal interner: an address-stable literal Registry plus its dedup cache (masked value, type) โ†’ LiteralId, together behind one RwLock so the check-or-mint is atomic. Reads (Index) hand back a stable &Literal.