OLD | NEW |
---|---|
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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_SPACES_H_ | 5 #ifndef V8_HEAP_SPACES_H_ |
6 #define V8_HEAP_SPACES_H_ | 6 #define V8_HEAP_SPACES_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <memory> | 9 #include <memory> |
10 #include <unordered_set> | 10 #include <unordered_set> |
(...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
928 virtual intptr_t Available() = 0; | 928 virtual intptr_t Available() = 0; |
929 | 929 |
930 virtual int RoundSizeDownToObjectAlignment(int size) { | 930 virtual int RoundSizeDownToObjectAlignment(int size) { |
931 if (id_ == CODE_SPACE) { | 931 if (id_ == CODE_SPACE) { |
932 return RoundDown(size, kCodeAlignment); | 932 return RoundDown(size, kCodeAlignment); |
933 } else { | 933 } else { |
934 return RoundDown(size, kPointerSize); | 934 return RoundDown(size, kPointerSize); |
935 } | 935 } |
936 } | 936 } |
937 | 937 |
938 virtual std::unique_ptr<ObjectIterator> GetObjectIterator() = 0; | |
939 | |
938 void AccountCommitted(intptr_t bytes) { | 940 void AccountCommitted(intptr_t bytes) { |
939 DCHECK_GE(bytes, 0); | 941 DCHECK_GE(bytes, 0); |
940 committed_ += bytes; | 942 committed_ += bytes; |
941 if (committed_ > max_committed_) { | 943 if (committed_ > max_committed_) { |
942 max_committed_ = committed_; | 944 max_committed_ = committed_; |
943 } | 945 } |
944 } | 946 } |
945 | 947 |
946 void AccountUncommitted(intptr_t bytes) { | 948 void AccountUncommitted(intptr_t bytes) { |
947 DCHECK_GE(bytes, 0); | 949 DCHECK_GE(bytes, 0); |
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2139 inline void UnlinkFreeListCategories(Page* page); | 2141 inline void UnlinkFreeListCategories(Page* page); |
2140 inline intptr_t RelinkFreeListCategories(Page* page); | 2142 inline intptr_t RelinkFreeListCategories(Page* page); |
2141 | 2143 |
2142 iterator begin() { return iterator(anchor_.next_page()); } | 2144 iterator begin() { return iterator(anchor_.next_page()); } |
2143 iterator end() { return iterator(&anchor_); } | 2145 iterator end() { return iterator(&anchor_); } |
2144 | 2146 |
2145 // Shrink immortal immovable pages of the space to be exactly the size needed | 2147 // Shrink immortal immovable pages of the space to be exactly the size needed |
2146 // using the high water mark. | 2148 // using the high water mark. |
2147 void ShrinkImmortalImmovablePages(); | 2149 void ShrinkImmortalImmovablePages(); |
2148 | 2150 |
2151 std::unique_ptr<ObjectIterator> GetObjectIterator() override; | |
2152 | |
2149 protected: | 2153 protected: |
2150 // PagedSpaces that should be included in snapshots have different, i.e., | 2154 // PagedSpaces that should be included in snapshots have different, i.e., |
2151 // smaller, initial pages. | 2155 // smaller, initial pages. |
2152 virtual bool snapshotable() { return true; } | 2156 virtual bool snapshotable() { return true; } |
2153 | 2157 |
2154 bool HasPages() { return anchor_.next_page() != &anchor_; } | 2158 bool HasPages() { return anchor_.next_page() != &anchor_; } |
2155 | 2159 |
2156 // Cleans up the space, frees all pages in this space except those belonging | 2160 // Cleans up the space, frees all pages in this space except those belonging |
2157 // to the initial chunk, uncommits addresses in the initial chunk. | 2161 // to the initial chunk, uncommits addresses in the initial chunk. |
2158 void TearDown(); | 2162 void TearDown(); |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2337 inline static void AssertValidRange(Address from, Address to) {} | 2341 inline static void AssertValidRange(Address from, Address to) {} |
2338 #endif | 2342 #endif |
2339 | 2343 |
2340 #ifdef VERIFY_HEAP | 2344 #ifdef VERIFY_HEAP |
2341 virtual void Verify(); | 2345 virtual void Verify(); |
2342 #endif | 2346 #endif |
2343 | 2347 |
2344 iterator begin() { return iterator(anchor_.next_page()); } | 2348 iterator begin() { return iterator(anchor_.next_page()); } |
2345 iterator end() { return iterator(anchor()); } | 2349 iterator end() { return iterator(anchor()); } |
2346 | 2350 |
2351 std::unique_ptr<ObjectIterator> GetObjectIterator() override; | |
Michael Lippautz
2016/09/27 13:53:05
While you are here, can you move this line and the
ulan
2016/09/27 14:10:53
Done.
| |
2352 | |
2347 private: | 2353 private: |
2348 void RewindPages(Page* start, int num_pages); | 2354 void RewindPages(Page* start, int num_pages); |
2349 | 2355 |
2350 inline Page* anchor() { return &anchor_; } | 2356 inline Page* anchor() { return &anchor_; } |
2351 inline int max_pages() { return current_capacity_ / Page::kPageSize; } | 2357 inline int max_pages() { return current_capacity_ / Page::kPageSize; } |
2352 | 2358 |
2353 // Copies the flags into the masked positions on all pages in the space. | 2359 // Copies the flags into the masked positions on all pages in the space. |
2354 void FixPagesFlags(intptr_t flags, intptr_t flag_mask); | 2360 void FixPagesFlags(intptr_t flags, intptr_t flag_mask); |
2355 | 2361 |
2356 // The currently committed space capacity. | 2362 // The currently committed space capacity. |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2668 bool IsFromSpaceCommitted() { return from_space_.is_committed(); } | 2674 bool IsFromSpaceCommitted() { return from_space_.is_committed(); } |
2669 | 2675 |
2670 SemiSpace* active_space() { return &to_space_; } | 2676 SemiSpace* active_space() { return &to_space_; } |
2671 | 2677 |
2672 void PauseAllocationObservers() override; | 2678 void PauseAllocationObservers() override; |
2673 void ResumeAllocationObservers() override; | 2679 void ResumeAllocationObservers() override; |
2674 | 2680 |
2675 iterator begin() { return to_space_.begin(); } | 2681 iterator begin() { return to_space_.begin(); } |
2676 iterator end() { return to_space_.end(); } | 2682 iterator end() { return to_space_.end(); } |
2677 | 2683 |
2684 std::unique_ptr<ObjectIterator> GetObjectIterator() override; | |
2685 | |
2678 private: | 2686 private: |
2679 // Update allocation info to match the current to-space page. | 2687 // Update allocation info to match the current to-space page. |
2680 void UpdateAllocationInfo(); | 2688 void UpdateAllocationInfo(); |
2681 | 2689 |
2682 base::Mutex mutex_; | 2690 base::Mutex mutex_; |
2683 | 2691 |
2684 // The semispaces. | 2692 // The semispaces. |
2685 SemiSpace to_space_; | 2693 SemiSpace to_space_; |
2686 SemiSpace from_space_; | 2694 SemiSpace from_space_; |
2687 base::VirtualMemory reservation_; | 2695 base::VirtualMemory reservation_; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2881 void AdjustLiveBytes(int by) { objects_size_ += by; } | 2889 void AdjustLiveBytes(int by) { objects_size_ += by; } |
2882 | 2890 |
2883 LargePage* first_page() { return first_page_; } | 2891 LargePage* first_page() { return first_page_; } |
2884 | 2892 |
2885 // Collect code statistics. | 2893 // Collect code statistics. |
2886 void CollectCodeStatistics(); | 2894 void CollectCodeStatistics(); |
2887 | 2895 |
2888 iterator begin() { return iterator(first_page_); } | 2896 iterator begin() { return iterator(first_page_); } |
2889 iterator end() { return iterator(nullptr); } | 2897 iterator end() { return iterator(nullptr); } |
2890 | 2898 |
2899 std::unique_ptr<ObjectIterator> GetObjectIterator() override; | |
2900 | |
2891 #ifdef VERIFY_HEAP | 2901 #ifdef VERIFY_HEAP |
2892 virtual void Verify(); | 2902 virtual void Verify(); |
2893 #endif | 2903 #endif |
2894 | 2904 |
2895 #ifdef DEBUG | 2905 #ifdef DEBUG |
2896 void Print() override; | 2906 void Print() override; |
2897 void ReportStatistics(); | 2907 void ReportStatistics(); |
2898 #endif | 2908 #endif |
2899 | 2909 |
2900 private: | 2910 private: |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2942 PageIterator old_iterator_; | 2952 PageIterator old_iterator_; |
2943 PageIterator code_iterator_; | 2953 PageIterator code_iterator_; |
2944 PageIterator map_iterator_; | 2954 PageIterator map_iterator_; |
2945 LargePageIterator lo_iterator_; | 2955 LargePageIterator lo_iterator_; |
2946 }; | 2956 }; |
2947 | 2957 |
2948 } // namespace internal | 2958 } // namespace internal |
2949 } // namespace v8 | 2959 } // namespace v8 |
2950 | 2960 |
2951 #endif // V8_HEAP_SPACES_H_ | 2961 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |