Commit c0dbde3a authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Add test for "table.set" with incompatible sig.

This adds test coverage for calling "table.set" with a constructed
{WebAssembly.Function} object that uses a signature incompatible with
JavaScript.

R=ahaas@chromium.org
TEST=mjsunit/wasm/type-reflection
BUG=v8:7742

Change-Id: I939d63db85b4eb9cffe5a901efe477397f20f925
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1691917Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62616}
parent b1f408fb
......@@ -294,6 +294,31 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
assertTraps(kTrapFuncSigMismatch, () => instance.exports.main(1));
})();
(function TestFunctionTableSetIncompatibleSig() {
let builder = new WasmModuleBuilder();
let fun = new WebAssembly.Function({parameters:[], results:["i64"]}, _ => 0);
let table = new WebAssembly.Table({element: "anyfunc", initial: 2});
let table_index = builder.addImportedTable("m", "table", 2);
let sig_index = builder.addType(kSig_l_v);
table.set(0, fun);
builder.addFunction('main', kSig_v_i)
.addBody([
kExprGetLocal, 0,
kExprCallIndirect, sig_index, table_index,
kExprDrop
])
.exportFunc();
let instance = builder.instantiate({ m: { table: table }});
assertThrows(
() => instance.exports.main(0), TypeError,
/wasm function signature contains illegal type/);
assertTraps(kTrapFuncSigMismatch, () => instance.exports.main(1));
table.set(1, fun);
assertThrows(
() => instance.exports.main(1), TypeError,
/wasm function signature contains illegal type/);
})();
// TODO(7742): Enable once imported constructed functions are callable.
/*(function TestFunctionModuleImportMatchingSig() {
let builder = new WasmModuleBuilder();
......
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