|
1 | 1 | use super::state::{mem0_bytes, Ip, Mem0Len, Mem0Ptr, Sp, VmState}; |
2 | 2 | use crate::{ |
3 | 3 | core::{CoreElementSegment, CoreGlobal, CoreMemory, CoreTable, ReadAs, UntypedVal, WriteAs}, |
4 | | - engine::{DedupFuncType, EngineFunc}, |
| 4 | + engine::{ |
| 5 | + executor::handler::{Done, DoneReason}, |
| 6 | + DedupFuncType, |
| 7 | + EngineFunc, |
| 8 | + }, |
5 | 9 | func::FuncEntity, |
6 | 10 | instance::InstanceEntity, |
7 | 11 | ir::{index, Address, BranchOffset, Offset16, Sign, Slot, SlotSpan}, |
@@ -124,19 +128,20 @@ macro_rules! impl_expand_to_result { |
124 | 128 | } |
125 | 129 | impl_expand_to_result!(bool, i32, i64, u32, u64, f32, f64); |
126 | 130 |
|
127 | | -macro_rules! exec_return { |
128 | | - ($state:expr, $sp:expr, $mem0:expr, $mem0_len:expr, $instance:expr) => {{ |
129 | | - let Some((ip, sp, mem0, mem0_len, instance)) = |
130 | | - $state |
131 | | - .stack |
132 | | - .pop_frame(&mut $state.store, $mem0, $mem0_len, $instance) |
133 | | - else { |
134 | | - // No more frames on the call stack -> break out of execution! |
135 | | - $state.done(DoneReason::Return($sp)); |
136 | | - return Done::control_break(); |
137 | | - }; |
138 | | - dispatch!($state, ip, sp, mem0, mem0_len, instance) |
139 | | - }}; |
| 131 | +pub fn exec_return( |
| 132 | + state: &mut VmState, |
| 133 | + sp: Sp, |
| 134 | + mem0: Mem0Ptr, |
| 135 | + mem0_len: Mem0Len, |
| 136 | + instance: NonNull<InstanceEntity>, |
| 137 | +) -> Done { |
| 138 | + let Some((ip, sp, mem0, mem0_len, instance)) = |
| 139 | + state.stack.pop_frame(state.store, mem0, mem0_len, instance) |
| 140 | + else { |
| 141 | + // No more frames on the call stack -> break out of execution! |
| 142 | + done!(state, DoneReason::Return(sp)) |
| 143 | + }; |
| 144 | + dispatch!(state, ip, sp, mem0, mem0_len, instance) |
140 | 145 | } |
141 | 146 |
|
142 | 147 | pub fn exec_copy_span(sp: Sp, dst: SlotSpan, src: SlotSpan, len: u16) { |
|
0 commit comments