node/deps/v8/test/mjsunit/wasm/enter-debug-state.js
Michaël Zasso f226350fcb deps: update V8 to 11.3.244.4
PR-URL: https://github.com/nodejs/node/pull/47251
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
2023-03-31 14:15:23 +00:00

53 lines
1.4 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
d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
const num_functions = 200;
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 checkForDebugCode(instance) {
for (let i = 0; i < num_functions; ++i) {
// Call the function once because of lazy compilation.
instance.exports['f' + i]();
assertTrue(%IsWasmDebugFunction(instance.exports['f' + i]));
}
}
function check(instance) {
%WasmEnterDebugging();
checkForDebugCode(instance);
for (let i = 0; i < num_functions; ++i) {
%WasmTierUpFunction(instance.exports['f' + i]);
}
checkForDebugCode(instance);
}
(function testTierDownToLiftoff() {
print(arguments.callee.name);
const instance = create_builder().instantiate();
check(instance);
})();
// Use slightly different module for this test to avoid sharing native module.
async function testTierDownToLiftoffAsync() {
print(arguments.callee.name);
const instance = await create_builder(num_functions).asyncInstantiate();
check(instance);
}
assertPromiseResult(testTierDownToLiftoffAsync());