v8/test/mjsunit/regress/wasm/regress-8896.js
Michael Starzinger 4c60e6b6ac [wasm] Support runtime functions in (de)serializer.
R=ahaas@chromium.org
TEST=mjsunit/regress/wasm/regress-8896
BUG=v8:8896

Change-Id: Id942b95ac05226206a08f0a5e516b9072a1a7f6f
Reviewed-on: https://chromium-review.googlesource.com/c/1491220
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59892}
2019-02-27 11:32:42 +00:00

24 lines
898 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
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);
})();