cf325b5ab1
This reverts commit 60ee70bb40
.
Reason for revert: wasm-api-tests/WasmCapiTest.Serialize starts flaking: https://crbug.com/v8/10784
Original change's description:
> [wasm] Ensure that only TurboFan code is serialized
>
> We have the implicit assumption that Liftoff code will never be
> serialized, and we start relying on that when implementing new features
> (debugging, dynamic tiering).
>
> This CL makes the serializer fail if the module contains any Liftoff
> code. Existing tests are changed to ensure that we fully tiered up
> before serializing a module (similar to the logic in Chromium).
> The "wasm-clone-module" test needs to serialize the module before
> enabling the debugger.
>
> Note that chrome currently only serializes a module after it fully
> tiered up, so that should be fine. If other embedders need the ability
> to serialize a module in an arbitrary state, we will have to fix this
> later. With this CL we will be on the safe side though and (gracefully)
> fail serialization instead of accidentally serializing Liftoff code.
>
> R=ahaas@chromium.org
>
> Bug: v8:10777
> Change-Id: I1245e5f7fda3447a544c1e3525e1239cde759174
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2336799
> Commit-Queue: Clemens Backes <clemensb@chromium.org>
> Reviewed-by: Andreas Haas <ahaas@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#69276}
TBR=ahaas@chromium.org,clemensb@chromium.org
Change-Id: Ic1349375bd562bb0a2724c39c27ef3247461c97b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: v8:10777
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2342845
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69284}
67 lines
2.0 KiB
JavaScript
67 lines
2.0 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.
|
|
|
|
// Flags: --allow-natives-syntax
|
|
|
|
load('test/mjsunit/wasm/wasm-module-builder.js');
|
|
|
|
// The number of locals must be greater than the constant defined here:
|
|
// https://cs.chromium.org/chromium/src/v8/src/compiler/x64/code-generator-x64.cc?l=3146
|
|
const kNumLocals = 128;
|
|
|
|
function varuint32(val) {
|
|
let bytes = [];
|
|
for (let i = 0; i < 4; ++i) {
|
|
bytes.push(0x80 | ((val >> (7 * i)) & 0x7f));
|
|
}
|
|
bytes.push((val >> (7 * 4)) & 0x7f);
|
|
return bytes;
|
|
}
|
|
|
|
// Generate a function that calls the "get" import `kNumLocals` times, and
|
|
// stores each result in a local, then calls the "call" import `kNumLocals`
|
|
// times with the stored local values.
|
|
//
|
|
// The intention is to create a function that has a large stack frame.
|
|
let body = [];
|
|
|
|
for (let i = 0; i < kNumLocals; ++i) {
|
|
body.push(kExprCallFunction, 0, kExprLocalSet, ...varuint32(i));
|
|
}
|
|
|
|
for (let i = 0; i < kNumLocals; ++i) {
|
|
body.push(kExprLocalGet, ...varuint32(i), kExprCallFunction, 1);
|
|
}
|
|
|
|
let builder = new WasmModuleBuilder();
|
|
builder.addImport('mod', 'get', kSig_i_v);
|
|
builder.addImport('mod', 'call', kSig_v_i);
|
|
builder.
|
|
addFunction('main', kSig_v_v).
|
|
addLocals({i32_count: kNumLocals}).
|
|
addBody(body).
|
|
exportAs('main');
|
|
let m1_bytes = builder.toBuffer();
|
|
let m1 = new WebAssembly.Module(m1_bytes);
|
|
|
|
// Serialize the module and postMessage it to another thread.
|
|
let serialized_m1 = %SerializeWasmModule(m1);
|
|
|
|
let worker_onmessage = function(msg) {
|
|
let {serialized_m1, m1_bytes} = msg;
|
|
|
|
let m1_clone = %DeserializeWasmModule(serialized_m1, m1_bytes);
|
|
let imports = {mod: {get: () => 3, call: () => {}}};
|
|
let i2 = new WebAssembly.Instance(m1_clone, imports);
|
|
i2.exports.main();
|
|
postMessage('done');
|
|
}
|
|
let workerScript = "onmessage = " + worker_onmessage.toString();
|
|
|
|
let worker = new Worker(workerScript, {type: 'string'});
|
|
worker.postMessage({serialized_m1, m1_bytes});
|
|
|
|
// Wait for worker to finish.
|
|
print(worker.getMessage());
|