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(
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
i::SaveAndSwitchContext saved_context(i_isolate, i::Context());
SealHandleScope shs(isolate);
while (v8::platform::PumpMessageLoop(g_default_platform, isolate,
behavior())) {
MicrotasksScope::PerformCheckpoint(isolate);
for (bool ran_tasks = true; ran_tasks;) {
// Execute one foreground task (if one exists), then microtasks.
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) {
// 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(
g_default_platform,
kProcessGlobalPredictablePlatformWorkerTaskQueue,
platform::MessageLoopBehavior::kDoNotWait)) {
ran_tasks = true;
}
}
}
......@@ -4552,13 +4555,9 @@ bool ProcessMessages(
50.0 / base::Time::kMillisecondsPerSecond);
}
bool ran_set_timeout = false;
if (!RunSetTimeoutCallback(isolate, &ran_set_timeout)) {
return false;
}
if (!RunSetTimeoutCallback(isolate, &ran_set_timeout)) return false;
if (!ran_set_timeout) return true;
}
return true;
}
} // 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