Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Cleanup vm stack on function return #1880

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion boa_engine/src/vm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,8 @@ impl Context {
);
}

let start_stack_size = self.vm.stack.len();

while self.vm.frame().pc < self.vm.frame().code.code.len() {
let result = if self.vm.trace {
let mut pc = self.vm.frame().pc;
Expand Down Expand Up @@ -1496,6 +1498,7 @@ impl Context {
match result {
Ok(ShouldExit::True) => {
let result = self.vm.pop();
self.vm.stack.truncate(start_stack_size);
return Ok((result, ReturnType::Normal));
}
Ok(ShouldExit::False) => {}
Expand Down Expand Up @@ -1543,6 +1546,7 @@ impl Context {
self.vm.frame_mut().finally_return = FinallyReturn::Err;
self.vm.push(e);
} else {
self.vm.stack.truncate(start_stack_size);
return Err(e);
}
}
Expand Down Expand Up @@ -1576,6 +1580,8 @@ impl Context {
return Ok((JsValue::undefined(), ReturnType::Normal));
}

Ok((self.vm.pop(), ReturnType::Normal))
let result = self.vm.pop();
self.vm.stack.truncate(start_stack_size);
Ok((result, ReturnType::Normal))
}
}