pub struct MirProgram {
pub fns: HashMap<FnId, MirFn>,
pub modules: Vec<ModuleId>,
pub stats: LowerStats,
pub builtins: Vec<String>,
pub external_callers_possible: bool,
}Expand description
A whole compiled program in Core MIR. Keyed by FnId (stable
across compilation units; same identity layer the rest of the
pipeline consumes). Phase 2a builds an empty MirProgram
directly; Phase 3 grows the lowering that populates it from
ResolvedProgramView.
Fields§
§fns: HashMap<FnId, MirFn>All compiled functions, keyed by their FnId.
modules: Vec<ModuleId>Optional module identity for tooling that wants to walk
MirProgram per source module (LSP outline, future
per-module IR dump). Empty when the program was assembled
from a single entry file with no depends [...].
stats: LowerStatsCoverage telemetry for the lowering that produced this
program. lowered + skipped.values().sum() equals the
number of ResolvedFnDef items the lowerer saw — see
super::stats::LowerStats for the coverage gate that
Phase 4 (VM slice) consumes.
builtins: Vec<String>Phase 6 wave 11 — interned built-in fn names. Indexed by
BuiltinId. Lowering grows this lazily as it encounters
each unique ResolvedCallee::Builtin(name) shape; MIR
consumers (VM walker, Rust walker, optimize passes) look
up the canonical string via program.builtin_name(id)
instead of carrying the string inline on every
MirCallee::Builtin.
external_callers_possible: booltrue when this program is a fragment of a larger build whose
other parts are compiled separately — specifically a dependency
module under the VM’s per-module compile (the VM lowers each
depends [...] module to its own MirProgram). Such a fragment
does NOT see the entry/sibling call sites, so whole-program
analyses that rely on “every caller is visible” (notably
own_param_refine) must bail. false for a whole-program compile
(single entry, or the flattened wasm-gc / Rust builds), where all
callers are present and graduation is sound.
Implementations§
Source§impl MirProgram
impl MirProgram
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Construct an empty program. Phase 3 lowering will populate
fns and modules as it walks ResolvedProgramView.
Sourcepub fn fn_by_id(&self, id: FnId) -> Option<&MirFn>
pub fn fn_by_id(&self, id: FnId) -> Option<&MirFn>
Lookup a function by its FnId. Returns None if the id
wasn’t part of this compilation (e.g. a stale id surviving
from a previous program view).
Sourcepub fn iter(&self) -> impl Iterator<Item = (&FnId, &MirFn)>
pub fn iter(&self) -> impl Iterator<Item = (&FnId, &MirFn)>
All functions in arbitrary (HashMap) order. Callers that
need a stable walk (snapshot tests, dump output) should sort
by FnId themselves.
Sourcepub fn builtin_name(&self, id: BuiltinId) -> &str
pub fn builtin_name(&self, id: BuiltinId) -> &str
Phase 6 wave 11 — look up the canonical name behind a
BuiltinId minted by this program’s lowering. Returns
"" (empty slice) if the id is out of range — a defensive
fallback for diagnostic paths; consumers in the hot path
should hold valid ids by construction.
Sourcepub fn intern_builtin(&mut self, name: &str) -> BuiltinId
pub fn intern_builtin(&mut self, name: &str) -> BuiltinId
Phase 6 wave 11 — intern a built-in fn name into this
program’s table. Returns the stable BuiltinId, reusing
the existing slot when the name has already been
registered. Lowering calls this; downstream optimizer
passes inherit the existing ids when they construct new
MirCallee::Builtin instances (e.g. from inlining).
Trait Implementations§
Source§impl Clone for MirProgram
impl Clone for MirProgram
Source§fn clone(&self) -> MirProgram
fn clone(&self) -> MirProgram
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more