OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/HeapCompact.h" | 5 #include "platform/heap/HeapCompact.h" |
6 | 6 |
7 #include "platform/Histogram.h" | 7 #include "platform/Histogram.h" |
8 #include "platform/RuntimeEnabledFeatures.h" | 8 #include "platform/RuntimeEnabledFeatures.h" |
9 #include "platform/heap/Heap.h" | 9 #include "platform/heap/Heap.h" |
10 #include "platform/heap/SparseHeapBitmap.h" | 10 #include "platform/heap/SparseHeapBitmap.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // |refPage|'s arena isn't in the set. | 76 // |refPage|'s arena isn't in the set. |
77 | 77 |
78 m_fixups.add(reference, slot); | 78 m_fixups.add(reference, slot); |
79 | 79 |
80 // Note: |slot| will reside outside the Oilpan heap if it is a | 80 // Note: |slot| will reside outside the Oilpan heap if it is a |
81 // PersistentHeapCollectionBase. Hence pageFromObject() cannot be | 81 // PersistentHeapCollectionBase. Hence pageFromObject() cannot be |
82 // used, as it sanity checks the |BasePage| it returns. Simply | 82 // used, as it sanity checks the |BasePage| it returns. Simply |
83 // derive the raw BasePage address here and check if it is a member | 83 // derive the raw BasePage address here and check if it is a member |
84 // of the compactable and relocatable page address set. | 84 // of the compactable and relocatable page address set. |
85 Address slotAddress = reinterpret_cast<Address>(slot); | 85 Address slotAddress = reinterpret_cast<Address>(slot); |
86 BasePage* slotPage = reinterpret_cast<BasePage*>( | 86 void* slotPageAddress = blinkPageAddress(slotAddress) + blinkGuardPageSize; |
87 blinkPageAddress(slotAddress) + blinkGuardPageSize); | 87 if (LIKELY(!m_relocatablePages.contains(slotPageAddress))) |
88 if (LIKELY(!m_relocatablePages.contains(slotPage))) | |
89 return; | 88 return; |
90 #if DCHECK_IS_ON() | 89 #if DCHECK_IS_ON() |
| 90 BasePage* slotPage = reinterpret_cast<BasePage*>(slotPageAddress); |
91 DCHECK(slotPage->contains(slotAddress)); | 91 DCHECK(slotPage->contains(slotAddress)); |
92 #endif | 92 #endif |
93 // Unlikely case, the slot resides on a compacting arena's page. | 93 // Unlikely case, the slot resides on a compacting arena's page. |
94 // => It is an 'interior slot' (interior to a movable backing store.) | 94 // => It is an 'interior slot' (interior to a movable backing store.) |
95 // Record it as an interior slot, which entails: | 95 // Record it as an interior slot, which entails: |
96 // | 96 // |
97 // - Storing it in the interior map, which maps the slot to | 97 // - Storing it in the interior map, which maps the slot to |
98 // its (eventual) location. Initially nullptr. | 98 // its (eventual) location. Initially nullptr. |
99 // - Mark it as being interior pointer within the page's | 99 // - Mark it as being interior pointer within the page's |
100 // "interior" bitmap. This bitmap is used when moving a backing | 100 // "interior" bitmap. This bitmap is used when moving a backing |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 HashMap<MovableReference, MovableReference*> m_fixups; | 237 HashMap<MovableReference, MovableReference*> m_fixups; |
238 | 238 |
239 // Map from movable reference to callbacks that need to be invoked | 239 // Map from movable reference to callbacks that need to be invoked |
240 // when the object moves. | 240 // when the object moves. |
241 HashMap<MovableReference, std::pair<void*, MovingObjectCallback>> | 241 HashMap<MovableReference, std::pair<void*, MovingObjectCallback>> |
242 m_fixupCallbacks; | 242 m_fixupCallbacks; |
243 | 243 |
244 // Slot => relocated slot/final location. | 244 // Slot => relocated slot/final location. |
245 HashMap<MovableReference*, Address> m_interiorFixups; | 245 HashMap<MovableReference*, Address> m_interiorFixups; |
246 | 246 |
247 // All pages that are being compacted. | 247 // All pages that are being compacted. The set keeps references to |
248 HashSet<BasePage*> m_relocatablePages; | 248 // BasePage instances. The void* type was selected to allow to check |
| 249 // arbitrary addresses. |
| 250 HashSet<void*> m_relocatablePages; |
249 | 251 |
250 std::unique_ptr<SparseHeapBitmap> m_interiors; | 252 std::unique_ptr<SparseHeapBitmap> m_interiors; |
251 }; | 253 }; |
252 | 254 |
253 HeapCompact::HeapCompact() | 255 HeapCompact::HeapCompact() |
254 : m_doCompact(false), | 256 : m_doCompact(false), |
255 m_gcCountSinceLastCompaction(0), | 257 m_gcCountSinceLastCompaction(0), |
256 m_freeListSize(0), | 258 m_freeListSize(0), |
257 m_compactableArenas(0u), | 259 m_compactableArenas(0u), |
258 m_freedPages(0), | 260 m_freedPages(0), |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 fixups().addCompactingPage(page); | 460 fixups().addCompactingPage(page); |
459 } | 461 } |
460 | 462 |
461 bool HeapCompact::scheduleCompactionGCForTesting(bool value) { | 463 bool HeapCompact::scheduleCompactionGCForTesting(bool value) { |
462 bool current = s_forceCompactionGC; | 464 bool current = s_forceCompactionGC; |
463 s_forceCompactionGC = value; | 465 s_forceCompactionGC = value; |
464 return current; | 466 return current; |
465 } | 467 } |
466 | 468 |
467 } // namespace blink | 469 } // namespace blink |
OLD | NEW |