Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: Source/platform/heap/PersistentNode.cpp

Issue 1275863002: Oilpan: catch some self-referential leaks (main thread.) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: add stdio.h include Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/platform/heap/PersistentNode.h ('k') | Source/platform/heap/ThreadState.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
10 namespace blink { 14 namespace blink {
11 15
12 PersistentRegion::~PersistentRegion() 16 PersistentRegion::~PersistentRegion()
13 { 17 {
14 PersistentNodeSlots* slots = m_slots; 18 PersistentNodeSlots* slots = m_slots;
15 while (slots) { 19 while (slots) {
16 PersistentNodeSlots* deadSlots = slots; 20 PersistentNodeSlots* deadSlots = slots;
17 slots = slots->m_next; 21 slots = slots->m_next;
18 delete deadSlots; 22 delete deadSlots;
19 } 23 }
20 } 24 }
21 25
22 int PersistentRegion::numberOfPersistents() 26 int PersistentRegion::numberOfPersistents()
23 { 27 {
24 int persistentCount = 0; 28 int persistentCount = 0;
25 for (PersistentNodeSlots* slots = m_slots; slots; slots = slots->m_next) { 29 for (PersistentNodeSlots* slots = m_slots; slots; slots = slots->m_next) {
26 for (int i = 0; i < PersistentNodeSlots::slotCount; ++i) { 30 for (int i = 0; i < PersistentNodeSlots::slotCount; ++i) {
27 if (!slots->m_slot[i].isUnused()) 31 if (!slots->m_slot[i].isUnused())
28 ++persistentCount; 32 ++persistentCount;
29 } 33 }
30 } 34 }
31 ASSERT(persistentCount == m_persistentCount); 35 ASSERT(persistentCount == m_persistentCount);
32 return persistentCount; 36 return persistentCount;
33 } 37 }
34 38
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
35 void PersistentRegion::ensurePersistentNodeSlots(void* self, TraceCallback trace ) 58 void PersistentRegion::ensurePersistentNodeSlots(void* self, TraceCallback trace )
36 { 59 {
37 ASSERT(!m_freeListHead); 60 ASSERT(!m_freeListHead);
38 PersistentNodeSlots* slots = new PersistentNodeSlots; 61 PersistentNodeSlots* slots = new PersistentNodeSlots;
39 for (int i = 0; i < PersistentNodeSlots::slotCount; ++i) { 62 for (int i = 0; i < PersistentNodeSlots::slotCount; ++i) {
40 PersistentNode* node = &slots->m_slot[i]; 63 PersistentNode* node = &slots->m_slot[i];
41 node->setFreeListNext(m_freeListHead); 64 node->setFreeListNext(m_freeListHead);
42 m_freeListHead = node; 65 m_freeListHead = node;
43 ASSERT(node->isUnused()); 66 ASSERT(node->isUnused());
44 } 67 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 if (page->orphaned()) 147 if (page->orphaned())
125 continue; 148 continue;
126 if (page->heap()->threadState() == threadState) 149 if (page->heap()->threadState() == threadState)
127 persistent->clear(); 150 persistent->clear();
128 } 151 }
129 slots = slots->m_next; 152 slots = slots->m_next;
130 } 153 }
131 } 154 }
132 155
133 } // namespace blink 156 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/heap/PersistentNode.h ('k') | Source/platform/heap/ThreadState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698