[wasm][debug] Add more tests for async compilation

Asynchronicity can be tricky, in particular if the debugger is enabled
while wasm compilation is happening.
We seem to have open issues in streaming compilation there. As a first
step, which CL adds more tests for async compilation (non-streaming).

R=thibaudm@chromium.org

Bug: v8:10531
Change-Id: Idf16790a91aad437ceb981485512a2f52b791bac
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2206736
Reviewed-by: Thibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67865}
This commit is contained in:
Clemens Backes 2020-05-18 12:36:06 +02:00 committed by Commit Bot
parent 7845967af3
commit e0246541ed

View File

@ -6,7 +6,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
const num_functions = 200;
// Create a simple Wasm script.
// Create a simple Wasm module.
function create_builder(delta = 0) {
const builder = new WasmModuleBuilder();
for (let i = 0; i < num_functions; ++i) {
@ -37,29 +37,39 @@ function waitForTieredUp(instance) {
}
}
// In the 'isolates' test, this test runs in parallel to itself on two isolates.
// All checks below should still hold.
const instance = create_builder().instantiate();
const Debug = new DebugWrapper();
Debug.enable();
checkTieredDown(instance);
const newInstance = create_builder(num_functions*2).instantiate();
checkTieredDown(newInstance);
Debug.disable();
// Eventually the instances will be completely tiered up again.
waitForTieredUp(instance);
waitForTieredUp(newInstance);
// Async.
async function testTierDownToLiftoffAsync() {
const asyncInstance = await create_builder(num_functions).asyncInstantiate();
(function testTierDownToLiftoff() {
// In the 'isolates' test, this test runs in parallel to itself on two
// isolates. All checks below should still hold.
const instance = create_builder(0).instantiate();
Debug.enable();
checkTieredDown(asyncInstance);
const newAsyncInstance = await create_builder(num_functions*3).asyncInstantiate();
checkTieredDown(newAsyncInstance);
checkTieredDown(instance);
const instance2 = create_builder(1).instantiate();
checkTieredDown(instance2);
Debug.disable();
waitForTieredUp(asyncInstance);
waitForTieredUp(newAsyncInstance);
}
// Eventually the instances will be completely tiered up again.
waitForTieredUp(instance);
waitForTieredUp(instance2);
})();
assertPromiseResult(testTierDownToLiftoffAsync());
// Test async compilation.
assertPromiseResult((async function testTierDownToLiftoffAsync() {
// First test: enable the debugger *after* compiling the module.
const instance = await create_builder(2).asyncInstantiate();
Debug.enable();
checkTieredDown(instance);
const instance2 = await create_builder(3).asyncInstantiate();
checkTieredDown(instance2);
Debug.disable();
waitForTieredUp(instance);
waitForTieredUp(instance2);
// Second test: enable the debugger *while* compiling the module.
const instancePromise = create_builder(4).asyncInstantiate();
Debug.enable();
const instance3 = await instancePromise;
checkTieredDown(instance3);
Debug.disable();
waitForTieredUp(instance3);
})());