pub struct Runtime { /* private fields */ }Expand description
State for batching operations and object storage. Every evaluation is a batch - it may just have one operation.
Uses a free-list strategy for heap ID allocation to stay in sync with JS heap. Also stores exported Rust structs and callback functions.
Implementations§
Source§impl Runtime
impl Runtime
Sourcepub fn get_next_heap_id(&mut self) -> u64
pub fn get_next_heap_id(&mut self) -> u64
Get the next heap ID for placeholder allocation. Uses free-list strategy: reuses freed IDs first, then allocates new ones.
Sourcepub fn get_next_placeholder_id(&mut self) -> u64
pub fn get_next_placeholder_id(&mut self) -> u64
Get the next heap ID for a batched return value placeholder. This also tracks the reserved placeholder count so JS can skip these IDs during nested callback allocations.
Sourcepub fn get_next_borrow_id(&mut self) -> u64
pub fn get_next_borrow_id(&mut self) -> u64
Get the next borrow ID from the borrow stack (indices 1-127). The borrow stack grows downward from JSIDX_OFFSET (128) toward 1. Panics if the borrow stack overflows (more than 127 borrowed refs in one operation).
Sourcepub fn push_borrow_frame(&mut self)
pub fn push_borrow_frame(&mut self)
Push a borrow frame before a nested operation that may use borrowed refs. This saves the current borrow stack pointer so we can restore it later.
Sourcepub fn pop_borrow_frame(&mut self)
pub fn pop_borrow_frame(&mut self)
Pop a borrow frame after a nested operation completes. This restores the borrow stack pointer to where it was before the nested operation.
Sourcepub fn release_heap_id(&mut self, id: u64) -> Option<u64>
pub fn release_heap_id(&mut self, id: u64) -> Option<u64>
Release a heap ID back to the free-list and queue it for JS drop.