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

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

Issue 1281903002: [heap] Remove unused support for heap iterator size function. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_cleanup-mark-compact-3
Patch Set: Created 5 years, 4 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 "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/base/atomicops.h" 9 #include "src/base/atomicops.h"
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 // 1233 //
1234 // A HeapObjectIterator iterates objects from the bottom of the given space 1234 // A HeapObjectIterator iterates objects from the bottom of the given space
1235 // to its top or from the bottom of the given page to its top. 1235 // to its top or from the bottom of the given page to its top.
1236 // 1236 //
1237 // If objects are allocated in the page during iteration the iterator may 1237 // If objects are allocated in the page during iteration the iterator may
1238 // or may not iterate over those objects. The caller must create a new 1238 // or may not iterate over those objects. The caller must create a new
1239 // iterator in order to be sure to visit these new objects. 1239 // iterator in order to be sure to visit these new objects.
1240 class HeapObjectIterator : public ObjectIterator { 1240 class HeapObjectIterator : public ObjectIterator {
1241 public: 1241 public:
1242 // Creates a new object iterator in a given space. 1242 // Creates a new object iterator in a given space.
1243 // If the size function is not given, the iterator calls the default
1244 // Object::Size().
1245 explicit HeapObjectIterator(PagedSpace* space); 1243 explicit HeapObjectIterator(PagedSpace* space);
1246 HeapObjectIterator(PagedSpace* space, HeapObjectCallback size_func); 1244 explicit HeapObjectIterator(Page* page);
1247 HeapObjectIterator(Page* page, HeapObjectCallback size_func);
1248 1245
1249 // Advance to the next object, skipping free spaces and other fillers and 1246 // Advance to the next object, skipping free spaces and other fillers and
1250 // skipping the special garbage section of which there is one per space. 1247 // skipping the special garbage section of which there is one per space.
1251 // Returns NULL when the iteration has ended. 1248 // Returns NULL when the iteration has ended.
1252 inline HeapObject* Next() { 1249 inline HeapObject* Next() {
1253 do { 1250 do {
1254 HeapObject* next_obj = FromCurrentPage(); 1251 HeapObject* next_obj = FromCurrentPage();
1255 if (next_obj != NULL) return next_obj; 1252 if (next_obj != NULL) return next_obj;
1256 } while (AdvanceToNextPage()); 1253 } while (AdvanceToNextPage());
1257 return NULL; 1254 return NULL;
1258 } 1255 }
1259 1256
1260 virtual HeapObject* next_object() { return Next(); } 1257 virtual HeapObject* next_object() { return Next(); }
1261 1258
1262 private: 1259 private:
1263 enum PageMode { kOnePageOnly, kAllPagesInSpace }; 1260 enum PageMode { kOnePageOnly, kAllPagesInSpace };
1264 1261
1265 Address cur_addr_; // Current iteration point. 1262 Address cur_addr_; // Current iteration point.
1266 Address cur_end_; // End iteration point. 1263 Address cur_end_; // End iteration point.
1267 HeapObjectCallback size_func_; // Size function or NULL.
1268 PagedSpace* space_; 1264 PagedSpace* space_;
1269 PageMode page_mode_; 1265 PageMode page_mode_;
1270 1266
1271 // Fast (inlined) path of next(). 1267 // Fast (inlined) path of next().
1272 inline HeapObject* FromCurrentPage(); 1268 inline HeapObject* FromCurrentPage();
1273 1269
1274 // Slow path of next(), goes into the next page. Returns false if the 1270 // Slow path of next(), goes into the next page. Returns false if the
1275 // iteration has ended. 1271 // iteration has ended.
1276 bool AdvanceToNextPage(); 1272 bool AdvanceToNextPage();
1277 1273
1278 // Initializes fields. 1274 // Initializes fields.
1279 inline void Initialize(PagedSpace* owner, Address start, Address end, 1275 inline void Initialize(PagedSpace* owner, Address start, Address end,
1280 PageMode mode, HeapObjectCallback size_func); 1276 PageMode mode);
1281 }; 1277 };
1282 1278
1283 1279
1284 // ----------------------------------------------------------------------------- 1280 // -----------------------------------------------------------------------------
1285 // A PageIterator iterates the pages in a paged space. 1281 // A PageIterator iterates the pages in a paged space.
1286 1282
1287 class PageIterator BASE_EMBEDDED { 1283 class PageIterator BASE_EMBEDDED {
1288 public: 1284 public:
1289 explicit inline PageIterator(PagedSpace* space); 1285 explicit inline PageIterator(PagedSpace* space);
1290 1286
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
2272 2268
2273 2269
2274 // A SemiSpaceIterator is an ObjectIterator that iterates over the active 2270 // A SemiSpaceIterator is an ObjectIterator that iterates over the active
2275 // semispace of the heap's new space. It iterates over the objects in the 2271 // semispace of the heap's new space. It iterates over the objects in the
2276 // semispace from a given start address (defaulting to the bottom of the 2272 // semispace from a given start address (defaulting to the bottom of the
2277 // semispace) to the top of the semispace. New objects allocated after the 2273 // semispace) to the top of the semispace. New objects allocated after the
2278 // iterator is created are not iterated. 2274 // iterator is created are not iterated.
2279 class SemiSpaceIterator : public ObjectIterator { 2275 class SemiSpaceIterator : public ObjectIterator {
2280 public: 2276 public:
2281 // Create an iterator over the objects in the given space. If no start 2277 // Create an iterator over the objects in the given space. If no start
2282 // address is given, the iterator starts from the bottom of the space. If 2278 // address is given, the iterator starts from the bottom of the space.
2283 // no size function is given, the iterator calls Object::Size().
2284 2279
2285 // Iterate over all of allocated to-space. 2280 // Iterate over all of allocated to-space.
2286 explicit SemiSpaceIterator(NewSpace* space); 2281 explicit SemiSpaceIterator(NewSpace* space);
2287 // Iterate over all of allocated to-space, with a custome size function.
2288 SemiSpaceIterator(NewSpace* space, HeapObjectCallback size_func);
2289 // Iterate over part of allocated to-space, from start to the end 2282 // Iterate over part of allocated to-space, from start to the end
2290 // of allocation. 2283 // of allocation.
2291 SemiSpaceIterator(NewSpace* space, Address start); 2284 SemiSpaceIterator(NewSpace* space, Address start);
2292 // Iterate from one address to another in the same semi-space. 2285 // Iterate from one address to another in the same semi-space.
2293 SemiSpaceIterator(Address from, Address to); 2286 SemiSpaceIterator(Address from, Address to);
2294 2287
2295 HeapObject* Next() { 2288 HeapObject* Next() {
2296 if (current_ == limit_) return NULL; 2289 if (current_ == limit_) return NULL;
2297 if (NewSpacePage::IsAtEnd(current_)) { 2290 if (NewSpacePage::IsAtEnd(current_)) {
2298 NewSpacePage* page = NewSpacePage::FromLimit(current_); 2291 NewSpacePage* page = NewSpacePage::FromLimit(current_);
2299 page = page->next_page(); 2292 page = page->next_page();
2300 DCHECK(!page->is_anchor()); 2293 DCHECK(!page->is_anchor());
2301 current_ = page->area_start(); 2294 current_ = page->area_start();
2302 if (current_ == limit_) return NULL; 2295 if (current_ == limit_) return NULL;
2303 } 2296 }
2304 2297
2305 HeapObject* object = HeapObject::FromAddress(current_); 2298 HeapObject* object = HeapObject::FromAddress(current_);
2306 int size = (size_func_ == NULL) ? object->Size() : size_func_(object); 2299 int size = object->Size();
2307 2300
2308 current_ += size; 2301 current_ += size;
2309 return object; 2302 return object;
2310 } 2303 }
2311 2304
2312 // Implementation of the ObjectIterator functions. 2305 // Implementation of the ObjectIterator functions.
2313 virtual HeapObject* next_object() { return Next(); } 2306 virtual HeapObject* next_object() { return Next(); }
2314 2307
2315 private: 2308 private:
2316 void Initialize(Address start, Address end, HeapObjectCallback size_func); 2309 void Initialize(Address start, Address end);
2317 2310
2318 // The current iteration point. 2311 // The current iteration point.
2319 Address current_; 2312 Address current_;
2320 // The end of iteration. 2313 // The end of iteration.
2321 Address limit_; 2314 Address limit_;
2322 // The callback function.
2323 HeapObjectCallback size_func_;
2324 }; 2315 };
2325 2316
2326 2317
2327 // ----------------------------------------------------------------------------- 2318 // -----------------------------------------------------------------------------
2328 // A PageIterator iterates the pages in a semi-space. 2319 // A PageIterator iterates the pages in a semi-space.
2329 class NewSpacePageIterator BASE_EMBEDDED { 2320 class NewSpacePageIterator BASE_EMBEDDED {
2330 public: 2321 public:
2331 // Make an iterator that runs over all pages in to-space. 2322 // Make an iterator that runs over all pages in to-space.
2332 explicit inline NewSpacePageIterator(NewSpace* space); 2323 explicit inline NewSpacePageIterator(NewSpace* space);
2333 2324
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
2811 // Map MemoryChunk::kAlignment-aligned chunks to large pages covering them 2802 // Map MemoryChunk::kAlignment-aligned chunks to large pages covering them
2812 HashMap chunk_map_; 2803 HashMap chunk_map_;
2813 2804
2814 friend class LargeObjectIterator; 2805 friend class LargeObjectIterator;
2815 }; 2806 };
2816 2807
2817 2808
2818 class LargeObjectIterator : public ObjectIterator { 2809 class LargeObjectIterator : public ObjectIterator {
2819 public: 2810 public:
2820 explicit LargeObjectIterator(LargeObjectSpace* space); 2811 explicit LargeObjectIterator(LargeObjectSpace* space);
2821 LargeObjectIterator(LargeObjectSpace* space, HeapObjectCallback size_func);
2822 2812
2823 HeapObject* Next(); 2813 HeapObject* Next();
2824 2814
2825 // implementation of ObjectIterator. 2815 // implementation of ObjectIterator.
2826 virtual HeapObject* next_object() { return Next(); } 2816 virtual HeapObject* next_object() { return Next(); }
2827 2817
2828 private: 2818 private:
2829 LargePage* current_; 2819 LargePage* current_;
2830 HeapObjectCallback size_func_;
2831 }; 2820 };
2832 2821
2833 2822
2834 // Iterates over the chunks (pages and large object pages) that can contain 2823 // Iterates over the chunks (pages and large object pages) that can contain
2835 // pointers to new space. 2824 // pointers to new space.
2836 class PointerChunkIterator BASE_EMBEDDED { 2825 class PointerChunkIterator BASE_EMBEDDED {
2837 public: 2826 public:
2838 inline explicit PointerChunkIterator(Heap* heap); 2827 inline explicit PointerChunkIterator(Heap* heap);
2839 2828
2840 // Return NULL when the iterator is done. 2829 // Return NULL when the iterator is done.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2898 count = 0; 2887 count = 0;
2899 } 2888 }
2900 // Must be small, since an iteration is used for lookup. 2889 // Must be small, since an iteration is used for lookup.
2901 static const int kMaxComments = 64; 2890 static const int kMaxComments = 64;
2902 }; 2891 };
2903 #endif 2892 #endif
2904 } 2893 }
2905 } // namespace v8::internal 2894 } // namespace v8::internal
2906 2895
2907 #endif // V8_HEAP_SPACES_H_ 2896 #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