2019-09-24 12:14:12 +00:00
|
|
|
// Copyright 2019 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.
|
|
|
|
|
2020-01-09 13:00:34 +00:00
|
|
|
// Flags: --no-liftoff --no-force-slow-path
|
2019-09-24 12:14:12 +00:00
|
|
|
|
2021-06-01 12:46:36 +00:00
|
|
|
d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
2019-09-24 12:14:12 +00:00
|
|
|
|
|
|
|
// This constant was chosen as it is the smallest number of cases that still
|
|
|
|
// triggers the input count overflow. The new limit put into place is smaller.
|
|
|
|
const NUM_CASES = 0xfffd;
|
|
|
|
|
|
|
|
(function TestBrTableTooLarge() {
|
|
|
|
let builder = new WasmModuleBuilder();
|
|
|
|
let cases = new Array(NUM_CASES).fill(0);
|
|
|
|
builder.addFunction('main', kSig_v_i)
|
|
|
|
.addBody([].concat([
|
2021-03-22 06:56:01 +00:00
|
|
|
kExprBlock, kWasmVoid,
|
2019-10-08 12:38:48 +00:00
|
|
|
kExprLocalGet, 0,
|
2019-09-24 12:14:12 +00:00
|
|
|
kExprBrTable], wasmSignedLeb(NUM_CASES),
|
|
|
|
cases, [0,
|
|
|
|
kExprEnd
|
|
|
|
])).exportFunc();
|
|
|
|
assertThrows(() => new WebAssembly.Module(builder.toBuffer()),
|
|
|
|
WebAssembly.CompileError, /invalid table count/);
|
|
|
|
})();
|