Commit 1592114b authored by Jakob Gruber's avatar Jakob Gruber Committed by V8 LUCI CQ

[heap] Add GC::IsAllowed CHECK to Parked(Shared)MutexGuard ctors

These mutex guards may trigger GC on the slow paths; to detect misuse
(creating these guards inside GC-disallowed scopes) more reliably,
this CL adds

 DCHECK(AllowGarbageCollection::IsAllowed())

to the guard constructors.

Bug: v8:12012
Change-Id: If59514c97ba6cc9bbca3b56559bf2496cafc78d9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3043952Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Commit-Queue: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#75861}
parent 251d741f
......@@ -50,6 +50,7 @@ class V8_NODISCARD ParkedMutexGuard {
: ParkedMutexGuard(local_isolate->heap(), mutex) {}
explicit ParkedMutexGuard(LocalHeap* local_heap, base::Mutex* mutex)
: mutex_(mutex) {
DCHECK(AllowGarbageCollection::IsAllowed());
if (!mutex_->TryLock()) {
ParkedScope scope(local_heap);
mutex_->Lock();
......@@ -74,6 +75,7 @@ class V8_NODISCARD ParkedSharedMutexGuardIf final {
: ParkedSharedMutexGuardIf(local_isolate->heap(), mutex, enable_mutex) {}
ParkedSharedMutexGuardIf(LocalHeap* local_heap, base::SharedMutex* mutex,
bool enable_mutex) {
DCHECK(AllowGarbageCollection::IsAllowed());
DCHECK_IMPLIES(Behavior == base::NullBehavior::kRequireNotNull,
mutex != nullptr);
if (!enable_mutex) return;
......
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