[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/+/2643382
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72247}
This commit is contained in:
Clemens Backes 2021-01-22 10:52:52 +01:00 committed by Commit Bot
parent 2ac866d9e1
commit 82c3254de0

View File

@ -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());