Expand description
The Nova runtime: support functions linked into every Nova program.
Phase 1 scope (spec 13-RUNTIME.md, “minimal: panic, allocator, basic
types”): string values, console output, and sum-type allocation. All
functions use the C ABI so compiled Nova code (Cranelift/LLVM) can call
them directly; for nova run they are registered as JIT symbols via
symbols.
Memory: heap values (records, sums, arrays, closures, strings, and
Bytes) are managed by a conservative mark-and-sweep garbage
collector — see [gc] and docs/adr/0002-phase1-leaking-allocator.md.
All heap allocation routes through [gc::alloc], which reclaims
unreachable objects.
Modules§
- bytes
- Byte-buffer intrinsics for
std/bytes.pub, not private, for the same reason asfs: its own doc comment explains the boundary it implements (one representation, shared withNovaStr, distinguished only byhir::Ty). Branchbyte-type’s own Task 3 (docs/superpowers/plans/2026-08-12-byte-type.md) added the rest of the byte surface beside this module’s first four intrinsics, the same way this crate’s other modules build ontask. Byte-buffer intrinsics forstd/bytes. - fs
- Filesystem intrinsics for
std/fs.pub, not private: its own doc comment explains the boundary it implements; nothing about that requires hiding the module itself. Branchstd-fs-strings’s Task 3 and Task 4 (docs/superpowers/plans/2026-08-11-std-fs-strings.md) built most of this module, and branchbyte-type’s own Task 4 later addedread/writebeside them, the same way this crate’s other modules build ontask. Filesystem intrinsics forstd/fs. - io
- The three standard streams’ intrinsics for
std/io.pub, not private, for the same reason asfsandbytes: its own doc comment explains the boundary it implements. Branchread-write-stdio’s Task 1 added this module besidefsandbytes, reusingfs‘s per-task slot table rather than owning a second one. The three standard streams’ boundary. - process
- The program’s arguments and
exit, behindstd/process(see its module doc anddocs/adr/0023-program-arguments.md).pubso the driver’s JIT path can set the list, and sotests/process_args_*.rscan drive it. The running program’s arguments, and a way to end it with a status: the runtime half ofstd/process’sargs()andexit(). - signal
- The process-wide shutdown flag
std/http’sServer::listenpolls (see its module doc anddocs/adr/0022-process-shutdown-signals.md).pub, unlike [time], sotests/signal_*.rscan drive it. The process-wide shutdown flag behindstd/http’s gracefulServer::listen. - task
pub, not private like [gc]:task’s ABI constants (PollFn,POLL_READY,STATE_SLOT_TAG,STATE_SLOT_TEMPS) are not all read by this crate’s own runtime logic – some exist purely as the documented contract codegen (Task 5’sasync_lower.rs) must reproduce. A private module would make thosepubitems unreachable from outside the crate, which both defeats their purpose and makes rustc’sdead_codelint treat them as genuinely dead, since nothing inside this crate alone uses them. A single-threaded cooperative executor.
Structs§
- NovaStr
- A Nova string value: immutable UTF-8,
{ len, ptr }.
Functions§
- nova_
rt_ alloc - Allocate
sizezeroed bytes for a heap value — a sum{ tag, fields... }, record{ fields... }, array{ len, elems... }, or closure environment. The result is GC-managed and its slots are traced for further pointers. - nova_
rt_ bool_ to_ str - Format a
Boolastrue/false. - nova_
rt_ char_ to_ str - Format a
Char(Unicode scalar value) as a string. - nova_
rt_ check_ bounds - Abort if
indexis outside0..len(an array bounds violation). - nova_
rt_ ⚠eprint - Write
sto stderr with no trailing newline. - nova_
rt_ ⚠eprintln - Write
sto stderr followed by a newline. - nova_
rt_ float_ fixed - Format a
Floatto a fixed number of decimal places. - nova_
rt_ float_ to_ str - Format a
Floatas a string. - nova_
rt_ int_ hash_ seed - The per-process seed for
std/core’sInt,BoolandCharhashing, XORed into the input beforemix64runs. - nova_
rt_ int_ to_ str - Format an
Intas a string. - nova_
rt_ ⚠json_ quote sas a JSON string literal, quotation marks included: the body ofstd/json’squote.- nova_
rt_ ⚠panic_ str - Abort the program with a panic message given as a Nova string.
- nova_
rt_ ⚠print - Print a string to stdout without a trailing newline.
- nova_
rt_ ⚠println - Print a string followed by a newline to stdout.
- nova_
rt_ ⚠str_ chars - Decompose
sinto a Nova[Char]. - nova_
rt_ ⚠str_ cmp - Byte-lexicographic comparison of two strings:
-1,0, or1. - nova_
rt_ ⚠str_ concat - Concatenate two strings into a new string value.
- nova_
rt_ ⚠str_ concat_ n - Concatenate every string in
partsinto one new string: the n-ary form string interpolation of three or more parts lowers to. - nova_
rt_ ⚠str_ eq - Compare two strings for byte equality.
- nova_
rt_ ⚠str_ from_ chars - Encode a Nova
[Char]back into a string. - nova_
rt_ ⚠str_ hash - Seeded, finalized hash of a Nova string’s bytes, as an
i64. - nova_
rt_ ⚠str_ index_ of - The character index of the first occurrence of
needleinhaystack, or-1: the body ofstd/strings’String.index_ofandString.contains. An empty needle occurs at0. - nova_
rt_ ⚠str_ join - Join every string in
partswithsepbetween each pair: the body ofstd/strings’String.join. - nova_
rt_ ⚠str_ len_ chars - Number of Unicode scalar values in
s. - nova_
rt_ ⚠str_ new - Create a string value from raw bytes (used for string literals).
- nova_
rt_ ⚠str_ to_ float - Parse decimal text as a
Float. - nova_
rt_ ⚠str_ to_ lower - Lowercase
swith full Unicode case mapping. Whole-string for the same reason asnova_rt_str_to_upper. - nova_
rt_ ⚠str_ to_ upper - Uppercase
swith full Unicode case mapping. - nova_
rt_ test_ selector test_selector() -> i64. SeeBuiltin::TestSelector.- splitmix64_
finalize - splitmix64’s finalizer — the same function
std/core’smix64computes. - symbols
- All runtime symbols, for registration with the JIT (or a linker map).