Commit c853d114 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Fix stack size estimate

We were just counting the number of stack elements instead of their
actual memory usage. This limits recursion a lot more and helps
avoiding OOM situations.

R=titzer@chromium.org

Bug: chromium:938739
Change-Id: I0e0ec2949f9fbad9c9e2c8677ec0223d5cd6a24b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1526006Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60264}
parent 277736cf
......@@ -2344,8 +2344,8 @@ class ThreadImpl {
// stack actually lies in zone memory.
const size_t stack_size_limit = FLAG_stack_size * KB;
// Sum up the value stack size and the control stack size.
const size_t current_stack_size =
(sp_ - stack_.get()) + frames_.size() * sizeof(Frame);
const size_t current_stack_size = (sp_ - stack_.get()) * sizeof(*sp_) +
frames_.size() * sizeof(frames_[0]);
if (V8_LIKELY(current_stack_size <= stack_size_limit)) {
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment