[vm, gc] Allow initial concurrent marking to proceed even if workers are slow to start up.

This makes the ConcurrentMark task safe to be run by an embedder-provided task runner that doesn't guarantee immediate execution.

Cf. 7aa8716f6d

TEST=ci
Change-Id: I39200bc1c7fa9da458a36ff1b61d3e28c46738ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219844
Reviewed-by: Liam Appelbe <liama@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak 2021-11-11 17:48:41 +00:00 committed by commit-bot@chromium.org
parent 66b2a57e68
commit b8c156dc91

View file

@ -783,13 +783,31 @@ void GCMarker::StartConcurrentMark(PageSpace* page_space) {
ResetSlices();
for (intptr_t i = 0; i < num_tasks; i++) {
ASSERT(visitors_[i] == NULL);
visitors_[i] = new SyncMarkingVisitor(
SyncMarkingVisitor* visitor = new SyncMarkingVisitor(
isolate_group_, page_space, &marking_stack_, &deferred_marking_stack_);
visitors_[i] = visitor;
// Begin marking on a helper thread.
bool result = Dart::thread_pool()->Run<ConcurrentMarkTask>(
this, isolate_group_, page_space, visitors_[i]);
ASSERT(result);
if (i < (num_tasks - 1)) {
// Begin marking on a helper thread.
bool result = Dart::thread_pool()->Run<ConcurrentMarkTask>(
this, isolate_group_, page_space, visitor);
ASSERT(result);
} else {
// Last worker is the main thread, which will only mark roots.
TIMELINE_FUNCTION_GC_DURATION(Thread::Current(), "ConcurrentMark");
int64_t start = OS::GetCurrentMonotonicMicros();
IterateRoots(visitor);
int64_t stop = OS::GetCurrentMonotonicMicros();
visitor->AddMicros(stop - start);
if (FLAG_log_marker_tasks) {
THR_Print("Task marked %" Pd " bytes in %" Pd64 " micros.\n",
visitor->marked_bytes(), visitor->marked_micros());
}
// Continue non-root marking concurrently.
bool result = Dart::thread_pool()->Run<ConcurrentMarkTask>(
this, isolate_group_, page_space, visitor);
ASSERT(result);
}
}
isolate_group_->DeferredMarkLiveTemporaries();