| 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 "config.h" | 5 #include "config.h" |
| 6 #include "platform/heap/PersistentNode.h" | 6 #include "platform/heap/PersistentNode.h" |
| 7 | 7 |
| 8 #include "platform/heap/Handle.h" | 8 #include "platform/heap/Handle.h" |
| 9 | 9 |
| 10 #ifndef NDEBUG | |
| 11 #include <stdio.h> | |
| 12 #endif | |
| 13 | |
| 14 namespace blink { | 10 namespace blink { |
| 15 | 11 |
| 16 PersistentRegion::~PersistentRegion() | 12 PersistentRegion::~PersistentRegion() |
| 17 { | 13 { |
| 18 PersistentNodeSlots* slots = m_slots; | 14 PersistentNodeSlots* slots = m_slots; |
| 19 while (slots) { | 15 while (slots) { |
| 20 PersistentNodeSlots* deadSlots = slots; | 16 PersistentNodeSlots* deadSlots = slots; |
| 21 slots = slots->m_next; | 17 slots = slots->m_next; |
| 22 delete deadSlots; | 18 delete deadSlots; |
| 23 } | 19 } |
| 24 } | 20 } |
| 25 | 21 |
| 26 int PersistentRegion::numberOfPersistents() | 22 int PersistentRegion::numberOfPersistents() |
| 27 { | 23 { |
| 28 int persistentCount = 0; | 24 int persistentCount = 0; |
| 29 for (PersistentNodeSlots* slots = m_slots; slots; slots = slots->m_next) { | 25 for (PersistentNodeSlots* slots = m_slots; slots; slots = slots->m_next) { |
| 30 for (int i = 0; i < PersistentNodeSlots::slotCount; ++i) { | 26 for (int i = 0; i < PersistentNodeSlots::slotCount; ++i) { |
| 31 if (!slots->m_slot[i].isUnused()) | 27 if (!slots->m_slot[i].isUnused()) |
| 32 ++persistentCount; | 28 ++persistentCount; |
| 33 } | 29 } |
| 34 } | 30 } |
| 35 ASSERT(persistentCount == m_persistentCount); | 31 ASSERT(persistentCount == m_persistentCount); |
| 36 return persistentCount; | 32 return persistentCount; |
| 37 } | 33 } |
| 38 | 34 |
| 39 #ifndef NDEBUG | |
| 40 void PersistentRegion::dumpLivePersistents() | |
| 41 { | |
| 42 class Object; | |
| 43 using GCObject = GarbageCollected<Object>; | |
| 44 | |
| 45 fprintf(stderr, "Live Persistent(heap object, trace method):\n"); | |
| 46 for (PersistentNodeSlots* slots = m_slots; slots; slots = slots->m_next) { | |
| 47 for (int i = 0; i < PersistentNodeSlots::slotCount; ++i) { | |
| 48 if (!slots->m_slot[i].isUnused()) { | |
| 49 Persistent<GCObject>* persistent = reinterpret_cast<Persistent<G
CObject>*>(slots->m_slot[i].self()); | |
| 50 ASSERT(persistent); | |
| 51 fprintf(stderr, "%p => (%p, %p)\n", persistent, persistent->get(
), slots->m_slot[i].traceCallback()); | |
| 52 } | |
| 53 } | |
| 54 } | |
| 55 } | |
| 56 #endif | |
| 57 | |
| 58 void PersistentRegion::ensurePersistentNodeSlots(void* self, TraceCallback trace
) | 35 void PersistentRegion::ensurePersistentNodeSlots(void* self, TraceCallback trace
) |
| 59 { | 36 { |
| 60 ASSERT(!m_freeListHead); | 37 ASSERT(!m_freeListHead); |
| 61 PersistentNodeSlots* slots = new PersistentNodeSlots; | 38 PersistentNodeSlots* slots = new PersistentNodeSlots; |
| 62 for (int i = 0; i < PersistentNodeSlots::slotCount; ++i) { | 39 for (int i = 0; i < PersistentNodeSlots::slotCount; ++i) { |
| 63 PersistentNode* node = &slots->m_slot[i]; | 40 PersistentNode* node = &slots->m_slot[i]; |
| 64 node->setFreeListNext(m_freeListHead); | 41 node->setFreeListNext(m_freeListHead); |
| 65 m_freeListHead = node; | 42 m_freeListHead = node; |
| 66 ASSERT(node->isUnused()); | 43 ASSERT(node->isUnused()); |
| 67 } | 44 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 if (page->orphaned()) | 124 if (page->orphaned()) |
| 148 continue; | 125 continue; |
| 149 if (page->heap()->threadState() == threadState) | 126 if (page->heap()->threadState() == threadState) |
| 150 persistent->clear(); | 127 persistent->clear(); |
| 151 } | 128 } |
| 152 slots = slots->m_next; | 129 slots = slots->m_next; |
| 153 } | 130 } |
| 154 } | 131 } |
| 155 | 132 |
| 156 } // namespace blink | 133 } // namespace blink |
| OLD | NEW |