2020-01-07 17:42:18 +00: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-02-05 17:32:47 +00:00
|
|
|
// Flags: --allow-natives-syntax
|
2020-01-07 17:42:18 +00:00
|
|
|
|
|
|
|
load('test/mjsunit/wasm/wasm-module-builder.js');
|
|
|
|
|
2020-02-05 17:32:47 +00:00
|
|
|
const num_functions = 200;
|
2020-01-07 17:42:18 +00:00
|
|
|
|
2020-01-22 18:01:34 +00:00
|
|
|
function create_builder(delta = 0) {
|
2020-01-07 17:42:18 +00:00
|
|
|
const builder = new WasmModuleBuilder();
|
|
|
|
for (let i = 0; i < num_functions; ++i) {
|
|
|
|
builder.addFunction('f' + i, kSig_i_v)
|
2020-01-22 18:01:34 +00:00
|
|
|
.addBody(wasmI32Const(i + delta))
|
2020-01-07 17:42:18 +00:00
|
|
|
.exportFunc();
|
|
|
|
}
|
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
2020-03-09 16:07:57 +00:00
|
|
|
function checkTieredDown(instance) {
|
2020-01-07 17:42:18 +00:00
|
|
|
for (let i = 0; i < num_functions; ++i) {
|
|
|
|
assertTrue(%IsLiftoffFunction(instance.exports['f' + i]));
|
|
|
|
}
|
2020-03-09 16:07:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function checkTieredUp(instance) {
|
|
|
|
// Busy waiting until all functions are tiered up.
|
|
|
|
let num_liftoff_functions;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function check(instance) {
|
2021-01-19 13:10:06 +00:00
|
|
|
%WasmTierDown();
|
2020-03-09 16:07:57 +00:00
|
|
|
checkTieredDown(instance);
|
2020-01-07 17:42:18 +00:00
|
|
|
|
|
|
|
for (let i = 0; i < num_functions; ++i) {
|
|
|
|
%WasmTierUpFunction(instance, i);
|
|
|
|
}
|
2020-03-09 16:07:57 +00:00
|
|
|
checkTieredDown(instance);
|
2020-01-07 17:42:18 +00:00
|
|
|
|
2021-01-19 13:10:06 +00:00
|
|
|
%WasmTierUp();
|
2020-03-09 16:07:57 +00:00
|
|
|
checkTieredUp(instance);
|
2020-01-07 17:42:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
(function testTierDownToLiftoff() {
|
|
|
|
print(arguments.callee.name);
|
|
|
|
const instance = create_builder().instantiate();
|
|
|
|
check(instance);
|
|
|
|
})();
|
|
|
|
|
2020-01-22 18:01:34 +00:00
|
|
|
// Use slightly different module for this test to avoid sharing native module.
|
2020-01-07 17:42:18 +00:00
|
|
|
async function testTierDownToLiftoffAsync() {
|
|
|
|
print(arguments.callee.name);
|
2020-01-22 18:01:34 +00:00
|
|
|
const instance = await create_builder(num_functions).asyncInstantiate();
|
2020-01-07 17:42:18 +00:00
|
|
|
check(instance);
|
|
|
|
}
|
|
|
|
|
|
|
|
assertPromiseResult(testTierDownToLiftoffAsync());
|