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

Side by Side Diff: src/heap/spaces.h

Issue 2377513007: [heap] Decouple SpaceIterator from ObjectIterator. (Closed)
Patch Set: rebase Created 4 years, 2 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
« no previous file with comments | « src/heap/mark-compact.cc ('k') | src/heap/spaces.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 virtual intptr_t Available() = 0; 936 virtual intptr_t Available() = 0;
937 937
938 virtual int RoundSizeDownToObjectAlignment(int size) { 938 virtual int RoundSizeDownToObjectAlignment(int size) {
939 if (id_ == CODE_SPACE) { 939 if (id_ == CODE_SPACE) {
940 return RoundDown(size, kCodeAlignment); 940 return RoundDown(size, kCodeAlignment);
941 } else { 941 } else {
942 return RoundDown(size, kPointerSize); 942 return RoundDown(size, kPointerSize);
943 } 943 }
944 } 944 }
945 945
946 virtual std::unique_ptr<ObjectIterator> GetObjectIterator() = 0;
947
946 void AccountCommitted(intptr_t bytes) { 948 void AccountCommitted(intptr_t bytes) {
947 DCHECK_GE(bytes, 0); 949 DCHECK_GE(bytes, 0);
948 committed_ += bytes; 950 committed_ += bytes;
949 if (committed_ > max_committed_) { 951 if (committed_ > max_committed_) {
950 max_committed_ = committed_; 952 max_committed_ = committed_;
951 } 953 }
952 } 954 }
953 955
954 void AccountUncommitted(intptr_t bytes) { 956 void AccountUncommitted(intptr_t bytes) {
955 DCHECK_GE(bytes, 0); 957 DCHECK_GE(bytes, 0);
(...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after
2147 inline void UnlinkFreeListCategories(Page* page); 2149 inline void UnlinkFreeListCategories(Page* page);
2148 inline intptr_t RelinkFreeListCategories(Page* page); 2150 inline intptr_t RelinkFreeListCategories(Page* page);
2149 2151
2150 iterator begin() { return iterator(anchor_.next_page()); } 2152 iterator begin() { return iterator(anchor_.next_page()); }
2151 iterator end() { return iterator(&anchor_); } 2153 iterator end() { return iterator(&anchor_); }
2152 2154
2153 // Shrink immortal immovable pages of the space to be exactly the size needed 2155 // Shrink immortal immovable pages of the space to be exactly the size needed
2154 // using the high water mark. 2156 // using the high water mark.
2155 void ShrinkImmortalImmovablePages(); 2157 void ShrinkImmortalImmovablePages();
2156 2158
2159 std::unique_ptr<ObjectIterator> GetObjectIterator() override;
2160
2157 protected: 2161 protected:
2158 // PagedSpaces that should be included in snapshots have different, i.e., 2162 // PagedSpaces that should be included in snapshots have different, i.e.,
2159 // smaller, initial pages. 2163 // smaller, initial pages.
2160 virtual bool snapshotable() { return true; } 2164 virtual bool snapshotable() { return true; }
2161 2165
2162 bool HasPages() { return anchor_.next_page() != &anchor_; } 2166 bool HasPages() { return anchor_.next_page() != &anchor_; }
2163 2167
2164 // Cleans up the space, frees all pages in this space except those belonging 2168 // Cleans up the space, frees all pages in this space except those belonging
2165 // to the initial chunk, uncommits addresses in the initial chunk. 2169 // to the initial chunk, uncommits addresses in the initial chunk.
2166 void TearDown(); 2170 void TearDown();
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2322 return 0; 2326 return 0;
2323 } 2327 }
2324 2328
2325 intptr_t SizeOfObjects() override { return Size(); } 2329 intptr_t SizeOfObjects() override { return Size(); }
2326 2330
2327 intptr_t Available() override { 2331 intptr_t Available() override {
2328 UNREACHABLE(); 2332 UNREACHABLE();
2329 return 0; 2333 return 0;
2330 } 2334 }
2331 2335
2336 iterator begin() { return iterator(anchor_.next_page()); }
2337 iterator end() { return iterator(anchor()); }
2338
2339 std::unique_ptr<ObjectIterator> GetObjectIterator() override;
2340
2332 #ifdef DEBUG 2341 #ifdef DEBUG
2333 void Print() override; 2342 void Print() override;
2334 // Validate a range of of addresses in a SemiSpace. 2343 // Validate a range of of addresses in a SemiSpace.
2335 // The "from" address must be on a page prior to the "to" address, 2344 // The "from" address must be on a page prior to the "to" address,
2336 // in the linked page order, or it must be earlier on the same page. 2345 // in the linked page order, or it must be earlier on the same page.
2337 static void AssertValidRange(Address from, Address to); 2346 static void AssertValidRange(Address from, Address to);
2338 #else 2347 #else
2339 // Do nothing. 2348 // Do nothing.
2340 inline static void AssertValidRange(Address from, Address to) {} 2349 inline static void AssertValidRange(Address from, Address to) {}
2341 #endif 2350 #endif
2342 2351
2343 #ifdef VERIFY_HEAP 2352 #ifdef VERIFY_HEAP
2344 virtual void Verify(); 2353 virtual void Verify();
2345 #endif 2354 #endif
2346 2355
2347 iterator begin() { return iterator(anchor_.next_page()); }
2348 iterator end() { return iterator(anchor()); }
2349
2350 private: 2356 private:
2351 void RewindPages(Page* start, int num_pages); 2357 void RewindPages(Page* start, int num_pages);
2352 2358
2353 inline Page* anchor() { return &anchor_; } 2359 inline Page* anchor() { return &anchor_; }
2354 inline int max_pages() { return current_capacity_ / Page::kPageSize; } 2360 inline int max_pages() { return current_capacity_ / Page::kPageSize; }
2355 2361
2356 // Copies the flags into the masked positions on all pages in the space. 2362 // Copies the flags into the masked positions on all pages in the space.
2357 void FixPagesFlags(intptr_t flags, intptr_t flag_mask); 2363 void FixPagesFlags(intptr_t flags, intptr_t flag_mask);
2358 2364
2359 // The currently committed space capacity. 2365 // The currently committed space capacity.
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
2641 bool IsFromSpaceCommitted() { return from_space_.is_committed(); } 2647 bool IsFromSpaceCommitted() { return from_space_.is_committed(); }
2642 2648
2643 SemiSpace* active_space() { return &to_space_; } 2649 SemiSpace* active_space() { return &to_space_; }
2644 2650
2645 void PauseAllocationObservers() override; 2651 void PauseAllocationObservers() override;
2646 void ResumeAllocationObservers() override; 2652 void ResumeAllocationObservers() override;
2647 2653
2648 iterator begin() { return to_space_.begin(); } 2654 iterator begin() { return to_space_.begin(); }
2649 iterator end() { return to_space_.end(); } 2655 iterator end() { return to_space_.end(); }
2650 2656
2657 std::unique_ptr<ObjectIterator> GetObjectIterator() override;
2658
2651 private: 2659 private:
2652 // Update allocation info to match the current to-space page. 2660 // Update allocation info to match the current to-space page.
2653 void UpdateAllocationInfo(); 2661 void UpdateAllocationInfo();
2654 2662
2655 base::Mutex mutex_; 2663 base::Mutex mutex_;
2656 2664
2657 // The semispaces. 2665 // The semispaces.
2658 SemiSpace to_space_; 2666 SemiSpace to_space_;
2659 SemiSpace from_space_; 2667 SemiSpace from_space_;
2660 base::VirtualMemory reservation_; 2668 base::VirtualMemory reservation_;
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
2856 void AdjustLiveBytes(int by) { objects_size_ += by; } 2864 void AdjustLiveBytes(int by) { objects_size_ += by; }
2857 2865
2858 LargePage* first_page() { return first_page_; } 2866 LargePage* first_page() { return first_page_; }
2859 2867
2860 // Collect code statistics. 2868 // Collect code statistics.
2861 void CollectCodeStatistics(); 2869 void CollectCodeStatistics();
2862 2870
2863 iterator begin() { return iterator(first_page_); } 2871 iterator begin() { return iterator(first_page_); }
2864 iterator end() { return iterator(nullptr); } 2872 iterator end() { return iterator(nullptr); }
2865 2873
2874 std::unique_ptr<ObjectIterator> GetObjectIterator() override;
2875
2866 #ifdef VERIFY_HEAP 2876 #ifdef VERIFY_HEAP
2867 virtual void Verify(); 2877 virtual void Verify();
2868 #endif 2878 #endif
2869 2879
2870 #ifdef DEBUG 2880 #ifdef DEBUG
2871 void Print() override; 2881 void Print() override;
2872 void ReportStatistics(); 2882 void ReportStatistics();
2873 #endif 2883 #endif
2874 2884
2875 private: 2885 private:
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2917 PageIterator old_iterator_; 2927 PageIterator old_iterator_;
2918 PageIterator code_iterator_; 2928 PageIterator code_iterator_;
2919 PageIterator map_iterator_; 2929 PageIterator map_iterator_;
2920 LargePageIterator lo_iterator_; 2930 LargePageIterator lo_iterator_;
2921 }; 2931 };
2922 2932
2923 } // namespace internal 2933 } // namespace internal
2924 } // namespace v8 2934 } // namespace v8
2925 2935
2926 #endif // V8_HEAP_SPACES_H_ 2936 #endif // V8_HEAP_SPACES_H_
OLDNEW
« no previous file with comments | « src/heap/mark-compact.cc ('k') | src/heap/spaces.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698