| 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 409 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 420   void RecordCodeEntrySlot(HeapObject* object, Address slot, Code* target); | 420   void RecordCodeEntrySlot(HeapObject* object, Address slot, Code* target); | 
| 421   void RecordCodeTargetPatch(Address pc, Code* target); | 421   void RecordCodeTargetPatch(Address pc, Code* target); | 
| 422   INLINE(void RecordSlot(HeapObject* object, Object** slot, Object* target)); | 422   INLINE(void RecordSlot(HeapObject* object, Object** slot, Object* target)); | 
| 423   INLINE(void ForceRecordSlot(HeapObject* object, Object** slot, | 423   INLINE(void ForceRecordSlot(HeapObject* object, Object** slot, | 
| 424                               Object* target)); | 424                               Object* target)); | 
| 425 | 425 | 
| 426   void UpdateSlots(SlotsBuffer* buffer); | 426   void UpdateSlots(SlotsBuffer* buffer); | 
| 427   void UpdateSlotsRecordedIn(SlotsBuffer* buffer); | 427   void UpdateSlotsRecordedIn(SlotsBuffer* buffer); | 
| 428 | 428 | 
| 429   void MigrateObject(HeapObject* dst, HeapObject* src, int size, | 429   void MigrateObject(HeapObject* dst, HeapObject* src, int size, | 
| 430                      AllocationSpace to_old_space); | 430                      AllocationSpace to_old_space, | 
|  | 431                      SlotsBuffer** evacuation_slots_buffer); | 
| 431 | 432 | 
| 432   void MigrateObjectTagged(HeapObject* dst, HeapObject* src, int size); | 433   void MigrateObjectTagged(HeapObject* dst, HeapObject* src, int size, | 
| 433   void MigrateObjectMixed(HeapObject* dst, HeapObject* src, int size); | 434                            SlotsBuffer** evacuation_slots_buffer); | 
|  | 435   void MigrateObjectMixed(HeapObject* dst, HeapObject* src, int size, | 
|  | 436                           SlotsBuffer** evacuation_slots_buffer); | 
| 434   void MigrateObjectRaw(HeapObject* dst, HeapObject* src, int size); | 437   void MigrateObjectRaw(HeapObject* dst, HeapObject* src, int size); | 
| 435 | 438 | 
| 436   bool TryPromoteObject(HeapObject* object, int object_size); | 439   bool TryPromoteObject(HeapObject* object, int object_size); | 
| 437 | 440 | 
| 438   void InvalidateCode(Code* code); | 441   void InvalidateCode(Code* code); | 
| 439 | 442 | 
| 440   void ClearMarkbits(); | 443   void ClearMarkbits(); | 
| 441 | 444 | 
| 442   bool is_compacting() const { return compacting_; } | 445   bool is_compacting() const { return compacting_; } | 
| 443 | 446 | 
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 559 | 562 | 
| 560   // Number of active compaction tasks (including main thread). | 563   // Number of active compaction tasks (including main thread). | 
| 561   intptr_t concurrent_compaction_tasks_active_; | 564   intptr_t concurrent_compaction_tasks_active_; | 
| 562 | 565 | 
| 563   bool evacuation_; | 566   bool evacuation_; | 
| 564 | 567 | 
| 565   SlotsBufferAllocator* slots_buffer_allocator_; | 568   SlotsBufferAllocator* slots_buffer_allocator_; | 
| 566 | 569 | 
| 567   SlotsBuffer* migration_slots_buffer_; | 570   SlotsBuffer* migration_slots_buffer_; | 
| 568 | 571 | 
| 569   base::Mutex migration_slots_buffer_mutex_; |  | 
| 570 |  | 
| 571   // Finishes GC, performs heap verification if enabled. | 572   // Finishes GC, performs heap verification if enabled. | 
| 572   void Finish(); | 573   void Finish(); | 
| 573 | 574 | 
| 574   // ----------------------------------------------------------------------- | 575   // ----------------------------------------------------------------------- | 
| 575   // Phase 1: Marking live objects. | 576   // Phase 1: Marking live objects. | 
| 576   // | 577   // | 
| 577   //  Before: The heap has been prepared for garbage collection by | 578   //  Before: The heap has been prepared for garbage collection by | 
| 578   //          MarkCompactCollector::Prepare() and is otherwise in its | 579   //          MarkCompactCollector::Prepare() and is otherwise in its | 
| 579   //          normal state. | 580   //          normal state. | 
| 580   // | 581   // | 
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 709   // If we are not compacting the heap, we simply sweep the spaces except | 710   // If we are not compacting the heap, we simply sweep the spaces except | 
| 710   // for the large object space, clearing mark bits and adding unmarked | 711   // for the large object space, clearing mark bits and adding unmarked | 
| 711   // regions to each space's free list. | 712   // regions to each space's free list. | 
| 712   void SweepSpaces(); | 713   void SweepSpaces(); | 
| 713 | 714 | 
| 714   int DiscoverAndEvacuateBlackObjectsOnPage(NewSpace* new_space, | 715   int DiscoverAndEvacuateBlackObjectsOnPage(NewSpace* new_space, | 
| 715                                             NewSpacePage* p); | 716                                             NewSpacePage* p); | 
| 716 | 717 | 
| 717   void EvacuateNewSpace(); | 718   void EvacuateNewSpace(); | 
| 718 | 719 | 
| 719   bool EvacuateLiveObjectsFromPage(Page* p, PagedSpace* target_space); | 720   bool EvacuateLiveObjectsFromPage(Page* p, PagedSpace* target_space, | 
|  | 721                                    SlotsBuffer** evacuation_slots_buffer); | 
| 720 | 722 | 
| 721   void EvacuatePages(CompactionSpaceCollection* compaction_spaces); | 723   void AddEvacuationSlotsBufferSynchronized( | 
|  | 724       SlotsBuffer* evacuation_slots_buffer); | 
|  | 725 | 
|  | 726   void EvacuatePages(CompactionSpaceCollection* compaction_spaces, | 
|  | 727                      SlotsBuffer** evacuation_slots_buffer); | 
|  | 728 | 
| 722   void EvacuatePagesInParallel(); | 729   void EvacuatePagesInParallel(); | 
| 723 | 730 | 
| 724   int NumberOfParallelCompactionTasks() { | 731   int NumberOfParallelCompactionTasks() { | 
| 725     // TODO(hpayer, mlippautz): Figure out some logic to determine the number | 732     // TODO(hpayer, mlippautz): Figure out some logic to determine the number | 
| 726     // of compaction tasks. | 733     // of compaction tasks. | 
| 727     return 1; | 734     return 1; | 
| 728   } | 735   } | 
| 729 | 736 | 
| 730   void WaitUntilCompactionCompleted(); | 737   void WaitUntilCompactionCompleted(); | 
| 731 | 738 | 
| 732   void EvacuateNewSpaceAndCandidates(); | 739   void EvacuateNewSpaceAndCandidates(); | 
| 733 | 740 | 
| 734   void ReleaseEvacuationCandidates(); | 741   void ReleaseEvacuationCandidates(); | 
| 735 | 742 | 
| 736   // Moves the pages of the evacuation_candidates_ list to the end of their | 743   // Moves the pages of the evacuation_candidates_ list to the end of their | 
| 737   // corresponding space pages list. | 744   // corresponding space pages list. | 
| 738   void MoveEvacuationCandidatesToEndOfPagesList(); | 745   void MoveEvacuationCandidatesToEndOfPagesList(); | 
| 739 | 746 | 
| 740   void SweepSpace(PagedSpace* space, SweeperType sweeper); | 747   void SweepSpace(PagedSpace* space, SweeperType sweeper); | 
| 741 | 748 | 
| 742   // Finalizes the parallel sweeping phase. Marks all the pages that were | 749   // Finalizes the parallel sweeping phase. Marks all the pages that were | 
| 743   // swept in parallel. | 750   // swept in parallel. | 
| 744   void ParallelSweepSpacesComplete(); | 751   void ParallelSweepSpacesComplete(); | 
| 745 | 752 | 
| 746   void ParallelSweepSpaceComplete(PagedSpace* space); | 753   void ParallelSweepSpaceComplete(PagedSpace* space); | 
| 747 | 754 | 
| 748   // Updates store buffer and slot buffer for a pointer in a migrating object. | 755   // Updates store buffer and slot buffer for a pointer in a migrating object. | 
| 749   void RecordMigratedSlot(Object* value, Address slot); | 756   void RecordMigratedSlot(Object* value, Address slot, | 
|  | 757                           SlotsBuffer** evacuation_slots_buffer); | 
| 750 | 758 | 
| 751   // Adds the code entry slot to the slots buffer. | 759   // Adds the code entry slot to the slots buffer. | 
| 752   void RecordMigratedCodeEntrySlot(Address code_entry, Address code_entry_slot); | 760   void RecordMigratedCodeEntrySlot(Address code_entry, Address code_entry_slot, | 
|  | 761                                    SlotsBuffer** evacuation_slots_buffer); | 
| 753 | 762 | 
| 754   // Adds the slot of a moved code object. | 763   // Adds the slot of a moved code object. | 
| 755   void RecordMigratedCodeObjectSlot(Address code_object); | 764   void RecordMigratedCodeObjectSlot(Address code_object, | 
|  | 765                                     SlotsBuffer** evacuation_slots_buffer); | 
| 756 | 766 | 
| 757 #ifdef DEBUG | 767 #ifdef DEBUG | 
| 758   friend class MarkObjectVisitor; | 768   friend class MarkObjectVisitor; | 
| 759   static void VisitObject(HeapObject* obj); | 769   static void VisitObject(HeapObject* obj); | 
| 760 | 770 | 
| 761   friend class UnmarkObjectVisitor; | 771   friend class UnmarkObjectVisitor; | 
| 762   static void UnmarkObject(HeapObject* obj); | 772   static void UnmarkObject(HeapObject* obj); | 
| 763 #endif | 773 #endif | 
| 764 | 774 | 
| 765   Heap* heap_; | 775   Heap* heap_; | 
| 766   base::VirtualMemory* marking_deque_memory_; | 776   base::VirtualMemory* marking_deque_memory_; | 
| 767   size_t marking_deque_memory_committed_; | 777   size_t marking_deque_memory_committed_; | 
| 768   MarkingDeque marking_deque_; | 778   MarkingDeque marking_deque_; | 
| 769   CodeFlusher* code_flusher_; | 779   CodeFlusher* code_flusher_; | 
| 770   bool have_code_to_deoptimize_; | 780   bool have_code_to_deoptimize_; | 
| 771 | 781 | 
| 772   List<Page*> evacuation_candidates_; | 782   List<Page*> evacuation_candidates_; | 
| 773 | 783 | 
|  | 784   // The evacuation_slots_buffers_ are used by the compaction threads. | 
|  | 785   // When a compaction task finishes, it uses | 
|  | 786   // AddEvacuationSlotsbufferSynchronized to adds its slots buffer to the | 
|  | 787   // evacuation_slots_buffers_ list using the evacuation_slots_buffers_mutex_ | 
|  | 788   // lock. | 
|  | 789   base::Mutex evacuation_slots_buffers_mutex_; | 
|  | 790   List<SlotsBuffer*> evacuation_slots_buffers_; | 
|  | 791 | 
| 774   base::SmartPointer<FreeList> free_list_old_space_; | 792   base::SmartPointer<FreeList> free_list_old_space_; | 
| 775   base::SmartPointer<FreeList> free_list_code_space_; | 793   base::SmartPointer<FreeList> free_list_code_space_; | 
| 776   base::SmartPointer<FreeList> free_list_map_space_; | 794   base::SmartPointer<FreeList> free_list_map_space_; | 
| 777 | 795 | 
| 778   friend class Heap; | 796   friend class Heap; | 
| 779 }; | 797 }; | 
| 780 | 798 | 
| 781 | 799 | 
| 782 class MarkBitCellIterator BASE_EMBEDDED { | 800 class MarkBitCellIterator BASE_EMBEDDED { | 
| 783  public: | 801  public: | 
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 832  private: | 850  private: | 
| 833   MarkCompactCollector* collector_; | 851   MarkCompactCollector* collector_; | 
| 834 }; | 852 }; | 
| 835 | 853 | 
| 836 | 854 | 
| 837 const char* AllocationSpaceName(AllocationSpace space); | 855 const char* AllocationSpaceName(AllocationSpace space); | 
| 838 } | 856 } | 
| 839 }  // namespace v8::internal | 857 }  // namespace v8::internal | 
| 840 | 858 | 
| 841 #endif  // V8_HEAP_MARK_COMPACT_H_ | 859 #endif  // V8_HEAP_MARK_COMPACT_H_ | 
| OLD | NEW | 
|---|