Expand description
FFI Trampolines for Async Operations
These extern “C” functions are called from JIT-compiled code to interact with the async execution system (event queue, alerts, etc.)
Design principles:
- Platform-agnostic: works on Tokio and bare metal
- No Tokio-specific async in these functions
- All async coordination through event queue abstraction
Structs§
- Event
Queue Opaque - Opaque type for event queue scheduling. This allows JIT to schedule events without knowing the full EventQueue type.
Constants§
- SUSPENSION_
ASYNC_ WAIT - Suspension state for async-wait (JoinAwait returns this to signal the JIT execution loop should hand control back to the interpreter).
- SUSPENSION_
RUNNING - Suspension state constants
- SUSPENSION_
SUSPENDED - SUSPENSION_
YIELDED
Statics§
- ASYNC_
SCOPE_ ENTER_ FN - Async scope enter trampoline:
fn() - ASYNC_
SCOPE_ EXIT_ FN - Async scope exit trampoline:
fn() - CANCEL_
TASK_ FN - Cancel trampoline:
fn(future_bits: u64) - SCHEDULE_
EVENT_ FN - ModuleBinding function pointer for event scheduling. Set by HybridKernel when simulation starts.
- SPAWN_
TASK_ FN - Spawn trampoline:
fn(callable_bits: u64) -> u64(returns Future bits)
Functions§
- __
shape_ emit_ alert - Emit an alert to the alert pipeline
- __
shape_ emit_ event - Push an event to the event queue
- __
shape_ get_ suspension_ state - Get the current suspension state
- __
shape_ poll_ event - Poll the event queue for the next event
- __
shape_ resume - Resume execution after suspension
- __
shape_ schedule_ event - Schedule a future event for simulation.
- __
shape_ set_ yield_ threshold - Set the yield threshold for cooperative scheduling
- __
shape_ should_ yield - Check if JIT code should yield for cooperative scheduling
- __
shape_ suspend - Suspend execution waiting for a specific event type
- __
shape_ yield - Mark the context as yielded
- jit_
async_ scope_ enter - Enter an async scope (structured concurrency boundary).
- jit_
async_ scope_ exit - Exit an async scope (structured concurrency boundary).
- jit_
cancel_ task - Cancel a running task by its future ID.
- jit_
join_ await - Await a task group, suspending JIT execution.
- jit_
join_ init - Initialize a join group from task futures.
- jit_
spawn_ task - Spawn a new async task.
- register_
async_ ⚠task_ fns - Register all async task trampolines.
- register_
schedule_ ⚠event_ fn - Register the schedule function for JIT calls.
- unregister_
async_ task_ fns - Clear all async task trampoline registrations.
- unregister_
schedule_ event_ fn - Clear the schedule function registration.