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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 INLINE(static bool ShouldSkipEvacuationSlotRecording(Object* host)) { | 591 INLINE(static bool ShouldSkipEvacuationSlotRecording(Object* host)) { |
592 return Page::FromAddress(reinterpret_cast<Address>(host)) | 592 return Page::FromAddress(reinterpret_cast<Address>(host)) |
593 ->ShouldSkipEvacuationSlotRecording(); | 593 ->ShouldSkipEvacuationSlotRecording(); |
594 } | 594 } |
595 | 595 |
596 INLINE(static bool IsOnEvacuationCandidate(Object* obj)) { | 596 INLINE(static bool IsOnEvacuationCandidate(Object* obj)) { |
597 return Page::FromAddress(reinterpret_cast<Address>(obj)) | 597 return Page::FromAddress(reinterpret_cast<Address>(obj)) |
598 ->IsEvacuationCandidate(); | 598 ->IsEvacuationCandidate(); |
599 } | 599 } |
600 | 600 |
601 INLINE(void EvictEvacuationCandidate(Page* page)) { | |
602 if (FLAG_trace_fragmentation) { | |
603 PrintF("Page %p is too popular. Disabling evacuation.\n", | |
604 reinterpret_cast<void*>(page)); | |
605 } | |
606 | |
607 // TODO(gc) If all evacuation candidates are too popular we | |
608 // should stop slots recording entirely. | |
609 page->ClearEvacuationCandidate(); | |
610 | |
611 // We were not collecting slots on this page that point | |
612 // to other evacuation candidates thus we have to | |
613 // rescan the page after evacuation to discover and update all | |
614 // pointers to evacuated objects. | |
615 if (page->owner()->identity() == OLD_DATA_SPACE) { | |
616 evacuation_candidates_.RemoveElement(page); | |
617 } else { | |
618 page->SetFlag(Page::RESCAN_ON_EVACUATION); | |
619 } | |
620 } | |
621 | |
622 void RecordRelocSlot(RelocInfo* rinfo, Object* target); | 601 void RecordRelocSlot(RelocInfo* rinfo, Object* target); |
623 void RecordCodeEntrySlot(Address slot, Code* target); | 602 void RecordCodeEntrySlot(Address slot, Code* target); |
624 void RecordCodeTargetPatch(Address pc, Code* target); | 603 void RecordCodeTargetPatch(Address pc, Code* target); |
625 | 604 |
626 INLINE(void RecordSlot( | 605 INLINE(void RecordSlot( |
627 Object** anchor_slot, Object** slot, Object* object, | 606 Object** anchor_slot, Object** slot, Object* object, |
628 SlotsBuffer::AdditionMode mode = SlotsBuffer::FAIL_ON_OVERFLOW)); | 607 SlotsBuffer::AdditionMode mode = SlotsBuffer::FAIL_ON_OVERFLOW)); |
629 | 608 |
630 void MigrateObject(HeapObject* dst, HeapObject* src, int size, | 609 void MigrateObject(HeapObject* dst, HeapObject* src, int size, |
631 AllocationSpace to_old_space); | 610 AllocationSpace to_old_space); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 private: | 675 private: |
697 class SweeperTask; | 676 class SweeperTask; |
698 | 677 |
699 explicit MarkCompactCollector(Heap* heap); | 678 explicit MarkCompactCollector(Heap* heap); |
700 ~MarkCompactCollector(); | 679 ~MarkCompactCollector(); |
701 | 680 |
702 bool MarkInvalidatedCode(); | 681 bool MarkInvalidatedCode(); |
703 bool WillBeDeoptimized(Code* code); | 682 bool WillBeDeoptimized(Code* code); |
704 void RemoveDeadInvalidatedCode(); | 683 void RemoveDeadInvalidatedCode(); |
705 void ProcessInvalidatedCode(ObjectVisitor* visitor); | 684 void ProcessInvalidatedCode(ObjectVisitor* visitor); |
| 685 void EvictEvacuationCandidate(Page* page); |
706 void ClearInvalidSlotsBufferEntries(PagedSpace* space); | 686 void ClearInvalidSlotsBufferEntries(PagedSpace* space); |
707 void ClearInvalidStoreAndSlotsBufferEntries(); | 687 void ClearInvalidStoreAndSlotsBufferEntries(); |
708 | 688 |
709 void StartSweeperThreads(); | 689 void StartSweeperThreads(); |
710 | 690 |
711 #ifdef DEBUG | 691 #ifdef DEBUG |
712 enum CollectorState { | 692 enum CollectorState { |
713 IDLE, | 693 IDLE, |
714 PREPARE_GC, | 694 PREPARE_GC, |
715 MARK_LIVE_OBJECTS, | 695 MARK_LIVE_OBJECTS, |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 private: | 958 private: |
979 MarkCompactCollector* collector_; | 959 MarkCompactCollector* collector_; |
980 }; | 960 }; |
981 | 961 |
982 | 962 |
983 const char* AllocationSpaceName(AllocationSpace space); | 963 const char* AllocationSpaceName(AllocationSpace space); |
984 } | 964 } |
985 } // namespace v8::internal | 965 } // namespace v8::internal |
986 | 966 |
987 #endif // V8_HEAP_MARK_COMPACT_H_ | 967 #endif // V8_HEAP_MARK_COMPACT_H_ |
OLD | NEW |