Index: Source/platform/heap/Handle.h |
diff --git a/Source/platform/heap/Handle.h b/Source/platform/heap/Handle.h |
index 8902360b60d262d265766f7dff6d8ea862c1be04..6fd8a28769fd40ce0fc46657e8a9a38d086175cb 100644 |
--- a/Source/platform/heap/Handle.h |
+++ b/Source/platform/heap/Handle.h |
@@ -138,10 +138,15 @@ public: |
{ |
RawPtr<T> result = m_raw; |
m_raw = nullptr; |
+ updatePersistentNode(); |
return result; |
} |
- void clear() { m_raw = nullptr; } |
+ void clear() |
+ { |
+ m_raw = nullptr; |
+ updatePersistentNode(); |
+ } |
T& operator*() const { return *m_raw; } |
bool operator!() const { return !m_raw; } |
operator T*() const { return m_raw; } |
@@ -153,6 +158,7 @@ public: |
PersistentBase& operator=(U* other) |
{ |
m_raw = other; |
+ updatePersistentNode(); |
checkPointer(); |
recordBacktrace(); |
return *this; |
@@ -161,12 +167,14 @@ public: |
PersistentBase& operator=(std::nullptr_t) |
{ |
m_raw = nullptr; |
+ updatePersistentNode(); |
return *this; |
} |
PersistentBase& operator=(const PersistentBase& other) |
{ |
m_raw = other; |
+ updatePersistentNode(); |
checkPointer(); |
recordBacktrace(); |
return *this; |
@@ -176,6 +184,7 @@ public: |
PersistentBase& operator=(const PersistentBase<U, weaknessConfiguration, crossThreadnessConfiguration>& other) |
{ |
m_raw = other; |
+ updatePersistentNode(); |
checkPointer(); |
recordBacktrace(); |
return *this; |
@@ -185,6 +194,7 @@ public: |
PersistentBase& operator=(const Member<U>& other) |
{ |
m_raw = other; |
+ updatePersistentNode(); |
checkPointer(); |
recordBacktrace(); |
return *this; |
@@ -194,6 +204,7 @@ public: |
PersistentBase& operator=(const RawPtr<U>& other) |
{ |
m_raw = other; |
+ updatePersistentNode(); |
checkPointer(); |
recordBacktrace(); |
return *this; |
@@ -202,8 +213,23 @@ public: |
private: |
NO_LAZY_SWEEP_SANITIZE_ADDRESS |
+ void updatePersistentNode() |
haraken
2015/09/13 12:36:56
Maybe I'd prefer renaming this to assign() and do
sof
2015/09/14 06:34:04
Switched to that scheme; I think it is ok to leave
|
+ { |
+ if (m_raw) { |
+ if (!m_persistentNode) |
+ initialize(); |
+ return; |
+ } |
+ if (m_persistentNode && crossThreadnessConfiguration != CrossThreadPersistentConfiguration) |
+ uninitialize(); |
haraken
2015/09/13 12:36:56
Will this remove the restriction that a (non-cross
sof
2015/09/14 06:34:04
It removes that restriction, as detailed on https:
|
+ } |
+ |
+ NO_LAZY_SWEEP_SANITIZE_ADDRESS |
void initialize() |
{ |
+ if (m_persistentNode || !m_raw) |
haraken
2015/09/13 12:36:56
Is it possible that m_persistentNode is non-null h
sof
2015/09/14 06:34:04
It no longer is, thanks - replaced with an assert.
|
+ return; |
+ |
TraceCallback traceCallback = TraceMethodDelegate<PersistentBase<T, weaknessConfiguration, crossThreadnessConfiguration>, &PersistentBase<T, weaknessConfiguration, crossThreadnessConfiguration>::trace>::trampoline; |
if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration) { |
m_persistentNode = ThreadState::crossThreadPersistentRegion().allocatePersistentNode(this, traceCallback); |
@@ -219,6 +245,9 @@ private: |
void uninitialize() |
{ |
+ if (!m_persistentNode) |
+ return; |
+ |
if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration) { |
ThreadState::crossThreadPersistentRegion().freePersistentNode(m_persistentNode); |
} else { |
@@ -228,6 +257,7 @@ private: |
ASSERT(m_state == state); |
state->persistentRegion()->freePersistentNode(m_persistentNode); |
} |
+ m_persistentNode = nullptr; |
} |
void checkPointer() |
@@ -261,9 +291,9 @@ private: |
#endif |
// m_raw is accessed most, so put it at the first field. |
T* m_raw; |
- PersistentNode* m_persistentNode; |
+ PersistentNode* m_persistentNode = nullptr; |
#if ENABLE(ASSERT) |
- ThreadState* m_state; |
+ ThreadState* m_state = nullptr; |
#endif |
}; |