Commit e18591df authored by Omer Katz's avatar Omer Katz Committed by Commit Bot

cppgc: Check AssignUnsafe use cases

Assert that the lock is help whenever AssignUnsafe is called.
LazyMutex::AssertHeld resolves to a DCHECK so this should not
regress production performance (other than the call itself
that might not be inlined).

Bug: chromium:1056170
Change-Id: Ic2005d180e6960c24dff7743aa3e0d5e57a63d80
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2716286Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Commit-Queue: Omer Katz <omerkatz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73000}
parent 8cc862ed
...@@ -271,6 +271,7 @@ class BasicCrossThreadPersistent final : public PersistentBase, ...@@ -271,6 +271,7 @@ class BasicCrossThreadPersistent final : public PersistentBase,
} }
void AssignUnsafe(T* ptr) { void AssignUnsafe(T* ptr) {
PersistentRegionLock::AssertLocked();
const void* old_value = GetValue(); const void* old_value = GetValue();
if (IsValid(old_value)) { if (IsValid(old_value)) {
PersistentRegion& region = this->GetPersistentRegion(old_value); PersistentRegion& region = this->GetPersistentRegion(old_value);
......
...@@ -121,6 +121,8 @@ class V8_EXPORT PersistentRegionLock final { ...@@ -121,6 +121,8 @@ class V8_EXPORT PersistentRegionLock final {
public: public:
PersistentRegionLock(); PersistentRegionLock();
~PersistentRegionLock(); ~PersistentRegionLock();
static void AssertLocked();
}; };
} // namespace internal } // namespace internal
......
...@@ -90,5 +90,10 @@ PersistentRegionLock::~PersistentRegionLock() { ...@@ -90,5 +90,10 @@ PersistentRegionLock::~PersistentRegionLock() {
g_process_mutex.Pointer()->Unlock(); g_process_mutex.Pointer()->Unlock();
} }
// static
void PersistentRegionLock::AssertLocked() {
return g_process_mutex.Pointer()->AssertHeld();
}
} // namespace internal } // namespace internal
} // namespace cppgc } // namespace cppgc
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