Commit e0246541 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[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/+/2206736Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#67865}
parent 7845967a
...@@ -6,7 +6,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js"); ...@@ -6,7 +6,7 @@ load("test/mjsunit/wasm/wasm-module-builder.js");
const num_functions = 200; const num_functions = 200;
// Create a simple Wasm script. // Create a simple Wasm module.
function create_builder(delta = 0) { function create_builder(delta = 0) {
const builder = new WasmModuleBuilder(); const builder = new WasmModuleBuilder();
for (let i = 0; i < num_functions; ++i) { for (let i = 0; i < num_functions; ++i) {
...@@ -37,29 +37,39 @@ function waitForTieredUp(instance) { ...@@ -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(); 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. (function testTierDownToLiftoff() {
async function testTierDownToLiftoffAsync() { // In the 'isolates' test, this test runs in parallel to itself on two
const asyncInstance = await create_builder(num_functions).asyncInstantiate(); // isolates. All checks below should still hold.
const instance = create_builder(0).instantiate();
Debug.enable(); Debug.enable();
checkTieredDown(asyncInstance); checkTieredDown(instance);
const newAsyncInstance = await create_builder(num_functions*3).asyncInstantiate(); const instance2 = create_builder(1).instantiate();
checkTieredDown(newAsyncInstance); checkTieredDown(instance2);
Debug.disable(); Debug.disable();
waitForTieredUp(asyncInstance); // Eventually the instances will be completely tiered up again.
waitForTieredUp(newAsyncInstance); waitForTieredUp(instance);
} waitForTieredUp(instance2);
})();
// 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);
assertPromiseResult(testTierDownToLiftoffAsync()); // 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);
})());
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment