Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 SharedFunctionInfo* shared_function_info_candidates_head_; | 493 SharedFunctionInfo* shared_function_info_candidates_head_; |
| 494 | 494 |
| 495 DISALLOW_COPY_AND_ASSIGN(CodeFlusher); | 495 DISALLOW_COPY_AND_ASSIGN(CodeFlusher); |
| 496 }; | 496 }; |
| 497 | 497 |
| 498 | 498 |
| 499 // Defined in isolate.h. | 499 // Defined in isolate.h. |
| 500 class ThreadLocalTop; | 500 class ThreadLocalTop; |
| 501 | 501 |
| 502 | 502 |
| 503 enum SweeperType { | |
|
Michael Starzinger
2013/01/28 16:30:18
Move this back into MarkCompactCollector, no longe
Hannes Payer (out of office)
2013/01/30 10:11:27
Done.
| |
| 504 CONSERVATIVE, | |
| 505 LAZY_CONSERVATIVE, | |
| 506 PRECISE | |
| 507 }; | |
| 508 | |
| 509 | |
| 503 // ------------------------------------------------------------------------- | 510 // ------------------------------------------------------------------------- |
| 504 // Mark-Compact collector | 511 // Mark-Compact collector |
| 505 class MarkCompactCollector { | 512 class MarkCompactCollector { |
| 506 public: | 513 public: |
| 507 // Type of functions to compute forwarding addresses of objects in | 514 // Type of functions to compute forwarding addresses of objects in |
| 508 // compacted spaces. Given an object and its size, return a (non-failure) | 515 // compacted spaces. Given an object and its size, return a (non-failure) |
| 509 // Object* that will be the object after forwarding. There is a separate | 516 // Object* that will be the object after forwarding. There is a separate |
| 510 // allocation function for each (compactable) space based on the location | 517 // allocation function for each (compactable) space based on the location |
| 511 // of the object before compaction. | 518 // of the object before compaction. |
| 512 typedef MaybeObject* (*AllocationFunction)(Heap* heap, | 519 typedef MaybeObject* (*AllocationFunction)(Heap* heap, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 577 static const uint32_t kMultiFreeEncoding = 1; | 584 static const uint32_t kMultiFreeEncoding = 1; |
| 578 | 585 |
| 579 static inline bool IsMarked(Object* obj); | 586 static inline bool IsMarked(Object* obj); |
| 580 | 587 |
| 581 inline Heap* heap() const { return heap_; } | 588 inline Heap* heap() const { return heap_; } |
| 582 | 589 |
| 583 CodeFlusher* code_flusher() { return code_flusher_; } | 590 CodeFlusher* code_flusher() { return code_flusher_; } |
| 584 inline bool is_code_flushing_enabled() const { return code_flusher_ != NULL; } | 591 inline bool is_code_flushing_enabled() const { return code_flusher_ != NULL; } |
| 585 void EnableCodeFlushing(bool enable); | 592 void EnableCodeFlushing(bool enable); |
| 586 | 593 |
| 587 enum SweeperType { | |
| 588 CONSERVATIVE, | |
| 589 LAZY_CONSERVATIVE, | |
| 590 PRECISE | |
| 591 }; | |
| 592 | |
| 593 #ifdef VERIFY_HEAP | 594 #ifdef VERIFY_HEAP |
| 594 void VerifyMarkbitsAreClean(); | 595 void VerifyMarkbitsAreClean(); |
| 595 static void VerifyMarkbitsAreClean(PagedSpace* space); | 596 static void VerifyMarkbitsAreClean(PagedSpace* space); |
| 596 static void VerifyMarkbitsAreClean(NewSpace* space); | 597 static void VerifyMarkbitsAreClean(NewSpace* space); |
| 597 #endif | 598 #endif |
| 598 | 599 |
| 599 // Sweep a single page from the given space conservatively. | 600 // Sweep a single page from the given space conservatively. |
| 600 // Return a number of reclaimed bytes. | 601 // Return a number of reclaimed bytes. |
| 601 static intptr_t SweepConservatively(PagedSpace* space, Page* p); | 602 static intptr_t SweepConservatively(PagedSpace* space, |
| 603 FreeList* free_list, | |
| 604 Page* p); | |
| 605 | |
| 606 static intptr_t Free(PagedSpace* space, | |
| 607 FreeList* free_list, | |
| 608 Address start, | |
| 609 int size); | |
| 602 | 610 |
| 603 INLINE(static bool ShouldSkipEvacuationSlotRecording(Object** anchor)) { | 611 INLINE(static bool ShouldSkipEvacuationSlotRecording(Object** anchor)) { |
| 604 return Page::FromAddress(reinterpret_cast<Address>(anchor))-> | 612 return Page::FromAddress(reinterpret_cast<Address>(anchor))-> |
| 605 ShouldSkipEvacuationSlotRecording(); | 613 ShouldSkipEvacuationSlotRecording(); |
| 606 } | 614 } |
| 607 | 615 |
| 608 INLINE(static bool ShouldSkipEvacuationSlotRecording(Object* host)) { | 616 INLINE(static bool ShouldSkipEvacuationSlotRecording(Object* host)) { |
| 609 return Page::FromAddress(reinterpret_cast<Address>(host))-> | 617 return Page::FromAddress(reinterpret_cast<Address>(host))-> |
| 610 ShouldSkipEvacuationSlotRecording(); | 618 ShouldSkipEvacuationSlotRecording(); |
| 611 } | 619 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 657 void InvalidateCode(Code* code); | 665 void InvalidateCode(Code* code); |
| 658 | 666 |
| 659 void ClearMarkbits(); | 667 void ClearMarkbits(); |
| 660 | 668 |
| 661 bool abort_incremental_marking() const { return abort_incremental_marking_; } | 669 bool abort_incremental_marking() const { return abort_incremental_marking_; } |
| 662 | 670 |
| 663 bool is_compacting() const { return compacting_; } | 671 bool is_compacting() const { return compacting_; } |
| 664 | 672 |
| 665 MarkingParity marking_parity() { return marking_parity_; } | 673 MarkingParity marking_parity() { return marking_parity_; } |
| 666 | 674 |
| 675 void SweepInParallel(PagedSpace* space, | |
| 676 SweeperType sweeper_type, | |
|
Michael Starzinger
2013/01/28 16:30:18
As discussed offline: Parallel sweeping will alway
Hannes Payer (out of office)
2013/01/30 10:11:27
Done.
| |
| 677 FreeList* private_free_list, | |
| 678 FreeList* free_list); | |
| 679 | |
| 680 void WaitUntilSweepingCompleted(); | |
| 681 | |
| 682 intptr_t StealMemoryFromSweeperThreads(PagedSpace* space); | |
| 683 | |
| 684 bool AreSweeperThreadsActivated(); | |
| 685 | |
| 667 private: | 686 private: |
| 668 MarkCompactCollector(); | 687 MarkCompactCollector(); |
| 669 ~MarkCompactCollector(); | 688 ~MarkCompactCollector(); |
| 670 | 689 |
| 671 bool MarkInvalidatedCode(); | 690 bool MarkInvalidatedCode(); |
| 672 void RemoveDeadInvalidatedCode(); | 691 void RemoveDeadInvalidatedCode(); |
| 673 void ProcessInvalidatedCode(ObjectVisitor* visitor); | 692 void ProcessInvalidatedCode(ObjectVisitor* visitor); |
| 674 | 693 |
| 694 void StartSweeperThreads(SweeperType sweeper_type); | |
| 675 | 695 |
| 676 #ifdef DEBUG | 696 #ifdef DEBUG |
| 677 enum CollectorState { | 697 enum CollectorState { |
| 678 IDLE, | 698 IDLE, |
| 679 PREPARE_GC, | 699 PREPARE_GC, |
| 680 MARK_LIVE_OBJECTS, | 700 MARK_LIVE_OBJECTS, |
| 681 SWEEP_SPACES, | 701 SWEEP_SPACES, |
| 682 ENCODE_FORWARDING_ADDRESSES, | 702 ENCODE_FORWARDING_ADDRESSES, |
| 683 UPDATE_POINTERS, | 703 UPDATE_POINTERS, |
| 684 RELOCATE_OBJECTS | 704 RELOCATE_OBJECTS |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 829 void EvacuateNewSpace(); | 849 void EvacuateNewSpace(); |
| 830 | 850 |
| 831 void EvacuateLiveObjectsFromPage(Page* p); | 851 void EvacuateLiveObjectsFromPage(Page* p); |
| 832 | 852 |
| 833 void EvacuatePages(); | 853 void EvacuatePages(); |
| 834 | 854 |
| 835 void EvacuateNewSpaceAndCandidates(); | 855 void EvacuateNewSpaceAndCandidates(); |
| 836 | 856 |
| 837 void SweepSpace(PagedSpace* space, SweeperType sweeper); | 857 void SweepSpace(PagedSpace* space, SweeperType sweeper); |
| 838 | 858 |
| 859 void PrepareParallelSweeping(PagedSpace* space); | |
| 860 | |
| 839 #ifdef DEBUG | 861 #ifdef DEBUG |
| 840 friend class MarkObjectVisitor; | 862 friend class MarkObjectVisitor; |
| 841 static void VisitObject(HeapObject* obj); | 863 static void VisitObject(HeapObject* obj); |
| 842 | 864 |
| 843 friend class UnmarkObjectVisitor; | 865 friend class UnmarkObjectVisitor; |
| 844 static void UnmarkObject(HeapObject* obj); | 866 static void UnmarkObject(HeapObject* obj); |
| 845 #endif | 867 #endif |
| 846 | 868 |
| 847 Heap* heap_; | 869 Heap* heap_; |
| 848 MarkingDeque marking_deque_; | 870 MarkingDeque marking_deque_; |
| 849 CodeFlusher* code_flusher_; | 871 CodeFlusher* code_flusher_; |
| 850 Object* encountered_weak_maps_; | 872 Object* encountered_weak_maps_; |
| 851 | 873 |
| 852 List<Page*> evacuation_candidates_; | 874 List<Page*> evacuation_candidates_; |
| 853 List<Code*> invalidated_code_; | 875 List<Code*> invalidated_code_; |
| 854 | 876 |
| 855 friend class Heap; | 877 friend class Heap; |
| 856 }; | 878 }; |
| 857 | 879 |
| 858 | 880 |
| 859 const char* AllocationSpaceName(AllocationSpace space); | 881 const char* AllocationSpaceName(AllocationSpace space); |
| 860 | 882 |
| 861 } } // namespace v8::internal | 883 } } // namespace v8::internal |
| 862 | 884 |
| 863 #endif // V8_MARK_COMPACT_H_ | 885 #endif // V8_MARK_COMPACT_H_ |
| OLD | NEW |