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-01-22 18:01:34 +00:00
|
|
|
// Flags: --allow-natives-syntax --liftoff --wasm-tier-up --no-stress-opt
|
2020-01-07 17:42:18 +00:00
|
|
|
|
|
|
|
load('test/mjsunit/wasm/wasm-module-builder.js');
|
|
|
|
|
|
|
|
const num_functions = 2;
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
function check(instance) {
|
|
|
|
%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);
|
|
|
|
})();
|
|
|
|
|
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());
|