Skip to main content

allocate_closure_globals

Function allocate_closure_globals 

Source
pub fn allocate_closure_globals(
    metas: &[AdapterMeta],
    exported: &BTreeMap<MangledName, MangledName>,
    globals: &mut GlobalSection,
    symbols: &mut SymbolTable,
    next_global_idx: &mut u32,
) -> Result<u32, CompilerFailure>
Expand description

Allocates the globals that cache a function’s closure, so every read of a top-level function yields the same value and f === f holds. The closure has no environment, so one instance serves every read. Each starts null and is filled on first read. Each function this module exports gets one shared anyref cache; any other function read here gets a typed cache of its own, unless it imported a shared one. Returns how many globals were added.