| 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 { |
| 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, |
| 677 FreeList* private_free_list, |
| 678 FreeList* free_list); |
| 679 |
| 667 private: | 680 private: |
| 668 MarkCompactCollector(); | 681 MarkCompactCollector(); |
| 669 ~MarkCompactCollector(); | 682 ~MarkCompactCollector(); |
| 670 | 683 |
| 671 bool MarkInvalidatedCode(); | 684 bool MarkInvalidatedCode(); |
| 672 void RemoveDeadInvalidatedCode(); | 685 void RemoveDeadInvalidatedCode(); |
| 673 void ProcessInvalidatedCode(ObjectVisitor* visitor); | 686 void ProcessInvalidatedCode(ObjectVisitor* visitor); |
| 674 | 687 |
| 675 | 688 |
| 676 #ifdef DEBUG | 689 #ifdef DEBUG |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 void EvacuateNewSpace(); | 842 void EvacuateNewSpace(); |
| 830 | 843 |
| 831 void EvacuateLiveObjectsFromPage(Page* p); | 844 void EvacuateLiveObjectsFromPage(Page* p); |
| 832 | 845 |
| 833 void EvacuatePages(); | 846 void EvacuatePages(); |
| 834 | 847 |
| 835 void EvacuateNewSpaceAndCandidates(); | 848 void EvacuateNewSpaceAndCandidates(); |
| 836 | 849 |
| 837 void SweepSpace(PagedSpace* space, SweeperType sweeper); | 850 void SweepSpace(PagedSpace* space, SweeperType sweeper); |
| 838 | 851 |
| 852 void PrepareParallelSweeping(PagedSpace* space); |
| 853 |
| 839 #ifdef DEBUG | 854 #ifdef DEBUG |
| 840 friend class MarkObjectVisitor; | 855 friend class MarkObjectVisitor; |
| 841 static void VisitObject(HeapObject* obj); | 856 static void VisitObject(HeapObject* obj); |
| 842 | 857 |
| 843 friend class UnmarkObjectVisitor; | 858 friend class UnmarkObjectVisitor; |
| 844 static void UnmarkObject(HeapObject* obj); | 859 static void UnmarkObject(HeapObject* obj); |
| 845 #endif | 860 #endif |
| 846 | 861 |
| 847 Heap* heap_; | 862 Heap* heap_; |
| 848 MarkingDeque marking_deque_; | 863 MarkingDeque marking_deque_; |
| 849 CodeFlusher* code_flusher_; | 864 CodeFlusher* code_flusher_; |
| 850 Object* encountered_weak_maps_; | 865 Object* encountered_weak_maps_; |
| 851 | 866 |
| 852 List<Page*> evacuation_candidates_; | 867 List<Page*> evacuation_candidates_; |
| 853 List<Code*> invalidated_code_; | 868 List<Code*> invalidated_code_; |
| 854 | 869 |
| 855 friend class Heap; | 870 friend class Heap; |
| 856 }; | 871 }; |
| 857 | 872 |
| 858 | 873 |
| 859 const char* AllocationSpaceName(AllocationSpace space); | 874 const char* AllocationSpaceName(AllocationSpace space); |
| 860 | 875 |
| 861 } } // namespace v8::internal | 876 } } // namespace v8::internal |
| 862 | 877 |
| 863 #endif // V8_MARK_COMPACT_H_ | 878 #endif // V8_MARK_COMPACT_H_ |
| OLD | NEW |