[heap] Make RegisterStrongRoots thread-safe

CanonicalHandleScope is now also used on background threads. Therefore
Heap::RegisterStrongRoots and Heap::UnregisterStrongRoots are not
exclusively used on the main thread anymore. Simply protect this list
with a mutex.

Bug: v8:10315, v8:10814
Change-Id: Id08269c9f7fecae8c570ab711c522d111b06b005
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2364503
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69488}
This commit is contained in:
Dominik Inführ 2020-08-19 18:11:55 +02:00 committed by Commit Bot
parent 536092f779
commit a61393a332
2 changed files with 3 additions and 0 deletions

View File

@ -6185,6 +6185,7 @@ size_t Heap::OldArrayBufferBytes() {
}
void Heap::RegisterStrongRoots(FullObjectSlot start, FullObjectSlot end) {
base::MutexGuard guard(&strong_roots_mutex_);
StrongRootsList* list = new StrongRootsList();
list->next = strong_roots_list_;
list->start = start;
@ -6193,6 +6194,7 @@ void Heap::RegisterStrongRoots(FullObjectSlot start, FullObjectSlot end) {
}
void Heap::UnregisterStrongRoots(FullObjectSlot start) {
base::MutexGuard guard(&strong_roots_mutex_);
StrongRootsList* prev = nullptr;
StrongRootsList* list = strong_roots_list_;
while (list != nullptr) {

View File

@ -2200,6 +2200,7 @@ class Heap {
std::unique_ptr<LocalEmbedderHeapTracer> local_embedder_heap_tracer_;
std::unique_ptr<MarkingBarrier> marking_barrier_;
StrongRootsList* strong_roots_list_ = nullptr;
base::Mutex strong_roots_mutex_;
bool need_to_remove_stress_concurrent_allocation_observer_ = false;