Skip to content

Commit f61d0de

Browse files
committed
fix updating callee_sp in call handlers
1 parent 6e377fd commit f61d0de

File tree

1 file changed

+9
-7
lines changed
  • crates/wasmi/src/engine/executor/handler

1 file changed

+9
-7
lines changed

crates/wasmi/src/engine/executor/handler/exec.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,14 @@ pub fn call_internal(
172172
let (caller_ip, crate::ir::decode::CallInternal { params, func }) = unsafe { ip.decode() };
173173
let func = EngineFunc::from(func);
174174
let (callee_ip, size) = compile_or_get_func!(state, ip, sp, mem0, mem0_len, instance, func);
175-
match state
175+
let callee_sp = match state
176176
.stack
177177
.push_frame(Some(caller_ip), callee_ip, params, size, None)
178178
{
179179
Ok(sp) => sp,
180180
Err(trap) => break_with_trap!(trap, state, ip, sp, mem0, mem0_len, instance),
181181
};
182-
dispatch!(state, callee_ip, sp, mem0, mem0_len, instance)
182+
dispatch!(state, callee_ip, callee_sp, mem0, mem0_len, instance)
183183
}
184184

185185
pub fn call_imported(
@@ -204,7 +204,7 @@ pub fn call_imported(
204204
.inner()
205205
.resolve_instance(&callee_instance)
206206
.into();
207-
match state.stack.push_frame(
207+
let callee_sp = match state.stack.push_frame(
208208
Some(caller_ip),
209209
callee_ip,
210210
params,
@@ -216,7 +216,7 @@ pub fn call_imported(
216216
};
217217
let (instance, mem0, mem0_len) =
218218
update_instance(state.store, instance, callee_instance, mem0, mem0_len);
219-
(callee_ip, sp, mem0, mem0_len, instance)
219+
(callee_ip, callee_sp, mem0, mem0_len, instance)
220220
}
221221
FuncEntity::Host(_func) => {
222222
todo!()
@@ -258,7 +258,7 @@ pub fn call_indirect(
258258
.inner()
259259
.resolve_instance(&callee_instance)
260260
.into();
261-
match state.stack.push_frame(
261+
let callee_sp = match state.stack.push_frame(
262262
Some(caller_ip),
263263
callee_ip,
264264
params,
@@ -270,7 +270,7 @@ pub fn call_indirect(
270270
};
271271
let (instance, mem0, mem0_len) =
272272
update_instance(state.store, instance, callee_instance, mem0, mem0_len);
273-
(callee_ip, sp, mem0, mem0_len, instance)
273+
(callee_ip, callee_sp, mem0, mem0_len, instance)
274274
}
275275
FuncEntity::Host(_func) => {
276276
todo!()
@@ -434,7 +434,9 @@ macro_rules! handler_binary {
434434
let rhs = get_value(rhs, sp);
435435
let value = match $eval(lhs, rhs).into_trap_result() {
436436
Ok(value) => value,
437-
Err(trap) => break_with_trap!(trap, state, ip, sp, mem0, mem0_len, instance),
437+
Err(trap) => {
438+
break_with_trap!(trap, state, ip, sp, mem0, mem0_len, instance)
439+
},
438440
};
439441
set_value(sp, result, value);
440442
dispatch!(state, ip, sp, mem0, mem0_len, instance)

0 commit comments

Comments
 (0)