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

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

Issue 1922493002: Revert of CrossThreadPersistentRegion will only trace objects (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 8 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
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 "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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 66 }
67 Persistent<DummyGCBase>* persistent = reinterpret_cast<Persistent<DummyGCBas e>*>(self); 67 Persistent<DummyGCBase>* persistent = reinterpret_cast<Persistent<DummyGCBas e>*>(self);
68 persistent->clear(); 68 persistent->clear();
69 ASSERT(persistentNode->isUnused()); 69 ASSERT(persistentNode->isUnused());
70 } 70 }
71 71
72 // This function traces all PersistentNodes. If we encounter 72 // This function traces all PersistentNodes. If we encounter
73 // a PersistentNodeSlot that contains only freed PersistentNodes, 73 // a PersistentNodeSlot that contains only freed PersistentNodes,
74 // we delete the PersistentNodeSlot. This function rebuilds the free 74 // we delete the PersistentNodeSlot. This function rebuilds the free
75 // list of PersistentNodes. 75 // list of PersistentNodes.
76 void PersistentRegion::tracePersistentNodes(Visitor* visitor, ShouldTraceCallbac k shouldTrace) 76 void PersistentRegion::tracePersistentNodes(Visitor* visitor)
77 { 77 {
78 size_t debugMarkedObjectSize = ProcessHeap::totalMarkedObjectSize(); 78 size_t debugMarkedObjectSize = ProcessHeap::totalMarkedObjectSize();
79 base::debug::Alias(&debugMarkedObjectSize); 79 base::debug::Alias(&debugMarkedObjectSize);
80 80
81 m_freeListHead = nullptr; 81 m_freeListHead = nullptr;
82 int persistentCount = 0; 82 int persistentCount = 0;
83 PersistentNodeSlots** prevNext = &m_slots; 83 PersistentNodeSlots** prevNext = &m_slots;
84 PersistentNodeSlots* slots = m_slots; 84 PersistentNodeSlots* slots = m_slots;
85 while (slots) { 85 while (slots) {
86 PersistentNode* freeListNext = nullptr; 86 PersistentNode* freeListNext = nullptr;
87 PersistentNode* freeListLast = nullptr; 87 PersistentNode* freeListLast = nullptr;
88 int freeCount = 0; 88 int freeCount = 0;
89 for (int i = 0; i < PersistentNodeSlots::slotCount; ++i) { 89 for (int i = 0; i < PersistentNodeSlots::slotCount; ++i) {
90 PersistentNode* node = &slots->m_slot[i]; 90 PersistentNode* node = &slots->m_slot[i];
91 if (node->isUnused()) { 91 if (node->isUnused()) {
92 if (!freeListNext) 92 if (!freeListNext)
93 freeListLast = node; 93 freeListLast = node;
94 node->setFreeListNext(freeListNext); 94 node->setFreeListNext(freeListNext);
95 freeListNext = node; 95 freeListNext = node;
96 ++freeCount; 96 ++freeCount;
97 } else { 97 } else {
98 node->tracePersistentNode(visitor);
98 ++persistentCount; 99 ++persistentCount;
99 if (!shouldTrace(visitor, node))
100 continue;
101 node->tracePersistentNode(visitor);
102 debugMarkedObjectSize = ProcessHeap::totalMarkedObjectSize(); 100 debugMarkedObjectSize = ProcessHeap::totalMarkedObjectSize();
103 } 101 }
104 } 102 }
105 if (freeCount == PersistentNodeSlots::slotCount) { 103 if (freeCount == PersistentNodeSlots::slotCount) {
106 PersistentNodeSlots* deadSlots = slots; 104 PersistentNodeSlots* deadSlots = slots;
107 *prevNext = slots->m_next; 105 *prevNext = slots->m_next;
108 slots = slots->m_next; 106 slots = slots->m_next;
109 delete deadSlots; 107 delete deadSlots;
110 } else { 108 } else {
111 if (freeListLast) { 109 if (freeListLast) {
112 ASSERT(freeListNext); 110 ASSERT(freeListNext);
113 ASSERT(!freeListLast->freeListNext()); 111 ASSERT(!freeListLast->freeListNext());
114 freeListLast->setFreeListNext(m_freeListHead); 112 freeListLast->setFreeListNext(m_freeListHead);
115 m_freeListHead = freeListNext; 113 m_freeListHead = freeListNext;
116 } 114 }
117 prevNext = &slots->m_next; 115 prevNext = &slots->m_next;
118 slots = slots->m_next; 116 slots = slots->m_next;
119 } 117 }
120 } 118 }
121 ASSERT(persistentCount == m_persistentCount); 119 ASSERT(persistentCount == m_persistentCount);
122 } 120 }
123 121
124 bool CrossThreadPersistentRegion::shouldTracePersistentNode(Visitor* visitor, Pe rsistentNode* node) 122
125 { 123 namespace {
126 CrossThreadPersistent<DummyGCBase>* persistent = reinterpret_cast<CrossThrea dPersistent<DummyGCBase>*>(node->self()); 124 class GCObject final : public GarbageCollected<GCObject> {
127 ASSERT(persistent); 125 public:
128 Address rawObject = reinterpret_cast<Address>(persistent->get()); 126 DEFINE_INLINE_TRACE() { }
129 if (!rawObject) 127 };
130 return false;
131 return &visitor->heap() == &ThreadState::fromObject(rawObject)->heap();
132 } 128 }
133 129
134 void CrossThreadPersistentRegion::prepareForThreadStateTermination(ThreadState* threadState) 130 void CrossThreadPersistentRegion::prepareForThreadStateTermination(ThreadState* threadState)
135 { 131 {
136 // For heaps belonging to a thread that's detaching, any cross-thread persis tents 132 // For heaps belonging to a thread that's detaching, any cross-thread persis tents
137 // pointing into them needs to be disabled. Do that by clearing out the unde rlying 133 // pointing into them needs to be disabled. Do that by clearing out the unde rlying
138 // heap reference. 134 // heap reference.
139 MutexLocker lock(m_mutex); 135 MutexLocker lock(m_mutex);
140 136
141 // TODO(sof): consider ways of reducing overhead. (e.g., tracking number of active 137 // TODO(sof): consider ways of reducing overhead. (e.g., tracking number of active
(...skipping 18 matching lines...) Expand all
160 if (page->orphaned()) 156 if (page->orphaned())
161 continue; 157 continue;
162 if (page->arena()->getThreadState() == threadState) 158 if (page->arena()->getThreadState() == threadState)
163 persistent->clear(); 159 persistent->clear();
164 } 160 }
165 slots = slots->m_next; 161 slots = slots->m_next;
166 } 162 }
167 } 163 }
168 164
169 } // namespace blink 165 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/PersistentNode.h ('k') | third_party/WebKit/Source/platform/heap/Visitor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698