v8/test/mjsunit/regress/wasm/regress-8896.js
Clemens Backes 63946bd50e [liftoff] Add support for throwing exceptions
This is the first part of exception handling support in Liftoff. For
now, the only supported instruction is throw, and only with empty
payload or only i32 values.

R=thibaudm@chromium.org

Bug: v8:11453
Change-Id: I9fdf1328ef46655674a05186fb93216518886d03
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2704659
Reviewed-by: Thibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72871}
2021-02-19 16:32:02 +00:00

26 lines
972 B
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: --experimental-wasm-eh --allow-natives-syntax
// Disable Liftoff so we can serialize the module.
// Flags: --no-liftoff
load("test/mjsunit/wasm/wasm-module-builder.js");
(function TestSerializeDeserializeRuntimeCall() {
var builder = new WasmModuleBuilder();
var except = builder.addException(kSig_v_v);
builder.addFunction("f", kSig_v_v)
.addBody([
kExprThrow, except,
]).exportFunc();
var wire_bytes = builder.toBuffer();
var module = new WebAssembly.Module(wire_bytes);
var instance1 = new WebAssembly.Instance(module);
var serialized = %SerializeWasmModule(module);
module = %DeserializeWasmModule(serialized, wire_bytes);
var instance2 = new WebAssembly.Instance(module);
assertThrows(() => instance2.exports.f(), WebAssembly.RuntimeError);
})();