v8/test/mjsunit/wasm/exceptions-export.js
Adam Klein 76ae4f56df [cleanup] Remove Wasm exception-handling runtime flag
It's been enabled by default since Chromium M95.

Also removes duplicate setup code for WebAssembly.Tag JS API
from WasmJs::InstallConditionalFeatures, since we're guaranteed
to set it up via the non-conditional WasmJs::Install.

Bug: v8:8091
Change-Id: Ic500feb655ad4fc0703ed226504847ca6d940537
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3996810
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Commit-Queue: Adam Klein <adamk@chromium.org>
Cr-Commit-Position: refs/heads/main@{#84074}
2022-11-04 22:50:50 +00:00

56 lines
2.2 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.
d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
(function TestExportMultiple() {
print(arguments.callee.name);
let builder = new WasmModuleBuilder();
let except1 = builder.addTag(kSig_v_v);
let except2 = builder.addTag(kSig_v_i);
builder.addExportOfKind("ex1a", kExternalTag, except1);
builder.addExportOfKind("ex1b", kExternalTag, except1);
builder.addExportOfKind("ex2", kExternalTag, except2);
let instance = builder.instantiate();
assertTrue(Object.prototype.hasOwnProperty.call(instance.exports, 'ex1a'));
assertTrue(Object.prototype.hasOwnProperty.call(instance.exports, 'ex1b'));
assertTrue(Object.prototype.hasOwnProperty.call(instance.exports, 'ex2'));
assertSame(instance.exports.ex1a, instance.exports.ex1b);
assertNotSame(instance.exports.ex1a, instance.exports.ex2);
})();
(function TestExportOutOfBounds() {
print(arguments.callee.name);
let builder = new WasmModuleBuilder();
let except = builder.addTag(kSig_v_v);
builder.addExportOfKind("ex_oob", kExternalTag, except + 1);
assertThrows(
() => builder.instantiate(), WebAssembly.CompileError,
'WebAssembly.Module(): tag index 1 out of bounds (1 entry) @+30');
})();
(function TestExportSameNameTwice() {
print(arguments.callee.name);
let builder = new WasmModuleBuilder();
let except = builder.addTag(kSig_v_v);
builder.addExportOfKind("ex", kExternalTag, except);
builder.addExportOfKind("ex", kExternalTag, except);
assertThrows(
() => builder.instantiate(), WebAssembly.CompileError,
'WebAssembly.Module(): Duplicate export name \'ex\' ' +
'for tag 0 and tag 0 @+28');
})();
(function TestExportModuleGetExports() {
print(arguments.callee.name);
let builder = new WasmModuleBuilder();
let except = builder.addTag(kSig_v_v);
builder.addExportOfKind("ex", kExternalTag, except);
let module = new WebAssembly.Module(builder.toBuffer());
let exports = WebAssembly.Module.exports(module);
assertArrayEquals([{ name: "ex", kind: "tag" }], exports);
})();