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

Unified Diff: Source/platform/heap/PersistentNode.h

Issue 1265103003: Invalidate cross-thread persistents on heap termination. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: clarify comments + style tweaks Created 5 years, 5 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
Index: Source/platform/heap/PersistentNode.h
diff --git a/Source/platform/heap/PersistentNode.h b/Source/platform/heap/PersistentNode.h
index fa18fa32cff10145a0f7fe1bd0dece9d240dd449..1fae6119f9893007943df7fe7571dd238db99bfb 100644
--- a/Source/platform/heap/PersistentNode.h
+++ b/Source/platform/heap/PersistentNode.h
@@ -44,6 +44,7 @@ public:
// TraceMethodDelegate in Visitor.h for how this is done.
void tracePersistentNode(Visitor* visitor)
{
+ ASSERT(isValid());
ASSERT(!isUnused());
ASSERT(m_trace);
m_trace(visitor, m_self);
@@ -77,6 +78,21 @@ public:
return !m_trace;
}
+ bool isValid() const
+ {
+ return !(reinterpret_cast<uintptr_t>(m_self) & 0x1);
+ }
+
+ void invalidate()
+ {
+ m_self = reinterpret_cast<Address>(reinterpret_cast<uintptr_t>(m_self) | 0x1);
haraken 2015/08/03 00:45:25 Or I'd prefer just clearing the pointer. The seman
sof 2015/08/03 08:30:04 Can do that instead, that is, clear out the underl
+ }
+
+ void* self() const
+ {
+ return m_self;
+ }
+
private:
// If this PersistentNode is in use:
// - m_self points to the corresponding Persistent handle.
@@ -94,6 +110,7 @@ private:
PersistentNodeSlots* m_next;
PersistentNode m_slot[slotCount];
friend class PersistentRegion;
+ friend class CrossThreadPersistentRegion;
};
// PersistentRegion provides a region of PersistentNodes. PersistentRegion
@@ -139,6 +156,8 @@ public:
int numberOfPersistents();
private:
+ friend CrossThreadPersistentRegion;
+
void ensurePersistentNodeSlots(void*, TraceCallback);
PersistentNode* m_freeListHead;
@@ -170,6 +189,8 @@ public:
m_persistentRegion->tracePersistentNodes(visitor);
}
+ void prepareForThreadStateTermination(ThreadState*);
+
private:
// We don't make CrossThreadPersistentRegion inherit from PersistentRegion
// because we don't want to virtualize performance-sensitive methods

Powered by Google App Engine
This is Rietveld 408576698