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

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

Issue 1265103003: Invalidate cross-thread persistents on heap termination. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: simplify the invalidation as ref-clearing 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"
9
8 namespace blink { 10 namespace blink {
9 11
10 PersistentRegion::~PersistentRegion() 12 PersistentRegion::~PersistentRegion()
11 { 13 {
12 PersistentNodeSlots* slots = m_slots; 14 PersistentNodeSlots* slots = m_slots;
13 while (slots) { 15 while (slots) {
14 PersistentNodeSlots* deadSlots = slots; 16 PersistentNodeSlots* deadSlots = slots;
15 slots = slots->m_next; 17 slots = slots->m_next;
16 delete deadSlots; 18 delete deadSlots;
17 } 19 }
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 freeListLast->setFreeListNext(m_freeListHead); 85 freeListLast->setFreeListNext(m_freeListHead);
84 m_freeListHead = freeListNext; 86 m_freeListHead = freeListNext;
85 } 87 }
86 prevNext = &slots->m_next; 88 prevNext = &slots->m_next;
87 slots = slots->m_next; 89 slots = slots->m_next;
88 } 90 }
89 } 91 }
90 ASSERT(persistentCount == m_persistentCount); 92 ASSERT(persistentCount == m_persistentCount);
91 } 93 }
92 94
95 void CrossThreadPersistentRegion::prepareForThreadStateTermination(ThreadState* threadState)
96 {
97 // For heaps belonging to a thread that's detaching, any cross-thread persis tents
98 // pointing into them needs to be disabled. Do that by clearing out the unde rlying
99 // heap reference.
100 MutexLocker lock(m_mutex);
101
102 class Object;
103 using GCObject = GarbageCollected<Object>;
104
105 // TODO(sof): consider ways of reducing overhead. (e.g., tracking number of active
106 // CrossThreadPersistent<>s pointing into the heaps of each ThreadState and use that
107 // count to bail out early.)
108 PersistentNodeSlots* slots = m_persistentRegion->m_slots;
109 while (slots) {
110 for (int i = 0; i < PersistentNodeSlots::slotCount; ++i) {
111 if (slots->m_slot[i].isUnused())
112 continue;
113
114 // 'self' is in use, containing the cross-thread persistent wrapper object.
115 CrossThreadPersistent<GCObject>* persistent = reinterpret_cast<Cross ThreadPersistent<GCObject>*>(slots->m_slot[i].self());
116 ASSERT(persistent);
117 void* rawObject = persistent->get();
118 if (!rawObject)
119 continue;
120 BasePage* page = pageFromObject(rawObject);
121 ASSERT(page);
122 if (page->heap()->threadState() == threadState)
123 persistent->clear();
124 }
125 slots = slots->m_next;
126 }
127 }
128
93 } // namespace blink 129 } // 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