| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/heap/PersistentNode.h" | 5 #include "platform/heap/PersistentNode.h" |
| 6 | 6 |
| 7 #include "base/debug/alias.h" | 7 #include "base/debug/alias.h" |
| 8 #include "platform/heap/Handle.h" | 8 #include "platform/heap/Handle.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 m_freeListHead = node; | 50 m_freeListHead = node; |
| 51 ASSERT(node->isUnused()); | 51 ASSERT(node->isUnused()); |
| 52 } | 52 } |
| 53 slots->m_next = m_slots; | 53 slots->m_next = m_slots; |
| 54 m_slots = slots; | 54 m_slots = slots; |
| 55 } | 55 } |
| 56 | 56 |
| 57 void PersistentRegion::releasePersistentNode( | 57 void PersistentRegion::releasePersistentNode( |
| 58 PersistentNode* persistentNode, | 58 PersistentNode* persistentNode, |
| 59 ThreadState::PersistentClearCallback callback) { | 59 ThreadState::PersistentClearCallback callback) { |
| 60 ASSERT(!persistentNode->isUnused()); | 60 DCHECK(callback); |
| 61 DCHECK(!persistentNode->isUnused()); |
| 61 // 'self' is in use, containing the persistent wrapper object. | 62 // 'self' is in use, containing the persistent wrapper object. |
| 62 void* self = persistentNode->self(); | 63 (*callback)(persistentNode->self(), ThreadState::ReleasePersistent); |
| 63 if (callback) { | 64 DCHECK(persistentNode->isUnused()); |
| 64 (*callback)(self); | |
| 65 ASSERT(persistentNode->isUnused()); | |
| 66 return; | |
| 67 } | |
| 68 Persistent<DummyGCBase>* persistent = | |
| 69 reinterpret_cast<Persistent<DummyGCBase>*>(self); | |
| 70 persistent->clear(); | |
| 71 ASSERT(persistentNode->isUnused()); | |
| 72 } | 65 } |
| 73 | 66 |
| 67 #if defined(LEAK_SANITIZER) |
| 68 void PersistentRegion::clearPersistentNode( |
| 69 PersistentNode* persistentNode, |
| 70 ThreadState::PersistentClearCallback callback) { |
| 71 DCHECK(callback); |
| 72 DCHECK(!persistentNode->isUnused()); |
| 73 // 'self' is in use, containing the persistent wrapper object. |
| 74 (*callback)(persistentNode->self(), ThreadState::ClearPersistent); |
| 75 // Cleared, not freed, so still usable. |
| 76 DCHECK(!persistentNode->isUnused()); |
| 77 } |
| 78 #endif |
| 79 |
| 74 // This function traces all PersistentNodes. If we encounter | 80 // This function traces all PersistentNodes. If we encounter |
| 75 // a PersistentNodeSlot that contains only freed PersistentNodes, | 81 // a PersistentNodeSlot that contains only freed PersistentNodes, |
| 76 // we delete the PersistentNodeSlot. This function rebuilds the free | 82 // we delete the PersistentNodeSlot. This function rebuilds the free |
| 77 // list of PersistentNodes. | 83 // list of PersistentNodes. |
| 78 void PersistentRegion::tracePersistentNodes(Visitor* visitor, | 84 void PersistentRegion::tracePersistentNodes(Visitor* visitor, |
| 79 ShouldTraceCallback shouldTrace) { | 85 ShouldTraceCallback shouldTrace) { |
| 80 size_t debugMarkedObjectSize = ProcessHeap::totalMarkedObjectSize(); | 86 size_t debugMarkedObjectSize = ProcessHeap::totalMarkedObjectSize(); |
| 81 base::debug::Alias(&debugMarkedObjectSize); | 87 base::debug::Alias(&debugMarkedObjectSize); |
| 82 | 88 |
| 83 m_freeListHead = nullptr; | 89 m_freeListHead = nullptr; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 } | 199 } |
| 194 } | 200 } |
| 195 } | 201 } |
| 196 #if DCHECK_IS_ON() | 202 #if DCHECK_IS_ON() |
| 197 DCHECK_EQ(persistentCount, m_persistentRegion->m_persistentCount); | 203 DCHECK_EQ(persistentCount, m_persistentRegion->m_persistentCount); |
| 198 #endif | 204 #endif |
| 199 } | 205 } |
| 200 #endif | 206 #endif |
| 201 | 207 |
| 202 } // namespace blink | 208 } // namespace blink |
| OLD | NEW |