Skip to main content

praxis_runtime/
lib.rs

1//! Runtime heap, type descriptors, and runtime context for Praxis.
2//!
3//! This crate is the contract between JIT-generated code and the Rust runtime,
4//! and it holds the GC implementation.
5//!
6//! - Every language value is a uniform [`GcRef`] (§4.3, §11.1).
7//! - Every generated function follows `fn(RuntimeContext*, GcRef...) -> GcRef`
8//!   (§10.3).
9//! - Runtime wrappers never let a Rust panic unwind across the ABI (§9.2); they
10//!   set `pending_fault` and return a defined sentinel instead.
11//! - A [`TypeDescriptor`] centralizes every operation on a value's payload
12//!   (§11.4), so the compiler never has to scatter type switches.
13//! - A precise, non-moving mark-and-sweep collector reclaims unreachable
14//!   objects (§12.1, ADR-011).
15//!
16//! See `docs/technical-design.md` §11, §12, and Appendix B.
17
18pub mod abi;
19pub mod bitset;
20pub mod breakpoint;
21pub mod closures;
22pub mod collections;
23pub mod context;
24pub mod crash_snapshot;
25pub mod debug;
26pub mod descriptor;
27pub mod dynamic_key;
28pub mod enums;
29pub mod gc;
30pub mod graph;
31pub mod heap;
32pub mod heaps;
33pub mod immortal;
34pub mod input;
35pub mod maps;
36/// The order a hash-backed collection walks and prints its keys in (ADR-138).
37/// Crate-private — it is `Map`/`Set`/`Counter`'s internal sort key, and nothing
38/// outside the runtime picks one.
39pub(crate) mod ordering;
40/// Size-class pages: the storage and the liveness bitmaps behind [`Heap`]
41/// (ADR-103). Crate-private — a page is the collector's business and nothing
42/// outside it has a reason to name one.
43pub(crate) mod page;
44pub mod parse_detail;
45pub mod parser;
46pub mod range;
47pub mod records;
48pub mod repr;
49pub mod repr_c_vec;
50pub mod roots;
51pub mod scalars;
52pub mod shadow_stack;
53pub mod small_char;
54pub mod small_int;
55pub mod teardown;
56pub mod text;
57pub mod tuples;
58pub mod var_cell;
59
60pub use abi::{RUNTIME_ABI_VERSION, assert_abi_version};
61pub use breakpoint::{
62    BreakpointHandler, BreakpointStop, Resume, breakpoints_detached, clear_breakpoint_handler,
63    install_breakpoint_handler,
64};
65pub use closures::ClosurePayload;
66pub use collections::{DequePayload, GridPayload, VecPayload};
67pub use context::{
68    DebugLocal, FRAME_BYTES_BASE, FRAME_BYTES_PER_SLOT, Fault, FaultKind, FaultMessage,
69    MAX_RECURSION_DEPTH, REFERENCE_FRAME_SLOTS, Runtime, RuntimeContext, STACK_BUDGET_BYTES,
70    StackBudget, current_fault_kind, frame_cost,
71};
72pub use crash_snapshot::{CrashSnapshot, SnapshotFrame, SnapshotSlot};
73pub use debug::{
74    DebugFrameEntry, DebugFrameStack, DebugFrameStackHeader, DebugLocalMeta, DebugSlotKind,
75    DebugValue, DebugValueStack, DebugValueStackHeader, FunctionDebugMeta, LOCAL_KIND_TEMP,
76    LOCAL_KIND_USER, ScalarValue,
77};
78pub use descriptor::{
79    BUILTINS, BuiltinTypeId, CompareFn, DropFn, DynamicHasher, EqualsFn, FormatFn, FormatSink,
80    FormatStyle, HashFn, StructHasher, TraceFn, Tracer, TypeDescriptor, TypeId,
81};
82pub use gc::{GcHeader, GcRef, HeapId};
83pub use heap::{
84    Heap, HeapStats, INITIAL_COLLECT_THRESHOLD, InlineClaimSite, InlineInternSite, LIVE_HEADROOM,
85    MAX_COLLECT_THRESHOLD, Pacer,
86};
87pub use immortal::Immortals;
88pub use input::{InputReader, clear_input_reader, install_input_reader};
89pub use parse_detail::{ParseDetail, ParseFail};
90pub use records::{RecordField, RecordPayload, RecordSchema, SchemaIdentity};
91pub use repr::{InstanceArg, InstanceRepr, instance_repr};
92pub use repr_c_vec::{ReprCVec, VecMut};
93pub use roots::{
94    NATIVE_ROOT_RESERVATION, NativeRootStore, NativeScope, RootScope, RootSet, Rooted, RuntimeRoots,
95};
96pub use shadow_stack::{
97    DebugSlotCount, MAX_DEBUG_VALUE_SLOTS, MAX_SHADOW_SLOTS, SHADOW_STACK_SLOTS, ShadowFrameGuard,
98    ShadowStack, ShadowStackHeader, SlotCount, SlotStack, SlotStackHeader, push_frame,
99};
100pub use small_int::{
101    SMALL_INT_COUNT, SMALL_INT_MAX, SMALL_INT_MIN, SMALL_INT_STRIDE, index_of as small_int_index,
102};
103pub use teardown::{HeapDrained, retire_parser_plans};
104pub use text::TextPayload;
105pub use tuples::{TuplePayload, TupleSchema};