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_MARK_COMPACT_H_ | 5 #ifndef V8_MARK_COMPACT_H_ |
6 #define V8_MARK_COMPACT_H_ | 6 #define V8_MARK_COMPACT_H_ |
7 | 7 |
8 #include "src/compiler-intrinsics.h" | 8 #include "src/compiler-intrinsics.h" |
9 #include "src/spaces.h" | 9 #include "src/spaces.h" |
10 | 10 |
11 namespace v8 { | 11 namespace v8 { |
12 namespace internal { | 12 namespace internal { |
13 | 13 |
14 // Callback function, returns whether an object is alive. The heap size | 14 // Callback function, returns whether an object is alive. The heap size |
15 // of the object is returned in size. It optionally updates the offset | 15 // of the object is returned in size. It optionally updates the offset |
16 // to the first live object in the page (only used for old and map objects). | 16 // to the first live object in the page (only used for old and map objects). |
17 typedef bool (*IsAliveFunction)(HeapObject* obj, int* size, int* offset); | 17 typedef bool (*IsAliveFunction)(HeapObject* obj, int* size, int* offset); |
18 | 18 |
19 // Forward declarations. | 19 // Forward declarations. |
20 class CodeFlusher; | 20 class CodeFlusher; |
21 class GCTracer; | |
22 class MarkCompactCollector; | 21 class MarkCompactCollector; |
23 class MarkingVisitor; | 22 class MarkingVisitor; |
24 class RootMarkingVisitor; | 23 class RootMarkingVisitor; |
25 | 24 |
26 | 25 |
27 class Marking { | 26 class Marking { |
28 public: | 27 public: |
29 explicit Marking(Heap* heap) | 28 explicit Marking(Heap* heap) |
30 : heap_(heap) { | 29 : heap_(heap) { |
31 } | 30 } |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 void SetUp(); | 520 void SetUp(); |
522 | 521 |
523 void TearDown(); | 522 void TearDown(); |
524 | 523 |
525 void CollectEvacuationCandidates(PagedSpace* space); | 524 void CollectEvacuationCandidates(PagedSpace* space); |
526 | 525 |
527 void AddEvacuationCandidate(Page* p); | 526 void AddEvacuationCandidate(Page* p); |
528 | 527 |
529 // Prepares for GC by resetting relocation info in old and map spaces and | 528 // Prepares for GC by resetting relocation info in old and map spaces and |
530 // choosing spaces to compact. | 529 // choosing spaces to compact. |
531 void Prepare(GCTracer* tracer); | 530 void Prepare(); |
532 | 531 |
533 // Performs a global garbage collection. | 532 // Performs a global garbage collection. |
534 void CollectGarbage(); | 533 void CollectGarbage(); |
535 | 534 |
536 enum CompactionMode { | 535 enum CompactionMode { |
537 INCREMENTAL_COMPACTION, | 536 INCREMENTAL_COMPACTION, |
538 NON_INCREMENTAL_COMPACTION | 537 NON_INCREMENTAL_COMPACTION |
539 }; | 538 }; |
540 | 539 |
541 bool StartCompaction(CompactionMode mode); | 540 bool StartCompaction(CompactionMode mode); |
542 | 541 |
543 void AbortCompaction(); | 542 void AbortCompaction(); |
544 | 543 |
545 // During a full GC, there is a stack-allocated GCTracer that is used for | |
546 // bookkeeping information. Return a pointer to that tracer. | |
547 GCTracer* tracer() { return tracer_; } | |
548 | |
549 #ifdef DEBUG | 544 #ifdef DEBUG |
550 // Checks whether performing mark-compact collection. | 545 // Checks whether performing mark-compact collection. |
551 bool in_use() { return state_ > PREPARE_GC; } | 546 bool in_use() { return state_ > PREPARE_GC; } |
552 bool are_map_pointers_encoded() { return state_ == UPDATE_POINTERS; } | 547 bool are_map_pointers_encoded() { return state_ == UPDATE_POINTERS; } |
553 #endif | 548 #endif |
554 | 549 |
555 // Determine type of object and emit deletion log event. | 550 // Determine type of object and emit deletion log event. |
556 static void ReportDeleteIfNeeded(HeapObject* obj, Isolate* isolate); | 551 static void ReportDeleteIfNeeded(HeapObject* obj, Isolate* isolate); |
557 | 552 |
558 // Distinguishable invalid map encodings (for single word and multiple words) | 553 // Distinguishable invalid map encodings (for single word and multiple words) |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 | 733 |
739 bool was_marked_incrementally_; | 734 bool was_marked_incrementally_; |
740 | 735 |
741 // True if concurrent or parallel sweeping is currently in progress. | 736 // True if concurrent or parallel sweeping is currently in progress. |
742 bool sweeping_in_progress_; | 737 bool sweeping_in_progress_; |
743 | 738 |
744 base::Semaphore pending_sweeper_jobs_semaphore_; | 739 base::Semaphore pending_sweeper_jobs_semaphore_; |
745 | 740 |
746 bool sequential_sweeping_; | 741 bool sequential_sweeping_; |
747 | 742 |
748 // A pointer to the current stack-allocated GC tracer object during a full | |
749 // collection (NULL before and after). | |
750 GCTracer* tracer_; | |
751 | |
752 SlotsBufferAllocator slots_buffer_allocator_; | 743 SlotsBufferAllocator slots_buffer_allocator_; |
753 | 744 |
754 SlotsBuffer* migration_slots_buffer_; | 745 SlotsBuffer* migration_slots_buffer_; |
755 | 746 |
756 // Finishes GC, performs heap verification if enabled. | 747 // Finishes GC, performs heap verification if enabled. |
757 void Finish(); | 748 void Finish(); |
758 | 749 |
759 // ----------------------------------------------------------------------- | 750 // ----------------------------------------------------------------------- |
760 // Phase 1: Marking live objects. | 751 // Phase 1: Marking live objects. |
761 // | 752 // |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 private: | 976 private: |
986 MarkCompactCollector* collector_; | 977 MarkCompactCollector* collector_; |
987 }; | 978 }; |
988 | 979 |
989 | 980 |
990 const char* AllocationSpaceName(AllocationSpace space); | 981 const char* AllocationSpaceName(AllocationSpace space); |
991 | 982 |
992 } } // namespace v8::internal | 983 } } // namespace v8::internal |
993 | 984 |
994 #endif // V8_MARK_COMPACT_H_ | 985 #endif // V8_MARK_COMPACT_H_ |
OLD | NEW |