Skip to content

Commit

Permalink
fix the other new host tail calls test
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbepop committed Dec 4, 2024
1 parent 40c2e07 commit 9eb1a44
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions crates/wasmi/src/engine/executor/instrs/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,9 @@ impl Executor<'_> {
let instance = *self.stack.calls.instance_expect();
// We have to reinstantiate the `self.sp` [`FrameRegisters`] since we just called
// [`ValueStack::reserve`] which might invalidate all live [`FrameRegisters`].
let caller = match <C as CallContext>::KIND {
CallKind::Nested => self.stack.calls.peek().copied(),
CallKind::Tail => self.stack.calls.pop().map(|(frame, _instance)| frame),
let (caller, popped_instance) = match <C as CallContext>::KIND {
CallKind::Nested => self.stack.calls.peek().copied().map(|frame| (frame, None)),
CallKind::Tail => self.stack.calls.pop(),
}
.expect("need to have a caller on the call stack");
let buffer = self.stack.values.extend_by(max_inout, |this| {
Expand Down Expand Up @@ -579,6 +579,19 @@ impl Executor<'_> {
// provide us with valid result registers.
unsafe { regs.set(result, *value) };
}
self.stack.values.truncate(caller.frame_offset());
let new_instance = popped_instance.and_then(|_| self.stack.calls.instance());
if let Some(new_instance) = new_instance {
self.cache.update(&mut store.inner, new_instance);

Check warning on line 585 in crates/wasmi/src/engine/executor/instrs/call.rs

View check run for this annotation

Codecov / codecov/patch

crates/wasmi/src/engine/executor/instrs/call.rs#L585

Added line #L585 was not covered by tests
}
if let Some(caller) = self.stack.calls.peek() {
Self::init_call_frame_impl(
&mut self.stack.values,
&mut self.sp,
&mut self.ip,
caller,

Check warning on line 592 in crates/wasmi/src/engine/executor/instrs/call.rs

View check run for this annotation

Codecov / codecov/patch

crates/wasmi/src/engine/executor/instrs/call.rs#L592

Added line #L592 was not covered by tests
);
}
Ok(cf)
}
}
Expand Down

0 comments on commit 9eb1a44

Please sign in to comment.