| 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 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 typedef void (*ProcessNonLiveFunction)(HeapObject* object, Isolate* isolate); | 564 typedef void (*ProcessNonLiveFunction)(HeapObject* object, Isolate* isolate); |
| 565 | 565 |
| 566 // Pointer to member function, used in IterateLiveObjects. | 566 // Pointer to member function, used in IterateLiveObjects. |
| 567 typedef int (MarkCompactCollector::*LiveObjectCallback)(HeapObject* obj); | 567 typedef int (MarkCompactCollector::*LiveObjectCallback)(HeapObject* obj); |
| 568 | 568 |
| 569 // Set the global flags, it must be called before Prepare to take effect. | 569 // Set the global flags, it must be called before Prepare to take effect. |
| 570 inline void SetFlags(int flags); | 570 inline void SetFlags(int flags); |
| 571 | 571 |
| 572 static void Initialize(); | 572 static void Initialize(); |
| 573 | 573 |
| 574 void SetUp(); |
| 575 |
| 574 void TearDown(); | 576 void TearDown(); |
| 575 | 577 |
| 576 void CollectEvacuationCandidates(PagedSpace* space); | 578 void CollectEvacuationCandidates(PagedSpace* space); |
| 577 | 579 |
| 578 void AddEvacuationCandidate(Page* p); | 580 void AddEvacuationCandidate(Page* p); |
| 579 | 581 |
| 580 // Prepares for GC by resetting relocation info in old and map spaces and | 582 // Prepares for GC by resetting relocation info in old and map spaces and |
| 581 // choosing spaces to compact. | 583 // choosing spaces to compact. |
| 582 void Prepare(GCTracer* tracer); | 584 void Prepare(GCTracer* tracer); |
| 583 | 585 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 | 710 |
| 709 void ClearMarkbits(); | 711 void ClearMarkbits(); |
| 710 | 712 |
| 711 bool abort_incremental_marking() const { return abort_incremental_marking_; } | 713 bool abort_incremental_marking() const { return abort_incremental_marking_; } |
| 712 | 714 |
| 713 bool is_compacting() const { return compacting_; } | 715 bool is_compacting() const { return compacting_; } |
| 714 | 716 |
| 715 MarkingParity marking_parity() { return marking_parity_; } | 717 MarkingParity marking_parity() { return marking_parity_; } |
| 716 | 718 |
| 717 // Concurrent and parallel sweeping support. | 719 // Concurrent and parallel sweeping support. |
| 718 void SweepInParallel(PagedSpace* space, | 720 void SweepInParallel(PagedSpace* space); |
| 719 FreeList* private_free_list, | |
| 720 FreeList* free_list); | |
| 721 | 721 |
| 722 void WaitUntilSweepingCompleted(); | 722 void WaitUntilSweepingCompleted(); |
| 723 | 723 |
| 724 intptr_t StealMemoryFromSweeperThreads(PagedSpace* space); | 724 intptr_t RefillFreeLists(PagedSpace* space); |
| 725 | 725 |
| 726 bool AreSweeperThreadsActivated(); | 726 bool AreSweeperThreadsActivated(); |
| 727 | 727 |
| 728 bool IsConcurrentSweepingInProgress(); | 728 bool IsConcurrentSweepingInProgress(); |
| 729 | 729 |
| 730 void set_sequential_sweeping(bool sequential_sweeping) { | 730 void set_sequential_sweeping(bool sequential_sweeping) { |
| 731 sequential_sweeping_ = sequential_sweeping; | 731 sequential_sweeping_ = sequential_sweeping; |
| 732 } | 732 } |
| 733 | 733 |
| 734 bool sequential_sweeping() const { | 734 bool sequential_sweeping() const { |
| 735 return sequential_sweeping_; | 735 return sequential_sweeping_; |
| 736 } | 736 } |
| 737 | 737 |
| 738 // Mark the global table which maps weak objects to dependent code without | 738 // Mark the global table which maps weak objects to dependent code without |
| 739 // marking its contents. | 739 // marking its contents. |
| 740 void MarkWeakObjectToCodeTable(); | 740 void MarkWeakObjectToCodeTable(); |
| 741 | 741 |
| 742 // Special case for processing weak references in a full collection. We need | 742 // Special case for processing weak references in a full collection. We need |
| 743 // to artifically keep AllocationSites alive for a time. | 743 // to artifically keep AllocationSites alive for a time. |
| 744 void MarkAllocationSite(AllocationSite* site); | 744 void MarkAllocationSite(AllocationSite* site); |
| 745 | 745 |
| 746 private: | 746 private: |
| 747 MarkCompactCollector(); | 747 class SweeperTask; |
| 748 |
| 749 explicit MarkCompactCollector(Heap* heap); |
| 748 ~MarkCompactCollector(); | 750 ~MarkCompactCollector(); |
| 749 | 751 |
| 750 bool MarkInvalidatedCode(); | 752 bool MarkInvalidatedCode(); |
| 751 bool WillBeDeoptimized(Code* code); | 753 bool WillBeDeoptimized(Code* code); |
| 752 void RemoveDeadInvalidatedCode(); | 754 void RemoveDeadInvalidatedCode(); |
| 753 void ProcessInvalidatedCode(ObjectVisitor* visitor); | 755 void ProcessInvalidatedCode(ObjectVisitor* visitor); |
| 754 | 756 |
| 755 void UnlinkEvacuationCandidates(); | 757 void UnlinkEvacuationCandidates(); |
| 756 void ReleaseEvacuationCandidates(); | 758 void ReleaseEvacuationCandidates(); |
| 757 | 759 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 784 | 786 |
| 785 // True if we are collecting slots to perform evacuation from evacuation | 787 // True if we are collecting slots to perform evacuation from evacuation |
| 786 // candidates. | 788 // candidates. |
| 787 bool compacting_; | 789 bool compacting_; |
| 788 | 790 |
| 789 bool was_marked_incrementally_; | 791 bool was_marked_incrementally_; |
| 790 | 792 |
| 791 // True if concurrent or parallel sweeping is currently in progress. | 793 // True if concurrent or parallel sweeping is currently in progress. |
| 792 bool sweeping_pending_; | 794 bool sweeping_pending_; |
| 793 | 795 |
| 796 Semaphore pending_sweeper_jobs_semaphore_; |
| 797 |
| 794 bool sequential_sweeping_; | 798 bool sequential_sweeping_; |
| 795 | 799 |
| 796 // A pointer to the current stack-allocated GC tracer object during a full | 800 // A pointer to the current stack-allocated GC tracer object during a full |
| 797 // collection (NULL before and after). | 801 // collection (NULL before and after). |
| 798 GCTracer* tracer_; | 802 GCTracer* tracer_; |
| 799 | 803 |
| 800 SlotsBufferAllocator slots_buffer_allocator_; | 804 SlotsBufferAllocator slots_buffer_allocator_; |
| 801 | 805 |
| 802 SlotsBuffer* migration_slots_buffer_; | 806 SlotsBuffer* migration_slots_buffer_; |
| 803 | 807 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 void EvacuateNewSpace(); | 937 void EvacuateNewSpace(); |
| 934 | 938 |
| 935 void EvacuateLiveObjectsFromPage(Page* p); | 939 void EvacuateLiveObjectsFromPage(Page* p); |
| 936 | 940 |
| 937 void EvacuatePages(); | 941 void EvacuatePages(); |
| 938 | 942 |
| 939 void EvacuateNewSpaceAndCandidates(); | 943 void EvacuateNewSpaceAndCandidates(); |
| 940 | 944 |
| 941 void SweepSpace(PagedSpace* space, SweeperType sweeper); | 945 void SweepSpace(PagedSpace* space, SweeperType sweeper); |
| 942 | 946 |
| 947 // Finalizes the parallel sweeping phase. Marks all the pages that were |
| 948 // swept in parallel. |
| 949 void ParallelSweepSpacesComplete(); |
| 950 |
| 951 void ParallelSweepSpaceComplete(PagedSpace* space); |
| 952 |
| 943 #ifdef DEBUG | 953 #ifdef DEBUG |
| 944 friend class MarkObjectVisitor; | 954 friend class MarkObjectVisitor; |
| 945 static void VisitObject(HeapObject* obj); | 955 static void VisitObject(HeapObject* obj); |
| 946 | 956 |
| 947 friend class UnmarkObjectVisitor; | 957 friend class UnmarkObjectVisitor; |
| 948 static void UnmarkObject(HeapObject* obj); | 958 static void UnmarkObject(HeapObject* obj); |
| 949 #endif | 959 #endif |
| 950 | 960 |
| 951 Heap* heap_; | 961 Heap* heap_; |
| 952 MarkingDeque marking_deque_; | 962 MarkingDeque marking_deque_; |
| 953 CodeFlusher* code_flusher_; | 963 CodeFlusher* code_flusher_; |
| 954 Object* encountered_weak_collections_; | 964 Object* encountered_weak_collections_; |
| 955 bool have_code_to_deoptimize_; | 965 bool have_code_to_deoptimize_; |
| 956 | 966 |
| 957 List<Page*> evacuation_candidates_; | 967 List<Page*> evacuation_candidates_; |
| 958 List<Code*> invalidated_code_; | 968 List<Code*> invalidated_code_; |
| 959 | 969 |
| 970 SmartPointer<FreeList> free_list_old_data_space_; |
| 971 SmartPointer<FreeList> free_list_old_pointer_space_; |
| 972 |
| 960 friend class Heap; | 973 friend class Heap; |
| 961 }; | 974 }; |
| 962 | 975 |
| 963 | 976 |
| 964 class MarkBitCellIterator BASE_EMBEDDED { | 977 class MarkBitCellIterator BASE_EMBEDDED { |
| 965 public: | 978 public: |
| 966 explicit MarkBitCellIterator(MemoryChunk* chunk) | 979 explicit MarkBitCellIterator(MemoryChunk* chunk) |
| 967 : chunk_(chunk) { | 980 : chunk_(chunk) { |
| 968 last_cell_index_ = Bitmap::IndexToCell( | 981 last_cell_index_ = Bitmap::IndexToCell( |
| 969 Bitmap::CellAlignIndex( | 982 Bitmap::CellAlignIndex( |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1019 private: | 1032 private: |
| 1020 MarkCompactCollector* collector_; | 1033 MarkCompactCollector* collector_; |
| 1021 }; | 1034 }; |
| 1022 | 1035 |
| 1023 | 1036 |
| 1024 const char* AllocationSpaceName(AllocationSpace space); | 1037 const char* AllocationSpaceName(AllocationSpace space); |
| 1025 | 1038 |
| 1026 } } // namespace v8::internal | 1039 } } // namespace v8::internal |
| 1027 | 1040 |
| 1028 #endif // V8_MARK_COMPACT_H_ | 1041 #endif // V8_MARK_COMPACT_H_ |
| OLD | NEW |