Chromium Code Reviews| 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 |