| OLD | NEW |
| 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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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; |
| 438 | 443 |
| 439 // The number of parallel compaction tasks, including the main thread. | 444 // The number of parallel compaction tasks, including the main thread. |
| 440 int NumberOfParallelCompactionTasks(int pages, intptr_t live_bytes); | 445 int NumberOfParallelCompactionTasks(int pages, intptr_t live_bytes); |
| 441 | 446 |
| 447 template <class Evacuator, class Collector> |
| 448 void CreateAndExecuteEvacuationTasks( |
| 449 Collector* collector, PageParallelJob<EvacuationJobTraits>* job, |
| 450 RecordMigratedSlotVisitor* record_visitor, const intptr_t live_bytes, |
| 451 const int& abandoned_pages); |
| 452 |
| 442 Heap* heap_; | 453 Heap* heap_; |
| 443 }; | 454 }; |
| 444 | 455 |
| 445 // Collector for young-generation only. | 456 // Collector for young-generation only. |
| 446 class MinorMarkCompactCollector final : public MarkCompactCollectorBase { | 457 class MinorMarkCompactCollector final : public MarkCompactCollectorBase { |
| 447 public: | 458 public: |
| 448 explicit MinorMarkCompactCollector(Heap* heap) | 459 explicit MinorMarkCompactCollector(Heap* heap) |
| 449 : MarkCompactCollectorBase(heap), marking_deque_(heap) {} | 460 : MarkCompactCollectorBase(heap), marking_deque_(heap) {} |
| 450 | 461 |
| 451 MarkingState marking_state(HeapObject* object) const override { | 462 MarkingState marking_state(HeapObject* object) const override { |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 858 ~EvacuationScope() { collector_->set_evacuation(false); } | 869 ~EvacuationScope() { collector_->set_evacuation(false); } |
| 859 | 870 |
| 860 private: | 871 private: |
| 861 MarkCompactCollector* collector_; | 872 MarkCompactCollector* collector_; |
| 862 }; | 873 }; |
| 863 | 874 |
| 864 } // namespace internal | 875 } // namespace internal |
| 865 } // namespace v8 | 876 } // namespace v8 |
| 866 | 877 |
| 867 #endif // V8_HEAP_MARK_COMPACT_H_ | 878 #endif // V8_HEAP_MARK_COMPACT_H_ |
| OLD | NEW |