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; |
89 BasePage* slotPage = reinterpret_cast<BasePage*>(slotPageAddress); | |
sof
2017/02/03 16:04:57
nit: now only used if DCHECK_IS_ON().
| |
90 #if DCHECK_IS_ON() | 90 #if DCHECK_IS_ON() |
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 |
(...skipping 137 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. |
sof
2017/02/02 22:04:41
Could you update the comment to say that the void*
krasin1
2017/02/02 22:19:09
Is it better now?
sof
2017/02/03 16:04:57
Much better, thanks :)
| |
248 HashSet<BasePage*> m_relocatablePages; | 248 HashSet<void*> m_relocatablePages; |
249 | 249 |
250 std::unique_ptr<SparseHeapBitmap> m_interiors; | 250 std::unique_ptr<SparseHeapBitmap> m_interiors; |
251 }; | 251 }; |
252 | 252 |
253 HeapCompact::HeapCompact() | 253 HeapCompact::HeapCompact() |
254 : m_doCompact(false), | 254 : m_doCompact(false), |
255 m_gcCountSinceLastCompaction(0), | 255 m_gcCountSinceLastCompaction(0), |
256 m_freeListSize(0), | 256 m_freeListSize(0), |
257 m_compactableArenas(0u), | 257 m_compactableArenas(0u), |
258 m_freedPages(0), | 258 m_freedPages(0), |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
458 fixups().addCompactingPage(page); | 458 fixups().addCompactingPage(page); |
459 } | 459 } |
460 | 460 |
461 bool HeapCompact::scheduleCompactionGCForTesting(bool value) { | 461 bool HeapCompact::scheduleCompactionGCForTesting(bool value) { |
462 bool current = s_forceCompactionGC; | 462 bool current = s_forceCompactionGC; |
463 s_forceCompactionGC = value; | 463 s_forceCompactionGC = value; |
464 return current; | 464 return current; |
465 } | 465 } |
466 | 466 |
467 } // namespace blink | 467 } // namespace blink |
OLD | NEW |