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

Side by Side Diff: src/heap/mark-compact.h

Issue 2855143003: [heap] Minor MC: Implement page moving (Closed)
Patch Set: Polishing Created 3 years, 7 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project 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 #ifndef V8_HEAP_MARK_COMPACT_H_ 5 #ifndef V8_HEAP_MARK_COMPACT_H_
6 #define V8_HEAP_MARK_COMPACT_H_ 6 #define V8_HEAP_MARK_COMPACT_H_
7 7
8 #include <deque> 8 #include <deque>
9 9
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 // for visited objects are cleared for each successfully visited object. 270 // for visited objects are cleared for each successfully visited object.
271 template <class Visitor> 271 template <class Visitor>
272 bool VisitBlackObjects(MemoryChunk* chunk, const MarkingState& state, 272 bool VisitBlackObjects(MemoryChunk* chunk, const MarkingState& state,
273 Visitor* visitor, IterationMode iteration_mode); 273 Visitor* visitor, IterationMode iteration_mode);
274 274
275 private: 275 private:
276 void RecomputeLiveBytes(MemoryChunk* chunk, const MarkingState& state); 276 void RecomputeLiveBytes(MemoryChunk* chunk, const MarkingState& state);
277 }; 277 };
278 278
279 enum PageEvacuationMode { NEW_TO_NEW, NEW_TO_OLD }; 279 enum PageEvacuationMode { NEW_TO_NEW, NEW_TO_OLD };
280 enum FreeSpaceTreatmentMode { IGNORE_FREE_SPACE, ZAP_FREE_SPACE };
281 enum MarkingTreatmentMode { KEEP, CLEAR };
280 282
281 // Base class for minor and full MC collectors. 283 // Base class for minor and full MC collectors.
282 class MarkCompactCollectorBase { 284 class MarkCompactCollectorBase {
283 public: 285 public:
284 virtual ~MarkCompactCollectorBase() {} 286 virtual ~MarkCompactCollectorBase() {}
285 287
286 // Note: Make sure to refer to the instances by their concrete collector 288 // Note: Make sure to refer to the instances by their concrete collector
287 // type to avoid vtable lookups marking state methods when used in hot paths. 289 // type to avoid vtable lookups marking state methods when used in hot paths.
288 virtual MarkingState marking_state(HeapObject* object) const = 0; 290 virtual MarkingState marking_state(HeapObject* object) const = 0;
289 virtual MarkingState marking_state(MemoryChunk* chunk) const = 0; 291 virtual MarkingState marking_state(MemoryChunk* chunk) const = 0;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 } 340 }
339 341
340 MarkingState marking_state(MemoryChunk* chunk) const override { 342 MarkingState marking_state(MemoryChunk* chunk) const override {
341 return MarkingState::External(chunk); 343 return MarkingState::External(chunk);
342 } 344 }
343 345
344 void SetUp() override; 346 void SetUp() override;
345 void TearDown() override; 347 void TearDown() override;
346 void CollectGarbage() override; 348 void CollectGarbage() override;
347 349
350 void MakeIterable(Page* page, MarkingTreatmentMode marking_mode,
351 FreeSpaceTreatmentMode free_space_mode);
352 void CleanupSweepToIteratePages();
353
348 private: 354 private:
349 class RootMarkingVisitor; 355 class RootMarkingVisitor;
350 356
351 inline MarkingDeque* marking_deque() { return &marking_deque_; } 357 inline MarkingDeque* marking_deque() { return &marking_deque_; }
352 358
353 V8_INLINE void MarkObject(HeapObject* obj); 359 V8_INLINE void MarkObject(HeapObject* obj);
354 V8_INLINE void PushBlack(HeapObject* obj); 360 V8_INLINE void PushBlack(HeapObject* obj);
355 361
356 SlotCallbackResult CheckAndMarkObject(Heap* heap, Address slot_address); 362 SlotCallbackResult CheckAndMarkObject(Heap* heap, Address slot_address);
357 void MarkLiveObjects() override; 363 void MarkLiveObjects() override;
358 void ProcessMarkingDeque() override; 364 void ProcessMarkingDeque() override;
359 void EmptyMarkingDeque() override; 365 void EmptyMarkingDeque() override;
360 void ClearNonLiveReferences() override; 366 void ClearNonLiveReferences() override;
361 367
362 void EvacuatePrologue() override; 368 void EvacuatePrologue() override;
363 void EvacuateEpilogue() override; 369 void EvacuateEpilogue() override;
364 void Evacuate() override; 370 void Evacuate() override;
365 void EvacuatePagesInParallel() override; 371 void EvacuatePagesInParallel() override;
366 void UpdatePointersAfterEvacuation() override; 372 void UpdatePointersAfterEvacuation() override;
367 373
368 MarkingDeque marking_deque_; 374 MarkingDeque marking_deque_;
369 base::Semaphore page_parallel_job_semaphore_; 375 base::Semaphore page_parallel_job_semaphore_;
370 List<Page*> new_space_evacuation_pages_; 376 List<Page*> new_space_evacuation_pages_;
377 std::vector<Page*> sweep_to_iterate_pages_;
371 378
372 friend class StaticYoungGenerationMarkingVisitor; 379 friend class StaticYoungGenerationMarkingVisitor;
373 }; 380 };
374 381
375 // Collector for young and old generation. 382 // Collector for young and old generation.
376 class MarkCompactCollector final : public MarkCompactCollectorBase { 383 class MarkCompactCollector final : public MarkCompactCollectorBase {
377 public: 384 public:
378 class RootMarkingVisitor; 385 class RootMarkingVisitor;
379 386
380 class Sweeper { 387 class Sweeper {
381 public: 388 public:
382 class SweeperTask; 389 class SweeperTask;
383 390
384 enum FreeListRebuildingMode { REBUILD_FREE_LIST, IGNORE_FREE_LIST }; 391 enum FreeListRebuildingMode { REBUILD_FREE_LIST, IGNORE_FREE_LIST };
385 enum FreeSpaceTreatmentMode { IGNORE_FREE_SPACE, ZAP_FREE_SPACE };
386 enum ClearOldToNewSlotsMode { 392 enum ClearOldToNewSlotsMode {
387 DO_NOT_CLEAR, 393 DO_NOT_CLEAR,
388 CLEAR_REGULAR_SLOTS, 394 CLEAR_REGULAR_SLOTS,
389 CLEAR_TYPED_SLOTS 395 CLEAR_TYPED_SLOTS
390 }; 396 };
391 397
392 typedef std::deque<Page*> SweepingList; 398 typedef std::deque<Page*> SweepingList;
393 typedef List<Page*> SweptList; 399 typedef List<Page*> SweptList;
394 400
395 static int RawSweep(Page* p, FreeListRebuildingMode free_list_mode, 401 static int RawSweep(Page* p, FreeListRebuildingMode free_list_mode,
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 ~EvacuationScope() { collector_->set_evacuation(false); } 751 ~EvacuationScope() { collector_->set_evacuation(false); }
746 752
747 private: 753 private:
748 MarkCompactCollector* collector_; 754 MarkCompactCollector* collector_;
749 }; 755 };
750 756
751 } // namespace internal 757 } // namespace internal
752 } // namespace v8 758 } // namespace v8
753 759
754 #endif // V8_HEAP_MARK_COMPACT_H_ 760 #endif // V8_HEAP_MARK_COMPACT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698