Commit 4c60e6b6 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[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: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59892}
parent ee325289
......@@ -9,6 +9,7 @@
#include "src/objects-inl.h"
#include "src/objects.h"
#include "src/ostreams.h"
#include "src/runtime/runtime.h"
#include "src/snapshot/code-serializer.h"
#include "src/snapshot/serializer-common.h"
#include "src/utils.h"
......@@ -241,15 +242,24 @@ class ExternalReferenceList {
std::end(tags_ordered_by_address_), addr_by_tag_less_than);
}
#define COUNT_EXTERNAL_REFERENCE(name, desc) +1
static constexpr uint32_t kNumExternalReferences =
#define COUNT_EXTERNAL_REFERENCE(name, ...) +1
static constexpr uint32_t kNumExternalReferencesList =
EXTERNAL_REFERENCE_LIST(COUNT_EXTERNAL_REFERENCE);
static constexpr uint32_t kNumExternalReferencesIntrinsics =
FOR_EACH_INTRINSIC(COUNT_EXTERNAL_REFERENCE);
static constexpr uint32_t kNumExternalReferences =
kNumExternalReferencesList + kNumExternalReferencesIntrinsics;
#undef COUNT_EXTERNAL_REFERENCE
#define EXT_REF_ADDR(name, desc) ExternalReference::name().address(),
Address external_reference_by_tag_[kNumExternalReferences] = {
EXTERNAL_REFERENCE_LIST(EXT_REF_ADDR)};
#define EXT_REF_ADDR(name, desc) ExternalReference::name().address(),
EXTERNAL_REFERENCE_LIST(EXT_REF_ADDR)
#undef EXT_REF_ADDR
#define RUNTIME_ADDR(name, ...) \
ExternalReference::Create(Runtime::k##name).address(),
FOR_EACH_INTRINSIC(RUNTIME_ADDR)
#undef RUNTIME_ADDR
};
uint32_t tags_ordered_by_address_[kNumExternalReferences];
DISALLOW_COPY_AND_ASSIGN(ExternalReferenceList);
};
......
// 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);
})();
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