dc748570c8
Add a new --wasm-max-module-size flag to replace the unused and more specific --experimental-wasm-allow-huge-modules flag. The new flag can be used in fuzzers to reduce the maximum allowed module size, avoiding OOM on some systems (like 32-bit ASan builds). R=ahaas@chromium.org Bug: chromium:1334577 Change-Id: I2830d407c5b01be21a47b21392c1210061c40b20 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3695267 Reviewed-by: Andreas Haas <ahaas@chromium.org> Commit-Queue: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/main@{#81102}
51 lines
1.6 KiB
JavaScript
51 lines
1.6 KiB
JavaScript
// Copyright 2022 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
// Flags: --wasm-max-module-size=128
|
|
|
|
d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
|
|
|
let small_binary = (() => {
|
|
let builder = new WasmModuleBuilder();
|
|
builder.addFunction('f', kSig_v_v).addBody(new Array(32).fill(kExprNop));
|
|
return builder.toBuffer();
|
|
})();
|
|
|
|
let big_binary = (() => {
|
|
let builder = new WasmModuleBuilder();
|
|
builder.addFunction('f', kSig_v_v).addBody(new Array(128).fill(kExprNop));
|
|
return builder.toBuffer();
|
|
})();
|
|
|
|
// Check that the sizes of the generated modules are within the expected ranges.
|
|
assertTrue(small_binary.length > 64);
|
|
assertTrue(small_binary.length < 128);
|
|
assertTrue(big_binary.length > 128);
|
|
assertTrue(big_binary.length < 256);
|
|
|
|
let big_error_msg =
|
|
'buffer source exceeds maximum size of 128 (is ' + big_binary.length + ')';
|
|
|
|
(function TestSyncSmallModule() {
|
|
let sync_small_module = new WebAssembly.Module(small_binary);
|
|
assertTrue(sync_small_module instanceof WebAssembly.Module);
|
|
})();
|
|
|
|
assertPromiseResult((async function TestAsyncSmallModule() {
|
|
let async_small_module = await WebAssembly.compile(small_binary);
|
|
assertTrue(async_small_module instanceof WebAssembly.Module);
|
|
})());
|
|
|
|
(function TestSyncBigModule() {
|
|
assertThrows(
|
|
() => new WebAssembly.Module(big_binary), RangeError,
|
|
'WebAssembly.Module(): ' + big_error_msg);
|
|
})();
|
|
|
|
(function TestAsyncBigModule() {
|
|
assertThrowsAsync(
|
|
WebAssembly.compile(big_binary), RangeError,
|
|
'WebAssembly.compile(): ' + big_error_msg);
|
|
})();
|