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

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

Issue 1670813004: Avoid data race on CrossThreadPersistents during thread detachment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « third_party/WebKit/Source/platform/heap/Handle.h ('k') | no next file » | 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 "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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // count to bail out early.) 110 // count to bail out early.)
111 PersistentNodeSlots* slots = m_persistentRegion->m_slots; 111 PersistentNodeSlots* slots = m_persistentRegion->m_slots;
112 while (slots) { 112 while (slots) {
113 for (int i = 0; i < PersistentNodeSlots::slotCount; ++i) { 113 for (int i = 0; i < PersistentNodeSlots::slotCount; ++i) {
114 if (slots->m_slot[i].isUnused()) 114 if (slots->m_slot[i].isUnused())
115 continue; 115 continue;
116 116
117 // 'self' is in use, containing the cross-thread persistent wrapper object. 117 // 'self' is in use, containing the cross-thread persistent wrapper object.
118 CrossThreadPersistent<GCObject>* persistent = reinterpret_cast<Cross ThreadPersistent<GCObject>*>(slots->m_slot[i].self()); 118 CrossThreadPersistent<GCObject>* persistent = reinterpret_cast<Cross ThreadPersistent<GCObject>*>(slots->m_slot[i].self());
119 ASSERT(persistent); 119 ASSERT(persistent);
120 void* rawObject = persistent->get(); 120 void* rawObject = persistent->atomicGet();
121 if (!rawObject) 121 if (!rawObject)
122 continue; 122 continue;
123 BasePage* page = pageFromObject(rawObject); 123 BasePage* page = pageFromObject(rawObject);
124 ASSERT(page); 124 ASSERT(page);
125 // The main thread will upon detach just mark its heap pages as orph aned, 125 // The main thread will upon detach just mark its heap pages as orph aned,
126 // but not invalidate its CrossThreadPersistent<>s. 126 // but not invalidate its CrossThreadPersistent<>s.
127 if (page->orphaned()) 127 if (page->orphaned())
128 continue; 128 continue;
129 if (page->heap()->threadState() == threadState) 129 if (page->heap()->threadState() == threadState)
130 persistent->clear(); 130 persistent->clear();
131 } 131 }
132 slots = slots->m_next; 132 slots = slots->m_next;
133 } 133 }
134 } 134 }
135 135
136 } // namespace blink 136 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/heap/Handle.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698