Commit bfbaefd8 authored by Andreas Haas's avatar Andreas Haas Committed by Commit Bot

[wasm] Add estimate size for the WasmInterpreter

The lifetime of the WasmInterpreter is managed by the GC. However, we
did not tell the GC the amount of memory consumed by the interpreter.
Therefore it was possible to fill up memory with instances of the
interpreter without triggering a GC to free memory. With this CL we pass
the size of the stack as an estimate for the size of the interpreter. At
least in the fuzzer the stack is the dominating factor for memory
consumption.

R=clemensh@chromium.org

Bug: chromium:863198
Change-Id: Ic5cb0bd364500bcff793a1fd53d2d0113196dfe2
Reviewed-on: https://chromium-review.googlesource.com/1156385Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54810}
parent 56baf567
......@@ -531,7 +531,12 @@ wasm::InterpreterHandle* GetOrCreateInterpreterHandle(
Isolate* isolate, Handle<WasmDebugInfo> debug_info) {
Handle<Object> handle(debug_info->interpreter_handle(), isolate);
if (handle->IsUndefined(isolate)) {
size_t interpreter_size = 0; // TODO(titzer): estimate size properly.
// Use the maximum stack size to estimate the maximum size of the
// interpreter. The interpreter keeps its own stack internally, and the size
// of the stack should dominate the overall size of the interpreter. We
// multiply by '2' to account for the growing strategy for the backing store
// of the stack.
size_t interpreter_size = FLAG_stack_size * KB * 2;
handle = Managed<wasm::InterpreterHandle>::Allocate(
isolate, interpreter_size, isolate, *debug_info);
debug_info->set_interpreter_handle(*handle);
......@@ -582,7 +587,11 @@ wasm::WasmInterpreter* WasmDebugInfo::SetupForTesting(
Handle<WasmInstanceObject> instance_obj) {
Handle<WasmDebugInfo> debug_info = WasmDebugInfo::New(instance_obj);
Isolate* isolate = instance_obj->GetIsolate();
size_t interpreter_size = 0; // TODO(titzer): estimate size properly.
// Use the maximum stack size to estimate the maximum size of the interpreter.
// The interpreter keeps its own stack internally, and the size of the stack
// should dominate the overall size of the interpreter. We multiply by '2' to
// account for the growing strategy for the backing store of the stack.
size_t interpreter_size = FLAG_stack_size * KB * 2;
auto interp_handle = Managed<wasm::InterpreterHandle>::Allocate(
isolate, interpreter_size, isolate, *debug_info);
debug_info->set_interpreter_handle(*interp_handle);
......
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