v8/test/mjsunit/wasm/test-partial-serialization.js
Andreas Haas 4852286284 [wasm] Add --no-wasm-lazy-compilation for tests that need it
Some tests assume that liftoff code is available immediately after
compilation. Add the `--no-wasm-lazy-compilation` flag to these tests
so that they work even after shipping lazy compilation.

R=clemensb@chromium.org

Bug: v8:12926
Change-Id: I839610221390822b90b25e1bef3ae727fa33d1ca
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3804862
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/main@{#82162}
2022-08-03 11:05:45 +00:00

58 lines
1.6 KiB
JavaScript

// Copyright 2021 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 --liftoff --no-wasm-tier-up --expose-gc
// Flags: --no-wasm-dynamic-tiering --no-wasm-lazy-compilation
// Compile functions 0 and 2 with Turbofan, the rest with Liftoff:
// Flags: --wasm-tier-mask-for-testing=5
d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
const num_functions = 5;
function create_builder() {
const builder = new WasmModuleBuilder();
for (let i = 0; i < num_functions; ++i) {
builder.addFunction('f' + i, kSig_i_v)
.addBody(wasmI32Const(i))
.exportFunc();
}
return builder;
}
function check(instance) {
for (let i = 0; i < num_functions; ++i) {
const expect_turbofan = i == 0 || i == 2;
assertEquals(
expect_turbofan, %IsTurboFanFunction(instance.exports['f' + i]),
'function ' + i);
}
}
const wire_bytes = create_builder().toBuffer();
function testTierTestingFlag() {
print(arguments.callee.name);
const module = new WebAssembly.Module(wire_bytes);
const buff = %SerializeWasmModule(module);
const instance = new WebAssembly.Instance(module);
check(instance);
return buff;
};
const serialized_module = testTierTestingFlag();
// Do some GCs to make sure the first module got collected and removed from the
// module cache.
gc();
gc();
gc();
(function testSerializedModule() {
print(arguments.callee.name);
const module = %DeserializeWasmModule(serialized_module, wire_bytes);
const instance = new WebAssembly.Instance(module);
check(instance);
})();