v8/test/mjsunit/wasm/table-limits.js
Sven Sauleau f4e322c3dd [wasm] correct Table limit
Align the Table implementation limits with the JavaScript Embedding
limits defined in the specification (from MAX_UINT32 to 1e7).

Introduce a new helper (max_table_init_entries) that returns the
maximum number of Table entry at initialization. It takes into account
the maximum Table size, which can be passed by a flag.

Bug: v8:8633
Change-Id: Idfa19418e81f478f7886a30876e66c9b216e25ac
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1496971
Commit-Queue: Sven Sauleau <ssauleau@igalia.com>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#60036}
2019-03-05 15:22:20 +00:00

43 lines
1.3 KiB
JavaScript

// Copyright 2018 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-table-size=10
load("test/mjsunit/wasm/wasm-module-builder.js");
// With the flags we set the maximum table size to 10, so 11 is out-of-bounds.
const oob = 11;
(function TestJSTableInitialAboveTheLimit() {
print(arguments.callee.name);
assertThrows(
() => new WebAssembly.Table({ initial: oob, element: "anyfunc" }),
RangeError, /above the upper bound/);
})();
(function TestJSTableMaximumAboveTheLimit() {
print(arguments.callee.name);
assertThrows(
() => new WebAssembly.Table({ initial: 1, maximum: oob, element: "anyfunc" }),
RangeError, /above the upper bound/);
})();
(function TestDecodeTableInitialAboveTheLimit() {
print(arguments.callee.name);
const builder = new WasmModuleBuilder();
builder.setTableBounds(oob);
assertThrows(
() => builder.instantiate(),
WebAssembly.CompileError, /is larger than implementation limit/);
})();
(function TestDecodeTableMaximumAboveTheLimit() {
print(arguments.callee.name);
const builder = new WasmModuleBuilder();
builder.setTableBounds(1, oob);
assertThrows(
() => builder.instantiate(),
WebAssembly.CompileError, /is larger than implementation limit/);
})();