#8. Runtime ABI / lowering overview
On this page
This block defines the shared contract between the compiler (nabic) and the runtime (libnabir.a; nabir.lib on Windows MSVC targets). The compiler and the runtime are connected through the text of this specification. The code they share is one crate without dependencies that both build, nabir_abi (runtime/nabir_abi), so both sides use one definition: the GC ABI constants (nabir_abi::gc, 8.1), the TLS slot layout (nabir_abi::tls, 8.3), the module and type descriptors (nabir_abi::module, nabir_abi::typedesc, 8.12, 8.13), and the format-spec, string and Unicode routines that constant evaluation must agree on with the runtime.
#Contents
- 8.1. Object header ABI
- 8.2. ScanTable serialization format
- 8.3. Mutator TLS slot layout
- 8.4. Safepoint protocol
- 8.5. Extern "C" symbols
- 8.6. Calling convention
- 8.7. Code generation
- 8.8. Lowering: data types and expressions
- 8.9. Lowering: control flow and GC integration
- 8.10. Lowering: coroutines and generics
- 8.11. Code generator contract
- 8.12. Module descriptor ABI
- 8.13. Type descriptor ABI
#Two kinds of contract
#1. Runtime ABI
The interface used when compiler-generated code is linked and run together with libnabir.a. The memory layout of objects is specified so that the GC can interpret compiler-created objects exactly. Extern "C" symbols are runtime functions the compiler may call; the thread-safety class of each symbol (thread-safe / caller-thread-only / process-init, etc.) is defined in 8.5.0 Thread-safety classes. TLS slots are thread-local locations read and written by inline code the compiler emits. The calling convention specifies register and stack usage in function calls.
#2. Lowering
The rules, applied in the code generation stage of the compilation pipeline, that translate Nabi's high-level semantics into machine code: the representation of every value and how tagged union, any slots, pattern matching, try/catch, coroutines and generics become loads, stores, branches and calls.
#Why this specification text is authoritative
Apart from those included source files, the compiler and the runtime share no code or header files. The guarantee that both follow the same ABI comes from this specification text and from end-to-end verification in integration tests.
This model follows the same approach as Swift ABI Stability: the specification is authoritative and the implementation follows it.
#Stability
The contract in this block, symbol mangling (9.5) included, is part of the toolchain version. Before 1.0 the ABI may change in every 0.x.0 release; 0.x.y releases do not break it. From 1.0, minor / patch releases may only add and must not break compatibility, and major releases may break it in a way the package manager can detect.
The NABIHIR header of a prebuilt package records the nabic that built it (9.4). Using a package built by a different nabic is an error that asks for a rebuild.
Found a mistake? Edit this page on GitHub. Last updated