Commit 82c3254d authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm] Guard against huge code allocations

If a single background thread generates more code than
{kMaxCodeSpaceSize}, we cannot add them as one chunk. This CL adds a
CHECK to guard against that. If we find that this CHECK is hit in the
wild, we need to fix this for real.

R=ahaas@chromium.org

Bug: v8:11339
Change-Id: I549ecd79747bdf14a65b297c01779953e053abf2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2643382Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72247}
parent 2ac866d9
......@@ -1912,6 +1912,11 @@ std::vector<std::unique_ptr<WasmCode>> NativeModule::AddCompiledCode(
code_allocator_.AllocateForCode(this, total_code_space);
// Lookup the jump tables to use once, then use for all code objects.
auto jump_tables = FindJumpTablesForRegion(base::AddressRegionOf(code_space));
// If we happen to have a {total_code_space} which is bigger than
// {kMaxCodeSpaceSize}, we would not find valid jump tables for the whole
// region. If this ever happens, we need to handle this case (by splitting the
// {results} vector in smaller chunks).
CHECK(jump_tables.is_valid());
std::vector<std::unique_ptr<WasmCode>> generated_code;
generated_code.reserve(results.size());
......
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