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

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

Issue 2796233003: [heap] Evacuation for young generation (Closed)
Patch Set: Rebase after disabling black allocation during GCs 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 virtual void SetUp() = 0; 298 virtual void SetUp() = 0;
299 virtual void TearDown() = 0; 299 virtual void TearDown() = 0;
300 virtual void CollectGarbage() = 0; 300 virtual void CollectGarbage() = 0;
301 301
302 inline Heap* heap() const { return heap_; } 302 inline Heap* heap() const { return heap_; }
303 inline Isolate* isolate() { return heap()->isolate(); } 303 inline Isolate* isolate() { return heap()->isolate(); }
304 304
305 protected: 305 protected:
306 explicit MarkCompactCollectorBase(Heap* heap) : heap_(heap) {} 306 explicit MarkCompactCollectorBase(Heap* heap) : heap_(heap) {}
307 307
308 virtual void ProcessMarkingDeque() = 0;
Hannes Payer (out of office) 2017/05/03 14:44:53 Can you move the comments from MarkCompacts to the
Michael Lippautz 2017/05/03 15:08:03 Done.
309 virtual void EmptyMarkingDeque() = 0;
308 virtual void MarkLiveObjects() = 0; 310 virtual void MarkLiveObjects() = 0;
311 virtual void ClearNonLiveReferences() = 0;
312 virtual void EvacuatePrologue() = 0;
313 virtual void EvacuateEpilogue() = 0;
314 virtual void Evacuate() = 0;
315 virtual void EvacuatePagesInParallel() = 0;
316 virtual void UpdatePointersAfterEvacuation() = 0;
309 317
310 // The number of parallel compaction tasks, including the main thread. 318 // The number of parallel compaction tasks, including the main thread.
311 int NumberOfParallelCompactionTasks(int pages, intptr_t live_bytes); 319 int NumberOfParallelCompactionTasks(int pages, intptr_t live_bytes);
312 320
313 template <class Evacuator, class Collector> 321 template <class Evacuator, class Collector>
314 void CreateAndExecuteEvacuationTasks( 322 void CreateAndExecuteEvacuationTasks(
315 Collector* collector, PageParallelJob<EvacuationJobTraits>* job, 323 Collector* collector, PageParallelJob<EvacuationJobTraits>* job,
316 RecordMigratedSlotVisitor* record_visitor, const intptr_t live_bytes, 324 RecordMigratedSlotVisitor* record_visitor,
325 MigrationObserver* migration_observer, const intptr_t live_bytes,
317 const int& abandoned_pages); 326 const int& abandoned_pages);
318 327
319 Heap* heap_; 328 Heap* heap_;
320 }; 329 };
321 330
322 // Collector for young-generation only. 331 // Collector for young-generation only.
323 class MinorMarkCompactCollector final : public MarkCompactCollectorBase { 332 class MinorMarkCompactCollector final : public MarkCompactCollectorBase {
324 public: 333 public:
325 explicit MinorMarkCompactCollector(Heap* heap) 334 explicit MinorMarkCompactCollector(Heap* heap)
326 : MarkCompactCollectorBase(heap), marking_deque_(heap) {} 335 : MarkCompactCollectorBase(heap),
336 marking_deque_(heap),
337 page_parallel_job_semaphore_(0) {}
327 338
328 MarkingState marking_state(HeapObject* object) const override { 339 MarkingState marking_state(HeapObject* object) const override {
329 return MarkingState::External(object); 340 return MarkingState::External(object);
330 } 341 }
331 342
332 MarkingState marking_state(MemoryChunk* chunk) const override { 343 MarkingState marking_state(MemoryChunk* chunk) const override {
333 return MarkingState::External(chunk); 344 return MarkingState::External(chunk);
334 } 345 }
335 346
336 void SetUp() override; 347 void SetUp() override;
337 void TearDown() override; 348 void TearDown() override;
338 void CollectGarbage() override; 349 void CollectGarbage() override;
339 350
340 private: 351 private:
341 class RootMarkingVisitor; 352 class RootMarkingVisitor;
342 353
343 inline MarkingDeque* marking_deque() { return &marking_deque_; } 354 inline MarkingDeque* marking_deque() { return &marking_deque_; }
344 355
345 V8_INLINE void MarkObject(HeapObject* obj); 356 V8_INLINE void MarkObject(HeapObject* obj);
346 V8_INLINE void PushBlack(HeapObject* obj); 357 V8_INLINE void PushBlack(HeapObject* obj);
347 358
348 SlotCallbackResult CheckAndMarkObject(Heap* heap, Address slot_address); 359 SlotCallbackResult CheckAndMarkObject(Heap* heap, Address slot_address);
349 void MarkLiveObjects() override; 360 void MarkLiveObjects() override;
350 void ProcessMarkingDeque(); 361 void ProcessMarkingDeque() override;
351 void EmptyMarkingDeque(); 362 void EmptyMarkingDeque() override;
363 void ClearNonLiveReferences() override;
364
365 void EvacuatePrologue() override;
366 void EvacuateEpilogue() override;
367 void Evacuate() override;
368 void EvacuatePagesInParallel() override;
369 void UpdatePointersAfterEvacuation() override;
352 370
353 MarkingDeque marking_deque_; 371 MarkingDeque marking_deque_;
372 base::Semaphore page_parallel_job_semaphore_;
373 List<Page*> new_space_evacuation_pages_;
354 374
355 friend class StaticYoungGenerationMarkingVisitor; 375 friend class StaticYoungGenerationMarkingVisitor;
356 }; 376 };
357 377
358 // Collector for young and old generation. 378 // Collector for young and old generation.
359 class MarkCompactCollector final : public MarkCompactCollectorBase { 379 class MarkCompactCollector final : public MarkCompactCollectorBase {
360 public: 380 public:
361 class RootMarkingVisitor; 381 class RootMarkingVisitor;
362 382
363 class Sweeper { 383 class Sweeper {
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 594
575 // Mark the heap roots and all objects reachable from them. 595 // Mark the heap roots and all objects reachable from them.
576 void MarkRoots(RootMarkingVisitor* visitor); 596 void MarkRoots(RootMarkingVisitor* visitor);
577 597
578 // Mark the string table specially. References to internalized strings from 598 // Mark the string table specially. References to internalized strings from
579 // the string table are weak. 599 // the string table are weak.
580 void MarkStringTable(RootMarkingVisitor* visitor); 600 void MarkStringTable(RootMarkingVisitor* visitor);
581 601
582 // Mark objects reachable (transitively) from objects in the marking stack 602 // Mark objects reachable (transitively) from objects in the marking stack
583 // or overflowed in the heap. 603 // or overflowed in the heap.
584 void ProcessMarkingDeque(); 604 void ProcessMarkingDeque() override;
585 605
586 // Mark objects reachable (transitively) from objects in the marking stack 606 // Mark objects reachable (transitively) from objects in the marking stack
587 // or overflowed in the heap. This respects references only considered in 607 // or overflowed in the heap. This respects references only considered in
588 // the final atomic marking pause including the following: 608 // the final atomic marking pause including the following:
589 // - Processing of objects reachable through Harmony WeakMaps. 609 // - Processing of objects reachable through Harmony WeakMaps.
590 // - Objects reachable due to host application logic like object groups, 610 // - Objects reachable due to host application logic like object groups,
591 // implicit references' groups, or embedder heap tracing. 611 // implicit references' groups, or embedder heap tracing.
592 void ProcessEphemeralMarking(bool only_process_harmony_weak_collections); 612 void ProcessEphemeralMarking(bool only_process_harmony_weak_collections);
593 613
594 // If the call-site of the top optimized code was not prepared for 614 // If the call-site of the top optimized code was not prepared for
595 // deoptimization, then treat the maps in the code as strong pointers, 615 // deoptimization, then treat the maps in the code as strong pointers,
596 // otherwise a map can die and deoptimize the code. 616 // otherwise a map can die and deoptimize the code.
597 void ProcessTopOptimizedFrame(RootMarkingVisitor* visitor); 617 void ProcessTopOptimizedFrame(RootMarkingVisitor* visitor);
598 618
599 // Collects a list of dependent code from maps embedded in optimize code. 619 // Collects a list of dependent code from maps embedded in optimize code.
600 DependentCode* DependentCodeListFromNonLiveMaps(); 620 DependentCode* DependentCodeListFromNonLiveMaps();
601 621
602 // Mark objects reachable (transitively) from objects in the marking 622 // Mark objects reachable (transitively) from objects in the marking
603 // stack. This function empties the marking stack, but may leave 623 // stack. This function empties the marking stack, but may leave
604 // overflowed objects in the heap, in which case the marking stack's 624 // overflowed objects in the heap, in which case the marking stack's
605 // overflow flag will be set. 625 // overflow flag will be set.
606 void EmptyMarkingDeque(); 626 void EmptyMarkingDeque() override;
607 627
608 // Refill the marking stack with overflowed objects from the heap. This 628 // Refill the marking stack with overflowed objects from the heap. This
609 // function either leaves the marking stack full or clears the overflow 629 // function either leaves the marking stack full or clears the overflow
610 // flag on the marking stack. 630 // flag on the marking stack.
611 void RefillMarkingDeque(); 631 void RefillMarkingDeque();
612 632
613 // Helper methods for refilling the marking stack by discovering grey objects 633 // Helper methods for refilling the marking stack by discovering grey objects
614 // on various pages of the heap. Used by {RefillMarkingDeque} only. 634 // on various pages of the heap. Used by {RefillMarkingDeque} only.
615 template <class T> 635 template <class T>
616 void DiscoverGreyObjectsWithIterator(T* it); 636 void DiscoverGreyObjectsWithIterator(T* it);
617 void DiscoverGreyObjectsOnPage(MemoryChunk* p); 637 void DiscoverGreyObjectsOnPage(MemoryChunk* p);
618 void DiscoverGreyObjectsInSpace(PagedSpace* space); 638 void DiscoverGreyObjectsInSpace(PagedSpace* space);
619 void DiscoverGreyObjectsInNewSpace(); 639 void DiscoverGreyObjectsInNewSpace();
620 640
621 // Callback function for telling whether the object *p is an unmarked 641 // Callback function for telling whether the object *p is an unmarked
622 // heap object. 642 // heap object.
623 static bool IsUnmarkedHeapObject(Object** p); 643 static bool IsUnmarkedHeapObject(Object** p);
624 644
625 // Clear non-live references in weak cells, transition and descriptor arrays, 645 // Clear non-live references in weak cells, transition and descriptor arrays,
626 // and deoptimize dependent code of non-live maps. 646 // and deoptimize dependent code of non-live maps.
627 void ClearNonLiveReferences(); 647 void ClearNonLiveReferences() override;
628 void MarkDependentCodeForDeoptimization(DependentCode* list); 648 void MarkDependentCodeForDeoptimization(DependentCode* list);
629 // Find non-live targets of simple transitions in the given list. Clear 649 // Find non-live targets of simple transitions in the given list. Clear
630 // transitions to non-live targets and if needed trim descriptors arrays. 650 // transitions to non-live targets and if needed trim descriptors arrays.
631 void ClearSimpleMapTransitions(Object* non_live_map_list); 651 void ClearSimpleMapTransitions(Object* non_live_map_list);
632 void ClearSimpleMapTransition(Map* map, Map* dead_transition); 652 void ClearSimpleMapTransition(Map* map, Map* dead_transition);
633 // Compact every array in the global list of transition arrays and 653 // Compact every array in the global list of transition arrays and
634 // trim the corresponding descriptor array if a transition target is non-live. 654 // trim the corresponding descriptor array if a transition target is non-live.
635 void ClearFullMapTransitions(); 655 void ClearFullMapTransitions();
636 bool CompactTransitionArray(Map* map, TransitionArray* transitions, 656 bool CompactTransitionArray(Map* map, TransitionArray* transitions,
637 DescriptorArray* descriptors); 657 DescriptorArray* descriptors);
(...skipping 18 matching lines...) Expand all
656 DependentCode** dependent_code_list); 676 DependentCode** dependent_code_list);
657 void AbortWeakCells(); 677 void AbortWeakCells();
658 678
659 void AbortTransitionArrays(); 679 void AbortTransitionArrays();
660 680
661 // Starts sweeping of spaces by contributing on the main thread and setting 681 // Starts sweeping of spaces by contributing on the main thread and setting
662 // up other pages for sweeping. Does not start sweeper tasks. 682 // up other pages for sweeping. Does not start sweeper tasks.
663 void StartSweepSpaces(); 683 void StartSweepSpaces();
664 void StartSweepSpace(PagedSpace* space); 684 void StartSweepSpace(PagedSpace* space);
665 685
666 void EvacuatePrologue(); 686 void EvacuatePrologue() override;
667 void EvacuateEpilogue(); 687 void EvacuateEpilogue() override;
668 void EvacuatePagesInParallel(); 688 void Evacuate() override;
669 689 void EvacuatePagesInParallel() override;
670 void EvacuateNewSpaceAndCandidates(); 690 void UpdatePointersAfterEvacuation() override;
671
672 void UpdatePointersAfterEvacuation();
673 691
674 void ReleaseEvacuationCandidates(); 692 void ReleaseEvacuationCandidates();
675 693
676 base::Semaphore page_parallel_job_semaphore_; 694 base::Semaphore page_parallel_job_semaphore_;
677 695
678 #ifdef DEBUG 696 #ifdef DEBUG
679 enum CollectorState { 697 enum CollectorState {
680 IDLE, 698 IDLE,
681 PREPARE_GC, 699 PREPARE_GC,
682 MARK_LIVE_OBJECTS, 700 MARK_LIVE_OBJECTS,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 ~EvacuationScope() { collector_->set_evacuation(false); } 753 ~EvacuationScope() { collector_->set_evacuation(false); }
736 754
737 private: 755 private:
738 MarkCompactCollector* collector_; 756 MarkCompactCollector* collector_;
739 }; 757 };
740 758
741 } // namespace internal 759 } // namespace internal
742 } // namespace v8 760 } // namespace v8
743 761
744 #endif // V8_HEAP_MARK_COMPACT_H_ 762 #endif // V8_HEAP_MARK_COMPACT_H_
OLDNEW
« no previous file with comments | « src/heap/gc-tracer.cc ('k') | src/heap/mark-compact.cc » ('j') | src/heap/mark-compact.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698