Sibling articles under this feature previously restated requirements in inconsistent forms.
Design model
Platform spec article
Design model
Spec standingStandard
-
This feature hub owns normative MUST/SHOULD contract text for Lowering contract.
Context
Decision
This feature hub owns normative MUST/SHOULD contract text. Sibling articles must not redefine hub requirements and should link here for authority.
Consequences
Contract changes start on the hub or in linked ADRs, then propagate to articles and implementation anchors.
Verification anchors
site/website/src/content/docs/platform-spec/compiler/codegen-and-ir/lowering-contract/index.mdxarticle bundle under the same feature directory.
-
Platform-spec text supersedes informal crate comments for Lowering contract.
Context
Implementation crates accumulated informal notes that diverged from published contracts.
Decision
Normative platform-spec prose and ADRs under this feature supersede informal comments in implementation crates until explicitly migrated into spec text.
Consequences
Engineers file spec/ADR updates when behavior changes; crate comments are non-authoritative for conformance arguments.
Verification anchors
compiler/crates/beskid_codegencompiler/crates/beskid_codegencompiler/crates/beskid_engine/src/jit_module.rs
-
Lowering was split across experimental paths.
Context
Lowering was split across experimental paths.
Decision
beskid_codegen::lower_sourceis the single lowering entry producingCodegenArtifactconsumed byJitModule.Consequences
Experimental IR dumps must not bypass this entry in release builds.
Verification anchors
compiler/crates/beskid_codegencompiler/crates/beskid_engine/src/jit_module.rs.
- Contracts and edge cases Normative guarantees and known edge cases for `Lowering contract`.
- Design model Conceptual model for `Lowering contract` and its subsystem boundaries.
- Examples Practical examples that demonstrate `Lowering contract` behavior.
- FAQ and troubleshooting Common questions and debugging guidance for `Lowering contract`.
- Flow and algorithm End-to-end control flow and major algorithmic steps for `Lowering contract`.
- Verification and traceability How `Lowering contract` requirements map to tests and implementation anchors.
0 revisions (git unavailable at build; counts may be empty)
No commits recorded for this path.
| Section id | Required | Found |
|---|---|---|
what-this-feature-specifies | yes | yes |
implementation-anchors | yes | yes |
Full tree: run pnpm verify:platform-spec-layout (writes src/generated/platform-spec-layout-report.json).
Lowering boundary
Section titled “Lowering boundary”Lowering is the last semantic gate before any backend runs. Inputs are a post-merge program snapshot (HIR + ModuleIndex + resolved types); output is an immutable CodegenArtifact containing Cranelift modules, data descriptors, extern imports, and debug metadata.
Backends must not re-run parse, mod host, or semantic rules on the artifact.
flowchart TB
subgraph analysis [beskid_analysis]
hir[HIR + ModuleIndex]
end
subgraph codegen [beskid_codegen]
lower[lower_program / lower_source]
art[CodegenArtifact]
end
subgraph backends [beskid_engine]
jit[JitModule]
aot[AOT object emit]
end
hir --> lower --> art
art --> jit
art --> aot
Artifact contents
Section titled “Artifact contents”| Slice | Role |
|---|---|
| CLIF modules | Per-compilation-unit functions and globals |
| Builtin imports | declare_builtin_imports from BUILTIN_SPECS |
ExternImport rows | User contract symbols for link step |
| Type descriptors | GC layout + array/string shapes for alloc |
Invariants
Section titled “Invariants”- Lowering runs only when
syntax_generation_idmatches the merged tree used by semantic rules (stage ordering). - Panic/abort paths use
AbiReturnKind::Neverimports so unreachable blocks are correct. - JIT and AOT consume the same artifact type; divergence happens only after
CodegenArtifactis sealed.
Code anchors
Section titled “Code anchors”beskid_codegen::lower_sourceincompiler/crates/beskid_codegenCodegenArtifactconstruction incompiler/crates/beskid_codegenJitModuleincompiler/crates/beskid_engine/src/jit_module.rs- Runtime smoke:
compiler/crates/beskid_tests/src/runtime/jit.rs