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

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

Issue 2377513007: [heap] Decouple SpaceIterator from ObjectIterator. (Closed)
Patch Set: 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 | « no previous file | src/heap/heap.cc » ('j') | src/heap/spaces.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_HEAP_H_ 5 #ifndef V8_HEAP_HEAP_H_
6 #define V8_HEAP_HEAP_H_ 6 #define V8_HEAP_HEAP_H_
7 7
8 #include <cmath> 8 #include <cmath>
9 #include <map> 9 #include <map>
10 10
(...skipping 2114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2125 // and after context disposal. 2125 // and after context disposal.
2126 int number_of_disposed_maps_; 2126 int number_of_disposed_maps_;
2127 2127
2128 int global_ic_age_; 2128 int global_ic_age_;
2129 2129
2130 NewSpace* new_space_; 2130 NewSpace* new_space_;
2131 OldSpace* old_space_; 2131 OldSpace* old_space_;
2132 OldSpace* code_space_; 2132 OldSpace* code_space_;
2133 MapSpace* map_space_; 2133 MapSpace* map_space_;
2134 LargeObjectSpace* lo_space_; 2134 LargeObjectSpace* lo_space_;
2135 // Map from the space id to the space.
2136 Space* space_[LAST_SPACE + 1];
2135 HeapState gc_state_; 2137 HeapState gc_state_;
2136 int gc_post_processing_depth_; 2138 int gc_post_processing_depth_;
2137 Address new_space_top_after_last_gc_; 2139 Address new_space_top_after_last_gc_;
2138 2140
2139 // Returns the amount of external memory registered since last global gc. 2141 // Returns the amount of external memory registered since last global gc.
2140 int64_t PromotedExternalMemorySize(); 2142 int64_t PromotedExternalMemorySize();
2141 2143
2142 // How many "runtime allocations" happened. 2144 // How many "runtime allocations" happened.
2143 uint32_t allocations_count_; 2145 uint32_t allocations_count_;
2144 2146
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
2449 explicit PagedSpaces(Heap* heap) : heap_(heap), counter_(OLD_SPACE) {} 2451 explicit PagedSpaces(Heap* heap) : heap_(heap), counter_(OLD_SPACE) {}
2450 PagedSpace* next(); 2452 PagedSpace* next();
2451 2453
2452 private: 2454 private:
2453 Heap* heap_; 2455 Heap* heap_;
2454 int counter_; 2456 int counter_;
2455 }; 2457 };
2456 2458
2457 2459
2458 // Space iterator for iterating over all spaces of the heap. 2460 // Space iterator for iterating over all spaces of the heap.
2459 // For each space an object iterator is provided. The deallocation of the 2461 // For each space an object iterator is provided. The deallocation of the
Michael Lippautz 2016/09/27 13:53:05 nit: Outdated comment.
ulan 2016/09/27 14:10:53 Done.
2460 // returned object iterators is handled by the space iterator. 2462 // returned object iterators is handled by the space iterator.
2461 class SpaceIterator : public Malloced { 2463 class SpaceIterator : public Malloced {
2462 public: 2464 public:
2463 explicit SpaceIterator(Heap* heap); 2465 explicit SpaceIterator(Heap* heap);
2464 virtual ~SpaceIterator(); 2466 virtual ~SpaceIterator();
2465 2467
2466 bool has_next(); 2468 bool has_next();
2467 ObjectIterator* next(); 2469 Space* next();
2468 2470
2469 private: 2471 private:
2470 ObjectIterator* CreateIterator();
2471
2472 Heap* heap_; 2472 Heap* heap_;
2473 int current_space_; // from enum AllocationSpace. 2473 int current_space_; // from enum AllocationSpace.
2474 ObjectIterator* iterator_; // object iterator for the current space.
2475 }; 2474 };
2476 2475
2477 2476
2478 // A HeapIterator provides iteration over the whole heap. It 2477 // A HeapIterator provides iteration over the whole heap. It
2479 // aggregates the specific iterators for the different spaces as 2478 // aggregates the specific iterators for the different spaces as
2480 // these can only iterate over one space only. 2479 // these can only iterate over one space only.
2481 // 2480 //
2482 // HeapIterator ensures there is no allocation during its lifetime 2481 // HeapIterator ensures there is no allocation during its lifetime
2483 // (using an embedded DisallowHeapAllocation instance). 2482 // (using an embedded DisallowHeapAllocation instance).
2484 // 2483 //
(...skipping 25 matching lines...) Expand all
2510 // allocations. 2509 // allocations.
2511 MakeHeapIterableHelper make_heap_iterable_helper_; 2510 MakeHeapIterableHelper make_heap_iterable_helper_;
2512 DisallowHeapAllocation no_heap_allocation_; 2511 DisallowHeapAllocation no_heap_allocation_;
2513 2512
2514 Heap* heap_; 2513 Heap* heap_;
2515 HeapObjectsFiltering filtering_; 2514 HeapObjectsFiltering filtering_;
2516 HeapObjectsFilter* filter_; 2515 HeapObjectsFilter* filter_;
2517 // Space iterator for iterating all the spaces. 2516 // Space iterator for iterating all the spaces.
2518 SpaceIterator* space_iterator_; 2517 SpaceIterator* space_iterator_;
2519 // Object iterator for the space currently being iterated. 2518 // Object iterator for the space currently being iterated.
2520 ObjectIterator* object_iterator_; 2519 std::unique_ptr<ObjectIterator> object_iterator_;
2521 }; 2520 };
2522 2521
2523 // Abstract base class for checking whether a weak object should be retained. 2522 // Abstract base class for checking whether a weak object should be retained.
2524 class WeakObjectRetainer { 2523 class WeakObjectRetainer {
2525 public: 2524 public:
2526 virtual ~WeakObjectRetainer() {} 2525 virtual ~WeakObjectRetainer() {}
2527 2526
2528 // Return whether this object should be retained. If NULL is returned the 2527 // Return whether this object should be retained. If NULL is returned the
2529 // object has no references. Otherwise the address of the retained object 2528 // object has no references. Otherwise the address of the retained object
2530 // should be returned as in some GC situations the object has been moved. 2529 // should be returned as in some GC situations the object has been moved.
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
2641 friend class LargeObjectSpace; 2640 friend class LargeObjectSpace;
2642 friend class NewSpace; 2641 friend class NewSpace;
2643 friend class PagedSpace; 2642 friend class PagedSpace;
2644 DISALLOW_COPY_AND_ASSIGN(AllocationObserver); 2643 DISALLOW_COPY_AND_ASSIGN(AllocationObserver);
2645 }; 2644 };
2646 2645
2647 } // namespace internal 2646 } // namespace internal
2648 } // namespace v8 2647 } // namespace v8
2649 2648
2650 #endif // V8_HEAP_HEAP_H_ 2649 #endif // V8_HEAP_HEAP_H_
OLDNEW
« no previous file with comments | « no previous file | src/heap/heap.cc » ('j') | src/heap/spaces.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698