diff options
| author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
|---|---|---|
| committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
| commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
| tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/v8/src/heap/safepoint.cc | |
| parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/v8/src/heap/safepoint.cc')
| -rw-r--r-- | chromium/v8/src/heap/safepoint.cc | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/chromium/v8/src/heap/safepoint.cc b/chromium/v8/src/heap/safepoint.cc index e6ccf642c09..3012413f48c 100644 --- a/chromium/v8/src/heap/safepoint.cc +++ b/chromium/v8/src/heap/safepoint.cc @@ -13,13 +13,16 @@ namespace v8 { namespace internal { GlobalSafepoint::GlobalSafepoint(Heap* heap) - : heap_(heap), local_heaps_head_(nullptr), is_active_(false) {} + : heap_(heap), local_heaps_head_(nullptr), active_safepoint_scopes_(0) {} -void GlobalSafepoint::Start() { StopThreads(); } +void GlobalSafepoint::Start() { EnterSafepointScope(); } -void GlobalSafepoint::End() { ResumeThreads(); } +void GlobalSafepoint::End() { LeaveSafepointScope(); } -void GlobalSafepoint::StopThreads() { +void GlobalSafepoint::EnterSafepointScope() { + if (!FLAG_local_heaps) return; + + if (++active_safepoint_scopes_ > 1) return; local_heaps_mutex_.Lock(); barrier_.Arm(); @@ -37,12 +40,13 @@ void GlobalSafepoint::StopThreads() { current->state_change_.Wait(¤t->state_mutex_); } } - - is_active_ = true; } -void GlobalSafepoint::ResumeThreads() { - is_active_ = false; +void GlobalSafepoint::LeaveSafepointScope() { + if (!FLAG_local_heaps) return; + + DCHECK_GT(active_safepoint_scopes_, 0); + if (--active_safepoint_scopes_ > 0) return; for (LocalHeap* current = local_heaps_head_; current; current = current->next_) { @@ -90,12 +94,10 @@ void GlobalSafepoint::Barrier::Wait() { } SafepointScope::SafepointScope(Heap* heap) : safepoint_(heap->safepoint()) { - if (FLAG_local_heaps) safepoint_->StopThreads(); + safepoint_->EnterSafepointScope(); } -SafepointScope::~SafepointScope() { - if (FLAG_local_heaps) safepoint_->ResumeThreads(); -} +SafepointScope::~SafepointScope() { safepoint_->LeaveSafepointScope(); } void GlobalSafepoint::AddLocalHeap(LocalHeap* local_heap) { base::MutexGuard guard(&local_heaps_mutex_); |
