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#

silk
pub struct ExecutionStorage

An affine state that owns its private-frame reservations and capacity limit.

Implementation Drop for ExecutionStorage#

silk
impl Drop for ExecutionStorage

Operation drop#

silk
fn drop(self: &mut ExecutionStorage) -> ()

Implementation ExecutionStorage#

silk
impl ExecutionStorage

Associated function make#

silk
pub effect fn make(limit: usize) -> ExecutionStorage ! OutOfMemoryError

Creates 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#

silk
pub fn used(self: &ExecutionStorage) -> usize

Returns the bytes charged to this state's current frame reservations.

Method acquire#

silk
pub unsafe fn acquire(self: &mut ExecutionStorage, size: usize, alignment: usize) -> ?*mut u8

Acquires 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#

silk
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.

View the source of this page