2020-03-05 10:49:19 -08:00
|
|
|
// 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.
|
|
|
|
|
2020-05-05 09:19:02 +02:00
|
|
|
// Flags: --allow-natives-syntax
|
2020-03-05 10:49:19 -08:00
|
|
|
|
2021-08-29 14:20:49 +02:00
|
|
|
d8.file.execute('test/mjsunit/wasm/wasm-module-builder.js');
|
2020-03-05 10:49:19 -08:00
|
|
|
|
2020-05-05 09:19:02 +02:00
|
|
|
const num_functions = 200;
|
2020-03-05 10:49:19 -08:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2023-03-30 12:11:08 +02:00
|
|
|
function checkForDebugCode(instance) {
|
2020-03-05 10:49:19 -08:00
|
|
|
for (let i = 0; i < num_functions; ++i) {
|
2023-03-30 12:11:08 +02:00
|
|
|
// Call the function once because of lazy compilation.
|
|
|
|
instance.exports['f' + i]();
|
|
|
|
assertTrue(%IsWasmDebugFunction(instance.exports['f' + i]));
|
2020-05-05 09:19:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function check(instance) {
|
2023-03-30 12:11:08 +02:00
|
|
|
%WasmEnterDebugging();
|
|
|
|
checkForDebugCode(instance);
|
2020-03-05 10:49:19 -08:00
|
|
|
|
|
|
|
for (let i = 0; i < num_functions; ++i) {
|
2023-03-30 12:11:08 +02:00
|
|
|
%WasmTierUpFunction(instance.exports['f' + i]);
|
2020-03-05 10:49:19 -08:00
|
|
|
}
|
2023-03-30 12:11:08 +02:00
|
|
|
checkForDebugCode(instance);
|
2020-03-05 10:49:19 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
(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());
|