Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: src/heap/mark-compact.h

Issue 1577853007: [heap] Parallel newspace evacuation, semispace copy, and compaction \o/ (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Refactoring Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 void RecordCodeTargetPatch(Address pc, Code* target); 399 void RecordCodeTargetPatch(Address pc, Code* target);
400 INLINE(void RecordSlot(HeapObject* object, Object** slot, Object* target)); 400 INLINE(void RecordSlot(HeapObject* object, Object** slot, Object* target));
401 INLINE(void ForceRecordSlot(HeapObject* object, Object** slot, 401 INLINE(void ForceRecordSlot(HeapObject* object, Object** slot,
402 Object* target)); 402 Object* target));
403 403
404 void UpdateSlots(SlotsBuffer* buffer); 404 void UpdateSlots(SlotsBuffer* buffer);
405 void UpdateSlotsRecordedIn(SlotsBuffer* buffer); 405 void UpdateSlotsRecordedIn(SlotsBuffer* buffer);
406 406
407 void MigrateObject(HeapObject* dst, HeapObject* src, int size, 407 void MigrateObject(HeapObject* dst, HeapObject* src, int size,
408 AllocationSpace to_old_space, 408 AllocationSpace to_old_space,
409 SlotsBuffer** evacuation_slots_buffer); 409 SlotsBuffer** evacuation_slots_buffer,
410 LocalStoreBuffer* local_store_buffer);
410 411
411 void InvalidateCode(Code* code); 412 void InvalidateCode(Code* code);
412 413
413 void ClearMarkbits(); 414 void ClearMarkbits();
414 415
415 bool is_compacting() const { return compacting_; } 416 bool is_compacting() const { return compacting_; }
416 417
417 MarkingParity marking_parity() { return marking_parity_; } 418 MarkingParity marking_parity() { return marking_parity_; }
418 419
419 // Concurrent and parallel sweeping support. If required_freed_bytes was set 420 // Concurrent and parallel sweeping support. If required_freed_bytes was set
420 // to a value larger than 0, then sweeping returns after a block of at least 421 // to a value larger than 0, then sweeping returns after a block of at least
421 // required_freed_bytes was freed. If required_freed_bytes was set to zero 422 // required_freed_bytes was freed. If required_freed_bytes was set to zero
422 // then the whole given space is swept. It returns the size of the maximum 423 // then the whole given space is swept. It returns the size of the maximum
423 // continuous freed memory chunk. 424 // continuous freed memory chunk.
424 int SweepInParallel(PagedSpace* space, int required_freed_bytes); 425 int SweepInParallel(PagedSpace* space, int required_freed_bytes,
426 int max_pages = 0);
Hannes Payer (out of office) 2016/01/20 13:19:39 Please remove the sweeper change from the CL. This
Michael Lippautz 2016/01/21 10:00:08 Done.
425 427
426 // Sweeps a given page concurrently to the sweeper threads. It returns the 428 // Sweeps a given page concurrently to the sweeper threads. It returns the
427 // size of the maximum continuous freed memory chunk. 429 // size of the maximum continuous freed memory chunk.
428 int SweepInParallel(Page* page, PagedSpace* space); 430 int SweepInParallel(Page* page, PagedSpace* space);
429 431
430 // Ensures that sweeping is finished. 432 // Ensures that sweeping is finished.
431 // 433 //
432 // Note: Can only be called safely from main thread. 434 // Note: Can only be called safely from main thread.
433 void EnsureSweepingCompleted(); 435 void EnsureSweepingCompleted();
434 436
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 } 503 }
502 base::SmartPointer<FreeList>& free_list_map_space() { 504 base::SmartPointer<FreeList>& free_list_map_space() {
503 return free_list_map_space_; 505 return free_list_map_space_;
504 } 506 }
505 507
506 private: 508 private:
507 class CompactionTask; 509 class CompactionTask;
508 class EvacuateNewSpaceVisitor; 510 class EvacuateNewSpaceVisitor;
509 class EvacuateOldSpaceVisitor; 511 class EvacuateOldSpaceVisitor;
510 class EvacuateVisitorBase; 512 class EvacuateVisitorBase;
513 class Evacuator;
511 class HeapObjectVisitor; 514 class HeapObjectVisitor;
512 class SweeperTask; 515 class SweeperTask;
513 516
514 static const int kInitialLocalPretenuringFeedbackCapacity = 256;
515
516 explicit MarkCompactCollector(Heap* heap); 517 explicit MarkCompactCollector(Heap* heap);
517 518
518 bool WillBeDeoptimized(Code* code); 519 bool WillBeDeoptimized(Code* code);
519 void EvictPopularEvacuationCandidate(Page* page); 520 void EvictPopularEvacuationCandidate(Page* page);
520 void ClearInvalidStoreAndSlotsBufferEntries(); 521 void ClearInvalidStoreAndSlotsBufferEntries();
521 522
522 void StartSweeperThreads(); 523 void StartSweeperThreads();
523 524
524 void ComputeEvacuationHeuristics(int area_size, 525 void ComputeEvacuationHeuristics(int area_size,
525 int* target_fragmentation_percent, 526 int* target_fragmentation_percent,
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 // their space's free list. Active eden semispace is compacted by 693 // their space's free list. Active eden semispace is compacted by
693 // evacuation. 694 // evacuation.
694 // 695 //
695 696
696 // If we are not compacting the heap, we simply sweep the spaces except 697 // If we are not compacting the heap, we simply sweep the spaces except
697 // for the large object space, clearing mark bits and adding unmarked 698 // for the large object space, clearing mark bits and adding unmarked
698 // regions to each space's free list. 699 // regions to each space's free list.
699 void SweepSpaces(); 700 void SweepSpaces();
700 701
701 void EvacuateNewSpacePrologue(); 702 void EvacuateNewSpacePrologue();
702 703 void EvacuateNewSpaceEpilogue();
703 // Returns local pretenuring feedback.
704 HashMap* EvacuateNewSpaceInParallel();
705 704
706 void AddEvacuationSlotsBufferSynchronized( 705 void AddEvacuationSlotsBufferSynchronized(
707 SlotsBuffer* evacuation_slots_buffer); 706 SlotsBuffer* evacuation_slots_buffer);
708 707
709 void EvacuatePages(CompactionSpaceCollection* compaction_spaces,
710 SlotsBuffer** evacuation_slots_buffer);
711
712 void EvacuatePagesInParallel(); 708 void EvacuatePagesInParallel();
713 709
714 // The number of parallel compaction tasks, including the main thread. 710 // The number of parallel compaction tasks, including the main thread.
715 int NumberOfParallelCompactionTasks(); 711 int NumberOfParallelCompactionTasks(int pages, intptr_t live_bytes);
716 712
717 713 void StartParallelCompaction(Evacuator** evacuators, int len);
718 void StartParallelCompaction(CompactionSpaceCollection** compaction_spaces, 714 void WaitUntilCompactionCompleted(Evacuator** evacuators, int len);
719 uint32_t* task_ids, int len);
720 void WaitUntilCompactionCompleted(uint32_t* task_ids, int len);
721 715
722 void EvacuateNewSpaceAndCandidates(); 716 void EvacuateNewSpaceAndCandidates();
723 717
724 void UpdatePointersAfterEvacuation(); 718 void UpdatePointersAfterEvacuation();
725 719
726 // Iterates through all live objects on a page using marking information. 720 // Iterates through all live objects on a page using marking information.
727 // Returns whether all objects have successfully been visited. 721 // Returns whether all objects have successfully been visited.
728 bool VisitLiveObjects(MemoryChunk* page, HeapObjectVisitor* visitor, 722 bool VisitLiveObjects(MemoryChunk* page, HeapObjectVisitor* visitor,
729 IterationMode mode); 723 IterationMode mode);
730 724
(...skipping 14 matching lines...) Expand all
745 void StartSweepSpace(PagedSpace* space); 739 void StartSweepSpace(PagedSpace* space);
746 740
747 // Finalizes the parallel sweeping phase. Marks all the pages that were 741 // Finalizes the parallel sweeping phase. Marks all the pages that were
748 // swept in parallel. 742 // swept in parallel.
749 void ParallelSweepSpacesComplete(); 743 void ParallelSweepSpacesComplete();
750 744
751 void ParallelSweepSpaceComplete(PagedSpace* space); 745 void ParallelSweepSpaceComplete(PagedSpace* space);
752 746
753 // Updates store buffer and slot buffer for a pointer in a migrating object. 747 // Updates store buffer and slot buffer for a pointer in a migrating object.
754 void RecordMigratedSlot(Object* value, Address slot, 748 void RecordMigratedSlot(Object* value, Address slot,
755 SlotsBuffer** evacuation_slots_buffer); 749 SlotsBuffer** evacuation_slots_buffer,
750 LocalStoreBuffer* local_store_buffer);
756 751
757 // Adds the code entry slot to the slots buffer. 752 // Adds the code entry slot to the slots buffer.
758 void RecordMigratedCodeEntrySlot(Address code_entry, Address code_entry_slot, 753 void RecordMigratedCodeEntrySlot(Address code_entry, Address code_entry_slot,
759 SlotsBuffer** evacuation_slots_buffer); 754 SlotsBuffer** evacuation_slots_buffer);
760 755
761 // Adds the slot of a moved code object. 756 // Adds the slot of a moved code object.
762 void RecordMigratedCodeObjectSlot(Address code_object, 757 void RecordMigratedCodeObjectSlot(Address code_object,
763 SlotsBuffer** evacuation_slots_buffer); 758 SlotsBuffer** evacuation_slots_buffer);
764 759
765 #ifdef DEBUG 760 #ifdef DEBUG
766 friend class MarkObjectVisitor; 761 friend class MarkObjectVisitor;
767 static void VisitObject(HeapObject* obj); 762 static void VisitObject(HeapObject* obj);
768 763
769 friend class UnmarkObjectVisitor; 764 friend class UnmarkObjectVisitor;
770 static void UnmarkObject(HeapObject* obj); 765 static void UnmarkObject(HeapObject* obj);
771 #endif 766 #endif
772 767
773 Heap* heap_; 768 Heap* heap_;
774 base::VirtualMemory* marking_deque_memory_; 769 base::VirtualMemory* marking_deque_memory_;
775 size_t marking_deque_memory_committed_; 770 size_t marking_deque_memory_committed_;
776 MarkingDeque marking_deque_; 771 MarkingDeque marking_deque_;
777 CodeFlusher* code_flusher_; 772 CodeFlusher* code_flusher_;
778 bool have_code_to_deoptimize_; 773 bool have_code_to_deoptimize_;
779 774
780 List<Page*> evacuation_candidates_; 775 List<Page*> evacuation_candidates_;
781 776 List<NewSpacePage*> newspace_evacuation_candidates_;
782 List<MemoryChunk*> newspace_evacuation_candidates_;
783 777
784 // The evacuation_slots_buffers_ are used by the compaction threads. 778 // The evacuation_slots_buffers_ are used by the compaction threads.
785 // When a compaction task finishes, it uses 779 // When a compaction task finishes, it uses
786 // AddEvacuationSlotsbufferSynchronized to adds its slots buffer to the 780 // AddEvacuationSlotsbufferSynchronized to adds its slots buffer to the
787 // evacuation_slots_buffers_ list using the evacuation_slots_buffers_mutex_ 781 // evacuation_slots_buffers_ list using the evacuation_slots_buffers_mutex_
788 // lock. 782 // lock.
789 base::Mutex evacuation_slots_buffers_mutex_; 783 base::Mutex evacuation_slots_buffers_mutex_;
790 List<SlotsBuffer*> evacuation_slots_buffers_; 784 List<SlotsBuffer*> evacuation_slots_buffers_;
791 785
792 base::SmartPointer<FreeList> free_list_old_space_; 786 base::SmartPointer<FreeList> free_list_old_space_;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 private: 889 private:
896 MarkCompactCollector* collector_; 890 MarkCompactCollector* collector_;
897 }; 891 };
898 892
899 893
900 const char* AllocationSpaceName(AllocationSpace space); 894 const char* AllocationSpaceName(AllocationSpace space);
901 } // namespace internal 895 } // namespace internal
902 } // namespace v8 896 } // namespace v8
903 897
904 #endif // V8_HEAP_MARK_COMPACT_H_ 898 #endif // V8_HEAP_MARK_COMPACT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698