| 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 "platform/heap/Handle.h" | 7 #include "platform/heap/Handle.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 slots->m_next = m_slots; | 44 slots->m_next = m_slots; |
| 45 m_slots = slots; | 45 m_slots = slots; |
| 46 } | 46 } |
| 47 | 47 |
| 48 // This function traces all PersistentNodes. If we encounter | 48 // This function traces all PersistentNodes. If we encounter |
| 49 // a PersistentNodeSlot that contains only freed PersistentNodes, | 49 // a PersistentNodeSlot that contains only freed PersistentNodes, |
| 50 // we delete the PersistentNodeSlot. This function rebuilds the free | 50 // we delete the PersistentNodeSlot. This function rebuilds the free |
| 51 // list of PersistentNodes. | 51 // list of PersistentNodes. |
| 52 void PersistentRegion::tracePersistentNodes(Visitor* visitor) | 52 void PersistentRegion::tracePersistentNodes(Visitor* visitor) |
| 53 { | 53 { |
| 54 size_t debugMarkedObjectSize = Heap::markedObjectSize(); | 54 size_t debugMarkedObjectSize = ProcessHeap::totalMarkedObjectSize(); |
| 55 base::debug::Alias(&debugMarkedObjectSize); | 55 base::debug::Alias(&debugMarkedObjectSize); |
| 56 | 56 |
| 57 m_freeListHead = nullptr; | 57 m_freeListHead = nullptr; |
| 58 int persistentCount = 0; | 58 int persistentCount = 0; |
| 59 PersistentNodeSlots** prevNext = &m_slots; | 59 PersistentNodeSlots** prevNext = &m_slots; |
| 60 PersistentNodeSlots* slots = m_slots; | 60 PersistentNodeSlots* slots = m_slots; |
| 61 while (slots) { | 61 while (slots) { |
| 62 PersistentNode* freeListNext = nullptr; | 62 PersistentNode* freeListNext = nullptr; |
| 63 PersistentNode* freeListLast = nullptr; | 63 PersistentNode* freeListLast = nullptr; |
| 64 int freeCount = 0; | 64 int freeCount = 0; |
| 65 for (int i = 0; i < PersistentNodeSlots::slotCount; ++i) { | 65 for (int i = 0; i < PersistentNodeSlots::slotCount; ++i) { |
| 66 PersistentNode* node = &slots->m_slot[i]; | 66 PersistentNode* node = &slots->m_slot[i]; |
| 67 if (node->isUnused()) { | 67 if (node->isUnused()) { |
| 68 if (!freeListNext) | 68 if (!freeListNext) |
| 69 freeListLast = node; | 69 freeListLast = node; |
| 70 node->setFreeListNext(freeListNext); | 70 node->setFreeListNext(freeListNext); |
| 71 freeListNext = node; | 71 freeListNext = node; |
| 72 ++freeCount; | 72 ++freeCount; |
| 73 } else { | 73 } else { |
| 74 node->tracePersistentNode(visitor); | 74 node->tracePersistentNode(visitor); |
| 75 ++persistentCount; | 75 ++persistentCount; |
| 76 debugMarkedObjectSize = Heap::markedObjectSize(); | 76 debugMarkedObjectSize = ProcessHeap::totalMarkedObjectSize(); |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 if (freeCount == PersistentNodeSlots::slotCount) { | 79 if (freeCount == PersistentNodeSlots::slotCount) { |
| 80 PersistentNodeSlots* deadSlots = slots; | 80 PersistentNodeSlots* deadSlots = slots; |
| 81 *prevNext = slots->m_next; | 81 *prevNext = slots->m_next; |
| 82 slots = slots->m_next; | 82 slots = slots->m_next; |
| 83 delete deadSlots; | 83 delete deadSlots; |
| 84 } else { | 84 } else { |
| 85 if (freeListLast) { | 85 if (freeListLast) { |
| 86 ASSERT(freeListNext); | 86 ASSERT(freeListNext); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 if (page->orphaned()) | 131 if (page->orphaned()) |
| 132 continue; | 132 continue; |
| 133 if (page->arena()->getThreadState() == threadState) | 133 if (page->arena()->getThreadState() == threadState) |
| 134 persistent->clear(); | 134 persistent->clear(); |
| 135 } | 135 } |
| 136 slots = slots->m_next; | 136 slots = slots->m_next; |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 | 139 |
| 140 } // namespace blink | 140 } // namespace blink |
| OLD | NEW |