e33c13c2a2
First step towards the new exception handling proposal: https://github.com/WebAssembly/exception-handling/issues/125 This is essentially a revert of: "[wasm] Switch to new 'catch' and 'br_on_exn' proposal." The changes are: - "catch" instruction takes a tag immediate, - "rethrow" instruction takes a label immediate, - Add "catch_all" instruction, - Remove "br_on_exn" instruction, - Do not push exceptions on the stack, only the encoded values R=clemensb@chromium.org CC=aheejin@chromium.org Bug: v8:8091 Change-Id: Iea4d8d5a5d3ad50693f645e93c13e8de117aa884 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2484514 Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/master@{#71602}
55 lines
2.0 KiB
JavaScript
55 lines
2.0 KiB
JavaScript
// 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.
|
|
|
|
// Flags: --expose-wasm --experimental-wasm-eh --allow-natives-syntax
|
|
|
|
// Note that this test does not pass --experimental-wasm-reftypes on purpose so
|
|
// that we make sure the two flags can be controlled separately/independently.
|
|
|
|
load("test/mjsunit/wasm/wasm-module-builder.js");
|
|
|
|
// First we just test that "exnref" global variables are allowed.
|
|
(function TestGlobalExnRefSupported() {
|
|
print(arguments.callee.name);
|
|
let builder = new WasmModuleBuilder();
|
|
let g = builder.addGlobal(kWasmExnRef);
|
|
builder.addFunction("push_and_drop_exnref", kSig_v_v)
|
|
.addBody([
|
|
kExprGlobalGet, g.index,
|
|
kExprDrop,
|
|
]).exportFunc();
|
|
let instance = builder.instantiate();
|
|
|
|
assertDoesNotThrow(instance.exports.push_and_drop_exnref);
|
|
})();
|
|
|
|
// Test default value that global "exnref" variables are initialized with.
|
|
(function TestGlobalExnRefDefaultValue() {
|
|
print(arguments.callee.name);
|
|
let builder = new WasmModuleBuilder();
|
|
let g = builder.addGlobal(kWasmExnRef);
|
|
builder.addFunction('push_and_return_exnref', kSig_e_v)
|
|
.addBody([kExprGlobalGet, g.index])
|
|
.exportFunc();
|
|
let instance = builder.instantiate();
|
|
|
|
assertEquals(null, instance.exports.push_and_return_exnref());
|
|
})();
|
|
|
|
// Test custom initialization index for a global "exnref" variable.
|
|
(function TestGlobalExnRefInitIndex() {
|
|
print(arguments.callee.name);
|
|
let builder = new WasmModuleBuilder();
|
|
let g1_index = builder.addImportedGlobal("m", "exn", kWasmExnRef);
|
|
let g2 = builder.addGlobal(kWasmExnRef);
|
|
g2.init_index = g1_index; // Initialize {g2} to equal {g1}.
|
|
builder.addFunction('push_and_return_exnref', kSig_e_v)
|
|
.addBody([kExprGlobalGet, g2.index])
|
|
.exportFunc();
|
|
let exception = { x: "my fancy exception" };
|
|
let instance = builder.instantiate({ "m": { "exn": exception }});
|
|
|
|
assertSame(exception, instance.exports.push_and_return_exnref());
|
|
})();
|