v8/test/mjsunit/wasm/tier-down-to-liftoff.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

68 lines
1.7 KiB
JavaScript
Raw Normal View History

// 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
load('test/mjsunit/wasm/wasm-module-builder.js');
const num_functions = 200;
Reland "[wasm] Perform NativeModule tier down in parallel." This is a reland of faccc95b77b3ac9aa9e3ca8843de18fbdd6f2407 Since 1c9bb77de5425f9f1d497d4e5bedc3f68801c836, async jobs use existing entry in native module cache and skip recompilation so we need to fix the test. Original change's description: > Reland "[wasm] Perform NativeModule tier down in parallel." > > This is a reland of 3352fcc900d4c24891c5b4b0a9b3056ea7029909 > > Disable stress-opt for test and check recompilation before clearing > callbacks. > > Original change's description: > > [wasm] Perform NativeModule tier down in parallel. > > > > Reuse logic in {CompileNativeModule} function in module-compiler.cc: > > initialize parallel compile jobs, then wait for them to finish while > > taking part in this compilation. > > > > Bug: v8:9654 > > Change-Id: I9974d9f8b516e9faec716a592c7c0ee9c7077d8e > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1977041 > > Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com> > > Reviewed-by: Clemens Backes <clemensb@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#65763} > > Bug: v8:9654 > Change-Id: I8e8830f05e189596207365b7332a2cc25e493e47 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2002945 > Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com> > Reviewed-by: Clemens Backes <clemensb@chromium.org> > Cr-Commit-Position: refs/heads/master@{#65901} Bug: v8:9654 Change-Id: Ia63b86d4275088d93202046bc9823e6202b7991a Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2012986 Reviewed-by: Clemens Backes <clemensb@chromium.org> Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com> Cr-Commit-Position: refs/heads/master@{#65929}
2020-01-22 18:01:34 +00: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)
Reland "[wasm] Perform NativeModule tier down in parallel." This is a reland of faccc95b77b3ac9aa9e3ca8843de18fbdd6f2407 Since 1c9bb77de5425f9f1d497d4e5bedc3f68801c836, async jobs use existing entry in native module cache and skip recompilation so we need to fix the test. Original change's description: > Reland "[wasm] Perform NativeModule tier down in parallel." > > This is a reland of 3352fcc900d4c24891c5b4b0a9b3056ea7029909 > > Disable stress-opt for test and check recompilation before clearing > callbacks. > > Original change's description: > > [wasm] Perform NativeModule tier down in parallel. > > > > Reuse logic in {CompileNativeModule} function in module-compiler.cc: > > initialize parallel compile jobs, then wait for them to finish while > > taking part in this compilation. > > > > Bug: v8:9654 > > Change-Id: I9974d9f8b516e9faec716a592c7c0ee9c7077d8e > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1977041 > > Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com> > > Reviewed-by: Clemens Backes <clemensb@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#65763} > > Bug: v8:9654 > Change-Id: I8e8830f05e189596207365b7332a2cc25e493e47 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2002945 > Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com> > Reviewed-by: Clemens Backes <clemensb@chromium.org> > Cr-Commit-Position: refs/heads/master@{#65901} Bug: v8:9654 Change-Id: Ia63b86d4275088d93202046bc9823e6202b7991a Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2012986 Reviewed-by: Clemens Backes <clemensb@chromium.org> Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com> Cr-Commit-Position: refs/heads/master@{#65929}
2020-01-22 18:01:34 +00:00
.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;
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) {
%WasmTierDown();
checkTieredDown(instance);
for (let i = 0; i < num_functions; ++i) {
%WasmTierUpFunction(instance, i);
}
checkTieredDown(instance);
%WasmTierUp();
checkTieredUp(instance);
}
(function testTierDownToLiftoff() {
print(arguments.callee.name);
const instance = create_builder().instantiate();
check(instance);
})();
Reland "[wasm] Perform NativeModule tier down in parallel." This is a reland of faccc95b77b3ac9aa9e3ca8843de18fbdd6f2407 Since 1c9bb77de5425f9f1d497d4e5bedc3f68801c836, async jobs use existing entry in native module cache and skip recompilation so we need to fix the test. Original change's description: > Reland "[wasm] Perform NativeModule tier down in parallel." > > This is a reland of 3352fcc900d4c24891c5b4b0a9b3056ea7029909 > > Disable stress-opt for test and check recompilation before clearing > callbacks. > > Original change's description: > > [wasm] Perform NativeModule tier down in parallel. > > > > Reuse logic in {CompileNativeModule} function in module-compiler.cc: > > initialize parallel compile jobs, then wait for them to finish while > > taking part in this compilation. > > > > Bug: v8:9654 > > Change-Id: I9974d9f8b516e9faec716a592c7c0ee9c7077d8e > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1977041 > > Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com> > > Reviewed-by: Clemens Backes <clemensb@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#65763} > > Bug: v8:9654 > Change-Id: I8e8830f05e189596207365b7332a2cc25e493e47 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2002945 > Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com> > Reviewed-by: Clemens Backes <clemensb@chromium.org> > Cr-Commit-Position: refs/heads/master@{#65901} Bug: v8:9654 Change-Id: Ia63b86d4275088d93202046bc9823e6202b7991a Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2012986 Reviewed-by: Clemens Backes <clemensb@chromium.org> Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com> Cr-Commit-Position: refs/heads/master@{#65929}
2020-01-22 18:01:34 +00:00
// Use slightly different module for this test to avoid sharing native module.
async function testTierDownToLiftoffAsync() {
print(arguments.callee.name);
Reland "[wasm] Perform NativeModule tier down in parallel." This is a reland of faccc95b77b3ac9aa9e3ca8843de18fbdd6f2407 Since 1c9bb77de5425f9f1d497d4e5bedc3f68801c836, async jobs use existing entry in native module cache and skip recompilation so we need to fix the test. Original change's description: > Reland "[wasm] Perform NativeModule tier down in parallel." > > This is a reland of 3352fcc900d4c24891c5b4b0a9b3056ea7029909 > > Disable stress-opt for test and check recompilation before clearing > callbacks. > > Original change's description: > > [wasm] Perform NativeModule tier down in parallel. > > > > Reuse logic in {CompileNativeModule} function in module-compiler.cc: > > initialize parallel compile jobs, then wait for them to finish while > > taking part in this compilation. > > > > Bug: v8:9654 > > Change-Id: I9974d9f8b516e9faec716a592c7c0ee9c7077d8e > > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1977041 > > Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com> > > Reviewed-by: Clemens Backes <clemensb@chromium.org> > > Cr-Commit-Position: refs/heads/master@{#65763} > > Bug: v8:9654 > Change-Id: I8e8830f05e189596207365b7332a2cc25e493e47 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2002945 > Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com> > Reviewed-by: Clemens Backes <clemensb@chromium.org> > Cr-Commit-Position: refs/heads/master@{#65901} Bug: v8:9654 Change-Id: Ia63b86d4275088d93202046bc9823e6202b7991a Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2012986 Reviewed-by: Clemens Backes <clemensb@chromium.org> Commit-Queue: Z Nguyen-Huu <duongn@microsoft.com> Cr-Commit-Position: refs/heads/master@{#65929}
2020-01-22 18:01:34 +00:00
const instance = await create_builder(num_functions).asyncInstantiate();
check(instance);
}
assertPromiseResult(testTierDownToLiftoffAsync());