node/deps/v8/test/debugger/debug/wasm/debug-enabled-tier-down-wasm.js
Michaël Zasso 1d6adf7432
deps: update V8 to 8.3.110.9
PR-URL: https://github.com/nodejs/node/pull/32831
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2020-05-12 16:12:13 +02:00

63 lines
1.8 KiB
JavaScript

// Copyright 2020 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.
load("test/mjsunit/wasm/wasm-module-builder.js");
const num_functions = 200;
// Create a simple Wasm script.
function create_builder(delta = 0) {
const builder = new WasmModuleBuilder();
for (let i = 0; i < num_functions; ++i) {
builder.addFunction('f' + i, kSig_i_v)
.addBody(wasmI32Const(i + delta))
.exportFunc();
}
return builder;
}
function checkTieredDown(instance) {
for (let i = 0; i < num_functions; ++i) {
assertTrue(%IsLiftoffFunction(instance.exports['f' + i]));
}
}
function checkTieredUp(instance) {
// Busy waiting until all functions are tiered up.
let num_liftoff_functions = 0;
while (true) {
num_liftoff_functions = 0;
for (let i = 0; i < num_functions; ++i) {
if (%IsLiftoffFunction(instance.exports['f' + i])) {
num_liftoff_functions++;
}
}
if (num_liftoff_functions == 0) return;
}
}
const instance = create_builder().instantiate();
const Debug = new DebugWrapper();
Debug.enable();
checkTieredDown(instance);
const newInstance = create_builder(num_functions*2).instantiate();
checkTieredDown(newInstance);
Debug.disable();
checkTieredUp(instance);
checkTieredUp(newInstance);
// Async.
async function testTierDownToLiftoffAsync() {
const asyncInstance = await create_builder(num_functions).asyncInstantiate();
Debug.enable();
checkTieredDown(asyncInstance);
const newAsyncInstance = await create_builder(num_functions*3).asyncInstantiate();
checkTieredDown(newAsyncInstance);
Debug.disable();
checkTieredUp(asyncInstance);
checkTieredUp(newAsyncInstance);
}
assertPromiseResult(testTierDownToLiftoffAsync());