Expand description
Which compiled functions — and which ops — can run.
A program’s bytecode carries every function the loader spliced in: the author’s, and whole standard-library modules a type name or a builtin demanded. Most of a demanded module is never called. A backend that lowers only what runs (the WebAssembly backend’s dead-function elimination) must agree with the gate that refuses what it cannot lower (the unlinkable-code gate), or a function nothing calls either breaks the build (the gate refuses dead code) or ships a stub a live call lands on (the backend drops live code). This module is the one answer both ask.
§The code stream
Main is code[0 .. main_end). Regular (## To) functions follow as a contiguous, entry-sorted
tail, each ending where the next begins. A closure body is INLINE: emitted inside its enclosing
region and jumped over by a Jump at entry_pc - 1 whose target is the body’s end, so a region
contains its closures’ bodies as holes.
§The edges
A function runs when Main or a running function names it: a Call, a MakeClosure body, or a
Spawn/SpawnHandle task. Two facts no op carries are part of the graph too, because the
backends act on them:
text_from_bytesvalidates throughvalidUtf8 (data: Seq of Int) -> Bool, a call the wasm backend writes from the builtin;- a page’s entries (
lgx_lower::LGX_ENTRIES) are entered by the HOST, never by the module; so is the mount of a component the host was asked to mount on demand (HostEntries).
Three facts gate edges:
- a drawn component’s members (its actions, bindings, patchers and callback trampolines) run only
for an instance, so an edge into one from outside the component is followed once the
component’s render is reached (
ComponentOwners); - a
vdom.lgfeature’s functions run only on a tape holding records its writers laid down (lgx_lower::VDOM_FEATURES), so an edge into one is followed once a writer is reached (VdomFeatures); - hydration (
vdHydrate) runs only for a page its build pre-rendered, which the host says (HostEntries::drawing_freshsays it never is).
Structs§
- Code
Layout - How the flat code stream partitions into functions.
- Host
Entries - The functions a page’s HOST enters by name, beyond Main: every fixed page entry of
lgx_lower::LGX_ENTRIESthe program defines, always; and the mount of each component the host is asked to be able to mount on demand — a test that mounts a component at a statement of its own. A shipped page has no such components (its only mount is the one its ownmainperforms), so the default is the fixed page entries alone. - Reach
- What can run.
Constants§
- UTF8_
VALIDATOR - The function
text_from_bytesvalidates through.
Functions§
- code_
layout - Resolve the
CodeLayout: aMakeClosuretarget is a closure body spanning[entry, jump-over target); the regular functions are the entry-sorted tail after Main.Errnames a closure body with no jump-over, which no compiler output has. - reach
- Walk the call graph from Main and a shipped page’s host entries.
- reach_
with - Walk the call graph from Main and every one of
entries. - running_
ops - Every op that can run in a shipped page, with its pc. A program whose layout cannot be resolved is taken whole: the caller is a gate, and a gate that cannot tell must not wave code through.
- running_
ops_ with - Every op that can run once the host may also enter
entries, with its pc — what a gate judges when a module is built for a host that mounts components on demand.