silk.concurrency.execution_storage.
Storage for the private execution frames that the compiler makes.
When to use#
The compiler and the runtime use this module through its C exports. Application code does not call it.
Details#
Each ExecutionStorage state owns its limit, its accounting and its frames. There is no
shared counter and no environment lookup. A state is a stack: frames are carved one after
another from segments, and released in reverse order, so a callee's frame sits right after its
caller's and costs no allocation of its own. The first segment, one page, comes with the
state; a frame that does not fit starts a new segment, which stays for reuse once it empties.
The second segment is sixteen times the size of the first, and each later one four times the
size of the last. Compiled code carves most frames itself from the state's window
without calling the state. Segments use the declared allocator of the selected target.
Errors#
ExecutionStorage.make fails with OutOfMemoryError. ExecutionStorage.acquire returns
null when a frame does not fit in the limit or cannot be allocated.
Gotchas#
Raw frame access is unsafe. A frame is valid only until it is released or its state is destroyed.
Frames are released last first; releasing any other frame corrupts the state.
One state needs exclusive use. Independent states can use a concurrent host allocator.
Import as ExecutionStorage with import silk.concurrency.execution_storage { ExecutionStorage }.
Public declarations: 1.
ExecutionStorage#
pub struct ExecutionStorageAn affine state that owns its private-frame reservations and capacity limit.
Implementation Drop for ExecutionStorage#
impl Drop for ExecutionStorageOperation drop#
fn drop(self: &mut ExecutionStorage) -> ()Implementation ExecutionStorage#
impl ExecutionStorageAssociated function make#
pub effect fn make(limit: usize) -> ExecutionStorage ! OutOfMemoryErrorCreates an independent state whose frame reservations can charge at most limit bytes.
Details#
Charges include each frame's offset word and alignment padding. The state allocation, which holds the first segment, is excluded. Refusal acquires no state and reports OutOfMemoryError.
Method used#
pub fn used(self: &ExecutionStorage) -> usizeReturns the bytes charged to this state's current frame reservations.
Method acquire#
pub unsafe fn acquire(self: &mut ExecutionStorage, size: usize, alignment: usize) -> ?*mut u8Acquires a fixed-address frame or returns null without retaining a partial reservation.
Gotchas#
The caller must initialize bytes before reading, obey the requested extent, and stop using the pointer before release or state destruction. A zero size or invalid alignment returns null.
Method release#
pub unsafe fn release(self: &mut ExecutionStorage, frame: ?*mut u8) -> ()Releases the frame this state acquired last and removes its charge.
Gotchas#
Frames are released in reverse acquisition order: frame must be the live frame acquired
last. The caller must finish semantic cleanup and stop every access before releasing it.
Category: Concurrency.
Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, x86_64-unknown-linux-gnu, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2, x86_64-pc-windows-msvc, wasm64-unknown-unknown.