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 | |
613 void RecordRelocSlot(RelocInfo* rinfo, Object* target); | 592 void RecordRelocSlot(RelocInfo* rinfo, Object* target); |
614 void RecordCodeEntrySlot(Address slot, Code* target); | 593 void RecordCodeEntrySlot(Address slot, Code* target); |
615 void RecordCodeTargetPatch(Address pc, Code* target); | 594 void RecordCodeTargetPatch(Address pc, Code* target); |
616 | 595 |
617 INLINE(void RecordSlot( | 596 INLINE(void RecordSlot( |
618 Object** anchor_slot, Object** slot, Object* object, | 597 Object** anchor_slot, Object** slot, Object* object, |
619 SlotsBuffer::AdditionMode mode = SlotsBuffer::FAIL_ON_OVERFLOW)); | 598 SlotsBuffer::AdditionMode mode = SlotsBuffer::FAIL_ON_OVERFLOW)); |
620 | 599 |
621 void MigrateObject(HeapObject* dst, HeapObject* src, int size, | 600 void MigrateObject(HeapObject* dst, HeapObject* src, int size, |
622 AllocationSpace to_old_space); | 601 AllocationSpace to_old_space); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 private: | 666 private: |
688 class SweeperTask; | 667 class SweeperTask; |
689 | 668 |
690 explicit MarkCompactCollector(Heap* heap); | 669 explicit MarkCompactCollector(Heap* heap); |
691 ~MarkCompactCollector(); | 670 ~MarkCompactCollector(); |
692 | 671 |
693 bool MarkInvalidatedCode(); | 672 bool MarkInvalidatedCode(); |
694 bool WillBeDeoptimized(Code* code); | 673 bool WillBeDeoptimized(Code* code); |
695 void RemoveDeadInvalidatedCode(); | 674 void RemoveDeadInvalidatedCode(); |
696 void ProcessInvalidatedCode(ObjectVisitor* visitor); | 675 void ProcessInvalidatedCode(ObjectVisitor* visitor); |
| 676 void EvictEvacuationCandidate(Page* page); |
697 | 677 |
698 void StartSweeperThreads(); | 678 void StartSweeperThreads(); |
699 | 679 |
700 #ifdef DEBUG | 680 #ifdef DEBUG |
701 enum CollectorState { | 681 enum CollectorState { |
702 IDLE, | 682 IDLE, |
703 PREPARE_GC, | 683 PREPARE_GC, |
704 MARK_LIVE_OBJECTS, | 684 MARK_LIVE_OBJECTS, |
705 SWEEP_SPACES, | 685 SWEEP_SPACES, |
706 ENCODE_FORWARDING_ADDRESSES, | 686 ENCODE_FORWARDING_ADDRESSES, |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 private: | 947 private: |
968 MarkCompactCollector* collector_; | 948 MarkCompactCollector* collector_; |
969 }; | 949 }; |
970 | 950 |
971 | 951 |
972 const char* AllocationSpaceName(AllocationSpace space); | 952 const char* AllocationSpaceName(AllocationSpace space); |
973 } | 953 } |
974 } // namespace v8::internal | 954 } // namespace v8::internal |
975 | 955 |
976 #endif // V8_HEAP_MARK_COMPACT_H_ | 956 #endif // V8_HEAP_MARK_COMPACT_H_ |
OLD | NEW |