v8/test/mjsunit/wasm/tier-down-to-liftoff.js
Z Nguyen-Huu 6ce3046e2b [wasm] Add support to tier down/up Wasm NativeModule
This is the first part of switching between Liftoff and Turbofan in
debugging Wasm. In this CL, we implemented the logic to tier down/up all
functions in module.

Bug: v8:9654
Change-Id: Ia25103ca29963afa103c124ff5f159f197c2b2b0
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1970470
Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com>
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65529}
2019-12-19 19:02:18 +00:00

57 lines
1.5 KiB
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: --allow-natives-syntax --wasm-tier-up
load('test/mjsunit/wasm/wasm-module-builder.js');
const num_functions = 2;
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) {
%WasmTierUpFunction(instance, i);
assertFalse(%IsLiftoffFunction(instance.exports['f' + i]));
}
%WasmTierDownModule(instance);
for (let i = 0; i < num_functions; ++i) {
assertTrue(%IsLiftoffFunction(instance.exports['f' + i]));
}
for (let i = 0; i < num_functions; ++i) {
%WasmTierUpFunction(instance, i);
assertTrue(%IsLiftoffFunction(instance.exports['f' + i]));
}
%WasmTierUpModule(instance);
for (let i = 0; i < num_functions; ++i) {
assertFalse(%IsLiftoffFunction(instance.exports['f' + i]));
}
}
(function testTierDownToLiftoff() {
print(arguments.callee.name);
const instance = create_builder().instantiate();
check(instance);
})();
async function testTierDownToLiftoffAsync() {
print(arguments.callee.name);
const instance = await create_builder().asyncInstantiate();
check(instance);
}
assertPromiseResult(testTierDownToLiftoffAsync());