Commit 8803cc14 authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[d8][predictable] Fix task execution loop

The predictable platform only executed background tasks if at least one
foreground task was executed. Async compilation in Wasm only spawns a
background task though, so that one could be missed.

This CL fixes the loop to also execute background tasks if no foreground
task was executed.

R=ahaas@chromium.org

Bug: v8:11848
Change-Id: Ia0b32427c24a79d5710c784b98528bf431471528
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2944833Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75007}
parent 95e8d867
...@@ -4531,19 +4531,22 @@ bool ProcessMessages( ...@@ -4531,19 +4531,22 @@ bool ProcessMessages(
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
i::SaveAndSwitchContext saved_context(i_isolate, i::Context()); i::SaveAndSwitchContext saved_context(i_isolate, i::Context());
SealHandleScope shs(isolate); SealHandleScope shs(isolate);
while (v8::platform::PumpMessageLoop(g_default_platform, isolate, for (bool ran_tasks = true; ran_tasks;) {
behavior())) { // Execute one foreground task (if one exists), then microtasks.
MicrotasksScope::PerformCheckpoint(isolate); ran_tasks = v8::platform::PumpMessageLoop(g_default_platform, isolate,
behavior());
if (ran_tasks) MicrotasksScope::PerformCheckpoint(isolate);
// In predictable mode we push all background tasks into the foreground
// task queue of the {kProcessGlobalPredictablePlatformWorkerTaskQueue}
// isolate. We execute all background tasks after running one foreground
// task.
if (i::FLAG_verify_predictable) { if (i::FLAG_verify_predictable) {
// In predictable mode we push all background tasks into the foreground
// task queue of the {kProcessGlobalPredictablePlatformWorkerTaskQueue}
// isolate. We execute the tasks after one foreground task has been
// executed.
while (v8::platform::PumpMessageLoop( while (v8::platform::PumpMessageLoop(
g_default_platform, g_default_platform,
kProcessGlobalPredictablePlatformWorkerTaskQueue, kProcessGlobalPredictablePlatformWorkerTaskQueue,
platform::MessageLoopBehavior::kDoNotWait)) { platform::MessageLoopBehavior::kDoNotWait)) {
ran_tasks = true;
} }
} }
} }
...@@ -4552,13 +4555,9 @@ bool ProcessMessages( ...@@ -4552,13 +4555,9 @@ bool ProcessMessages(
50.0 / base::Time::kMillisecondsPerSecond); 50.0 / base::Time::kMillisecondsPerSecond);
} }
bool ran_set_timeout = false; bool ran_set_timeout = false;
if (!RunSetTimeoutCallback(isolate, &ran_set_timeout)) { if (!RunSetTimeoutCallback(isolate, &ran_set_timeout)) return false;
return false;
}
if (!ran_set_timeout) return true; if (!ran_set_timeout) return true;
} }
return true;
} }
} // anonymous namespace } // anonymous namespace
......
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