Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(952)

Unified Diff: third_party/WebKit/Source/platform/heap/Persistent.h

Issue 2094973002: Completely clear weak persistent references. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: undo strongification.. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/heap/Persistent.h
diff --git a/third_party/WebKit/Source/platform/heap/Persistent.h b/third_party/WebKit/Source/platform/heap/Persistent.h
index cf48b4999cb220e2d1de7bad996087414fd7474d..b3cfa449af04c7eb66b9f4e7f90f83f8028ef768 100644
--- a/third_party/WebKit/Source/platform/heap/Persistent.h
+++ b/third_party/WebKit/Source/platform/heap/Persistent.h
@@ -182,11 +182,10 @@ private:
{
static_assert(sizeof(T), "T must be fully defined");
static_assert(IsGarbageCollectedType<T>::value, "T needs to be a garbage collected object");
- if (weaknessConfiguration == WeakPersistentConfiguration) {
- visitor->registerWeakCell(&m_raw);
- } else {
+ if (weaknessConfiguration == WeakPersistentConfiguration)
+ visitor->registerWeakMembers(this, m_raw, handleWeakPersistent);
+ else
visitor->mark(m_raw);
- }
}
NO_LAZY_SWEEP_SANITIZE_ADDRESS
@@ -196,7 +195,7 @@ private:
if (!m_raw || isHashTableDeletedValue())
return;
- TraceCallback traceCallback = TraceMethodDelegate<PersistentBase<T, weaknessConfiguration, crossThreadnessConfiguration>, &PersistentBase<T, weaknessConfiguration, crossThreadnessConfiguration>::tracePersistent>::trampoline;
+ TraceCallback traceCallback = TraceMethodDelegate<PersistentBase, &PersistentBase::tracePersistent>::trampoline;
if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration) {
ProcessHeap::crossThreadPersistentRegion().allocatePersistentNode(m_persistentNode, this, traceCallback);
return;
@@ -245,6 +244,14 @@ private:
#endif
}
+ static void handleWeakPersistent(Visitor* self, void* object)
+ {
+ using Base = PersistentBase<typename std::remove_const<T>::type, weaknessConfiguration, crossThreadnessConfiguration>;
+ Base* persistent = reinterpret_cast<Base*>(object);
+ if (persistent->get() && !ObjectAliveTrait<T>::isHeapObjectAlive(persistent->get()))
+ persistent->clear();
+ }
+
// m_raw is accessed most, so put it at the first field.
T* m_raw;
PersistentNode* m_persistentNode = nullptr;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698