From e0246541edcd2a5796793b6f5cd249a680a2e057 Mon Sep 17 00:00:00 2001 From: Clemens Backes Date: Mon, 18 May 2020 12:36:06 +0200 Subject: [PATCH] [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 Commit-Queue: Clemens Backes Cr-Commit-Position: refs/heads/master@{#67865} --- .../wasm/debug-enabled-tier-down-wasm.js | 54 +++++++++++-------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/test/debugger/debug/wasm/debug-enabled-tier-down-wasm.js b/test/debugger/debug/wasm/debug-enabled-tier-down-wasm.js index d2d1c5480f..312ae47e7f 100644 --- a/test/debugger/debug/wasm/debug-enabled-tier-down-wasm.js +++ b/test/debugger/debug/wasm/debug-enabled-tier-down-wasm.js @@ -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); +})());