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" |
| 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 Loading... |
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 |
OLD | NEW |