pub struct JitEffectMachine { /* private fields */ }Expand description
High-level JIT effect machine.
Compiles a CoreExpr (Haskell effect program) into native code via Cranelift
and runs it as a coroutine: the machine yields effect requests, the caller
dispatches them through an HList of EffectHandlers, and resumes with responses.
ⓘ
let (expr, table) = haskell_inline! { target = "main", include = "haskell", r#"..."# };
let mut vm = JitEffectMachine::compile(&expr, &table, 1 << 20)?;
vm.run(&table, &mut frunk::hlist![MyHandler], &())?;Owns the compiled code, nursery (GC heap), and freer-simple constructor tags. The nursery size (in bytes) controls how much heap is available before GC triggers.
Implementations§
Source§impl JitEffectMachine
impl JitEffectMachine
Sourcepub fn compile(
expr: &CoreExpr,
table: &DataConTable,
nursery_size: usize,
) -> Result<Self, JitError>
pub fn compile( expr: &CoreExpr, table: &DataConTable, nursery_size: usize, ) -> Result<Self, JitError>
Compile a CoreExpr for JIT execution.
Sourcepub fn run<U, H: DispatchEffect<U>>(
&mut self,
table: &DataConTable,
handlers: &mut H,
user: &U,
) -> Result<Value, JitError>
pub fn run<U, H: DispatchEffect<U>>( &mut self, table: &DataConTable, handlers: &mut H, user: &U, ) -> Result<Value, JitError>
Run to completion, dispatching effects through the handler HList.
Auto Trait Implementations§
impl !Freeze for JitEffectMachine
impl !RefUnwindSafe for JitEffectMachine
impl Send for JitEffectMachine
impl !Sync for JitEffectMachine
impl Unpin for JitEffectMachine
impl UnsafeUnpin for JitEffectMachine
impl !UnwindSafe for JitEffectMachine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more