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

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

Issue 2796233003: [heap] Evacuation for young generation (Closed)
Patch Set: Rebase after smaller refactorings landed 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"
11 #include "src/base/platform/condition-variable.h" 11 #include "src/base/platform/condition-variable.h"
12 #include "src/cancelable-task.h" 12 #include "src/cancelable-task.h"
13 #include "src/heap/marking.h" 13 #include "src/heap/marking.h"
14 #include "src/heap/spaces.h" 14 #include "src/heap/spaces.h"
15 #include "src/heap/store-buffer.h" 15 #include "src/heap/store-buffer.h"
16 16
17 namespace v8 { 17 namespace v8 {
18 namespace internal { 18 namespace internal {
19 19
20 // Forward declarations. 20 // Forward declarations.
21 class CodeFlusher; 21 class CodeFlusher;
22 class EvacuationJobTraits;
22 class HeapObjectVisitor; 23 class HeapObjectVisitor;
23 class MarkCompactCollector; 24 class MarkCompactCollector;
24 class MinorMarkCompactCollector; 25 class MinorMarkCompactCollector;
25 class MarkingVisitor; 26 class MarkingVisitor;
27 class MigrationObserver;
28 template <typename JobTraits>
29 class PageParallelJob;
30 class RecordMigratedSlotVisitor;
26 class ThreadLocalTop; 31 class ThreadLocalTop;
27 32
28 class ObjectMarking : public AllStatic { 33 class ObjectMarking : public AllStatic {
29 public: 34 public:
30 V8_INLINE static MarkBit MarkBitFrom(HeapObject* obj, 35 V8_INLINE static MarkBit MarkBitFrom(HeapObject* obj,
31 const MarkingState& state) { 36 const MarkingState& state) {
32 const Address address = obj->address(); 37 const Address address = obj->address();
33 const MemoryChunk* p = MemoryChunk::FromAddress(address); 38 const MemoryChunk* p = MemoryChunk::FromAddress(address);
34 return state.bitmap()->MarkBitFromIndex(p->AddressToMarkbitIndex(address)); 39 return state.bitmap()->MarkBitFromIndex(p->AddressToMarkbitIndex(address));
35 } 40 }
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 virtual void TearDown() = 0; 433 virtual void TearDown() = 0;
429 virtual void CollectGarbage() = 0; 434 virtual void CollectGarbage() = 0;
430 435
431 inline Heap* heap() const { return heap_; } 436 inline Heap* heap() const { return heap_; }
432 inline Isolate* isolate() { return heap()->isolate(); } 437 inline Isolate* isolate() { return heap()->isolate(); }
433 438
434 protected: 439 protected:
435 explicit MarkCompactCollectorBase(Heap* heap) : heap_(heap) {} 440 explicit MarkCompactCollectorBase(Heap* heap) : heap_(heap) {}
436 441
437 virtual void MarkLiveObjects() = 0; 442 virtual void MarkLiveObjects() = 0;
443 virtual void UpdatePointersAfterEvacuation() = 0;
438 444
439 // The number of parallel compaction tasks, including the main thread. 445 // The number of parallel compaction tasks, including the main thread.
440 int NumberOfParallelCompactionTasks(int pages, intptr_t live_bytes); 446 int NumberOfParallelCompactionTasks(int pages, intptr_t live_bytes);
441 447
448 template <class Evacuator, class Collector>
449 void CreateAndExecuteEvacuationTasks(
450 Collector* collector, PageParallelJob<EvacuationJobTraits>* job,
451 RecordMigratedSlotVisitor* record_visitor, MigrationObserver* observer,
452 const intptr_t live_bytes, const int& abandoned_pages);
453
442 Heap* heap_; 454 Heap* heap_;
443 }; 455 };
444 456
445 // Collector for young-generation only. 457 // Collector for young-generation only.
446 class MinorMarkCompactCollector final : public MarkCompactCollectorBase { 458 class MinorMarkCompactCollector final : public MarkCompactCollectorBase {
447 public: 459 public:
448 explicit MinorMarkCompactCollector(Heap* heap) 460 explicit MinorMarkCompactCollector(Heap* heap)
449 : MarkCompactCollectorBase(heap), marking_deque_(heap) {} 461 : MarkCompactCollectorBase(heap),
462 marking_deque_(heap),
463 page_parallel_job_semaphore_(0) {}
450 464
451 MarkingState marking_state(HeapObject* object) const override { 465 MarkingState marking_state(HeapObject* object) const override {
452 return MarkingState::External(object); 466 return MarkingState::External(object);
453 } 467 }
454 468
455 MarkingState marking_state(MemoryChunk* chunk) const override { 469 MarkingState marking_state(MemoryChunk* chunk) const override {
456 return MarkingState::External(chunk); 470 return MarkingState::External(chunk);
457 } 471 }
458 472
459 void SetUp() override; 473 void SetUp() override;
460 void TearDown() override; 474 void TearDown() override;
461 void CollectGarbage() override; 475 void CollectGarbage() override;
462 476
463 private: 477 private:
464 class RootMarkingVisitor; 478 class RootMarkingVisitor;
465 479
466 inline MarkingDeque* marking_deque() { return &marking_deque_; } 480 inline MarkingDeque* marking_deque() { return &marking_deque_; }
467 481
468 V8_INLINE void MarkObject(HeapObject* obj); 482 V8_INLINE void MarkObject(HeapObject* obj);
469 V8_INLINE void PushBlack(HeapObject* obj); 483 V8_INLINE void PushBlack(HeapObject* obj);
470 484
471 SlotCallbackResult CheckAndMarkObject(Heap* heap, Address slot_address); 485 SlotCallbackResult CheckAndMarkObject(Heap* heap, Address slot_address);
472 void MarkLiveObjects() override; 486 void MarkLiveObjects() override;
473 void ProcessMarkingDeque(); 487 void ProcessMarkingDeque();
474 void EmptyMarkingDeque(); 488 void EmptyMarkingDeque();
489 void ClearNonLiveReferences();
490
491 void EvacuatePrologue();
492 void EvacuateEpilogue();
493 void EvacuateNewSpace(std::vector<HeapObject*>* black_allocation_objects);
494 void EvacuatePagesInParallel(
495 std::vector<HeapObject*>* black_allocation_objects);
496 void UpdatePointersAfterEvacuation() override;
475 497
476 MarkingDeque marking_deque_; 498 MarkingDeque marking_deque_;
499 base::Semaphore page_parallel_job_semaphore_;
500 List<Page*> new_space_evacuation_pages_;
477 501
478 friend class StaticYoungGenerationMarkingVisitor; 502 friend class StaticYoungGenerationMarkingVisitor;
479 }; 503 };
480 504
481 // Collector for young and old generation. 505 // Collector for young and old generation.
482 class MarkCompactCollector final : public MarkCompactCollectorBase { 506 class MarkCompactCollector final : public MarkCompactCollectorBase {
483 public: 507 public:
484 class RootMarkingVisitor; 508 class RootMarkingVisitor;
485 509
486 class Sweeper { 510 class Sweeper {
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 // up other pages for sweeping. Does not start sweeper tasks. 809 // up other pages for sweeping. Does not start sweeper tasks.
786 void StartSweepSpaces(); 810 void StartSweepSpaces();
787 void StartSweepSpace(PagedSpace* space); 811 void StartSweepSpace(PagedSpace* space);
788 812
789 void EvacuatePrologue(); 813 void EvacuatePrologue();
790 void EvacuateEpilogue(); 814 void EvacuateEpilogue();
791 void EvacuatePagesInParallel(); 815 void EvacuatePagesInParallel();
792 816
793 void EvacuateNewSpaceAndCandidates(); 817 void EvacuateNewSpaceAndCandidates();
794 818
795 void UpdatePointersAfterEvacuation(); 819 void UpdatePointersAfterEvacuation() override;
796 820
797 void ReleaseEvacuationCandidates(); 821 void ReleaseEvacuationCandidates();
798 822
799 base::Semaphore page_parallel_job_semaphore_; 823 base::Semaphore page_parallel_job_semaphore_;
800 824
801 #ifdef DEBUG 825 #ifdef DEBUG
802 enum CollectorState { 826 enum CollectorState {
803 IDLE, 827 IDLE,
804 PREPARE_GC, 828 PREPARE_GC,
805 MARK_LIVE_OBJECTS, 829 MARK_LIVE_OBJECTS,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 ~EvacuationScope() { collector_->set_evacuation(false); } 882 ~EvacuationScope() { collector_->set_evacuation(false); }
859 883
860 private: 884 private:
861 MarkCompactCollector* collector_; 885 MarkCompactCollector* collector_;
862 }; 886 };
863 887
864 } // namespace internal 888 } // namespace internal
865 } // namespace v8 889 } // namespace v8
866 890
867 #endif // V8_HEAP_MARK_COMPACT_H_ 891 #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