use crate::extern_::{Memory, Table};
use crate::func::Func;
use crate::instance::Instance;
use crate::value::Ref;
pub(crate) enum Outcome {
Finished,
#[cfg(feature = "async")]
HostAsync {
func: Func,
instance: Instance,
},
#[cfg(feature = "async")]
FuelYield,
EpochDeadline,
Grow {
memory: Memory,
delta: u64,
at: usize,
},
TableGrow {
table: Table,
delta: u64,
init: Ref,
at: usize,
},
GcGrow {
reserved_target: usize,
bytes_needed: u64,
},
}
pub(super) const CONTROL: u32 = u32::MAX;
pub(super) const CALL_INTERNAL: u32 = u32::MAX - 1;
#[derive(Debug)]
pub(super) enum StepOutcome {
Call(CallReq),
TailCall(CallReq),
TailHostCall {
func: Func,
instance: Instance,
args_at: usize,
n_params: usize,
},
HostCall {
func: Func,
instance: Instance,
top: usize,
return_ip: u32,
},
#[cfg(feature = "async")]
TailHostAsyncCall {
func: Func,
instance: Instance,
args_at: usize,
n_params: usize,
},
#[cfg(feature = "async")]
HostAsyncCall {
func: Func,
instance: Instance,
top: usize,
return_ip: u32,
},
Grow {
memory: Memory,
delta: u64,
at: usize,
return_ip: u32,
},
TableGrow {
table: Table,
delta: u64,
init: Ref,
at: usize,
return_ip: u32,
},
GcGrow {
reserved_target: usize,
bytes_needed: u64,
return_ip: u32,
},
}
pub(super) enum ResolvedCall {
Wasm(Callee),
Host(Func),
#[cfg(feature = "async")]
HostAsync(Func),
}
#[derive(Debug, Clone, Copy)]
pub(super) struct Callee {
pub instance: Instance,
pub func_index: u32,
pub index: u32,
pub key: usize,
pub n_params: u32,
pub type_idx: u32,
}
#[derive(Debug)]
pub(super) struct CallReq {
pub return_ip: u32,
pub args_at: usize,
pub callee: Callee,
}