Browse the docs

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 reservations. There is no shared counter and no environment lookup. Allocation and release 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.

  • 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 reservation header and alignment padding. The fixed state allocation 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 one frame acquired from this state and removes its charge.

Gotchas#

The caller must finish semantic cleanup and stop every access before releasing the frame.

Category: Concurrency.

Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, x86_64-unknown-linux-gnu, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2.

View the source of this page