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 "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/heap/spaces.h" | 9 #include "src/heap/spaces.h" |
10 | 10 |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 INLINE(static bool ShouldSkipEvacuationSlotRecording(Object* host)) { | 582 INLINE(static bool ShouldSkipEvacuationSlotRecording(Object* host)) { |
583 return Page::FromAddress(reinterpret_cast<Address>(host)) | 583 return Page::FromAddress(reinterpret_cast<Address>(host)) |
584 ->ShouldSkipEvacuationSlotRecording(); | 584 ->ShouldSkipEvacuationSlotRecording(); |
585 } | 585 } |
586 | 586 |
587 INLINE(static bool IsOnEvacuationCandidate(Object* obj)) { | 587 INLINE(static bool IsOnEvacuationCandidate(Object* obj)) { |
588 return Page::FromAddress(reinterpret_cast<Address>(obj)) | 588 return Page::FromAddress(reinterpret_cast<Address>(obj)) |
589 ->IsEvacuationCandidate(); | 589 ->IsEvacuationCandidate(); |
590 } | 590 } |
591 | 591 |
| 592 INLINE(void EvictEvacuationCandidate(Page* page)) { |
| 593 if (FLAG_trace_fragmentation) { |
| 594 PrintF("Page %p is too popular. Disabling evacuation.\n", |
| 595 reinterpret_cast<void*>(page)); |
| 596 } |
| 597 |
| 598 // TODO(gc) If all evacuation candidates are too popular we |
| 599 // should stop slots recording entirely. |
| 600 page->ClearEvacuationCandidate(); |
| 601 |
| 602 // We were not collecting slots on this page that point |
| 603 // to other evacuation candidates thus we have to |
| 604 // rescan the page after evacuation to discover and update all |
| 605 // pointers to evacuated objects. |
| 606 if (page->owner()->identity() == OLD_DATA_SPACE) { |
| 607 evacuation_candidates_.RemoveElement(page); |
| 608 } else { |
| 609 page->SetFlag(Page::RESCAN_ON_EVACUATION); |
| 610 } |
| 611 } |
| 612 |
592 void RecordRelocSlot(RelocInfo* rinfo, Object* target); | 613 void RecordRelocSlot(RelocInfo* rinfo, Object* target); |
593 void RecordCodeEntrySlot(Address slot, Code* target); | 614 void RecordCodeEntrySlot(Address slot, Code* target); |
594 void RecordCodeTargetPatch(Address pc, Code* target); | 615 void RecordCodeTargetPatch(Address pc, Code* target); |
595 | 616 |
596 INLINE(void RecordSlot( | 617 INLINE(void RecordSlot( |
597 Object** anchor_slot, Object** slot, Object* object, | 618 Object** anchor_slot, Object** slot, Object* object, |
598 SlotsBuffer::AdditionMode mode = SlotsBuffer::FAIL_ON_OVERFLOW)); | 619 SlotsBuffer::AdditionMode mode = SlotsBuffer::FAIL_ON_OVERFLOW)); |
599 | 620 |
600 void MigrateObject(HeapObject* dst, HeapObject* src, int size, | 621 void MigrateObject(HeapObject* dst, HeapObject* src, int size, |
601 AllocationSpace to_old_space); | 622 AllocationSpace to_old_space); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 private: | 687 private: |
667 class SweeperTask; | 688 class SweeperTask; |
668 | 689 |
669 explicit MarkCompactCollector(Heap* heap); | 690 explicit MarkCompactCollector(Heap* heap); |
670 ~MarkCompactCollector(); | 691 ~MarkCompactCollector(); |
671 | 692 |
672 bool MarkInvalidatedCode(); | 693 bool MarkInvalidatedCode(); |
673 bool WillBeDeoptimized(Code* code); | 694 bool WillBeDeoptimized(Code* code); |
674 void RemoveDeadInvalidatedCode(); | 695 void RemoveDeadInvalidatedCode(); |
675 void ProcessInvalidatedCode(ObjectVisitor* visitor); | 696 void ProcessInvalidatedCode(ObjectVisitor* visitor); |
676 void EvictEvacuationCandidate(Page* page); | |
677 | 697 |
678 void StartSweeperThreads(); | 698 void StartSweeperThreads(); |
679 | 699 |
680 #ifdef DEBUG | 700 #ifdef DEBUG |
681 enum CollectorState { | 701 enum CollectorState { |
682 IDLE, | 702 IDLE, |
683 PREPARE_GC, | 703 PREPARE_GC, |
684 MARK_LIVE_OBJECTS, | 704 MARK_LIVE_OBJECTS, |
685 SWEEP_SPACES, | 705 SWEEP_SPACES, |
686 ENCODE_FORWARDING_ADDRESSES, | 706 ENCODE_FORWARDING_ADDRESSES, |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 private: | 967 private: |
948 MarkCompactCollector* collector_; | 968 MarkCompactCollector* collector_; |
949 }; | 969 }; |
950 | 970 |
951 | 971 |
952 const char* AllocationSpaceName(AllocationSpace space); | 972 const char* AllocationSpaceName(AllocationSpace space); |
953 } | 973 } |
954 } // namespace v8::internal | 974 } // namespace v8::internal |
955 | 975 |
956 #endif // V8_HEAP_MARK_COMPACT_H_ | 976 #endif // V8_HEAP_MARK_COMPACT_H_ |
OLD | NEW |