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 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 1602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1613 // iteration has ended. | 1613 // iteration has ended. |
1614 bool AdvanceToNextPage(); | 1614 bool AdvanceToNextPage(); |
1615 | 1615 |
1616 // Initializes fields. | 1616 // Initializes fields. |
1617 inline void Initialize(PagedSpace* owner, Address start, Address end, | 1617 inline void Initialize(PagedSpace* owner, Address start, Address end, |
1618 PageMode mode); | 1618 PageMode mode); |
1619 }; | 1619 }; |
1620 | 1620 |
1621 | 1621 |
1622 // ----------------------------------------------------------------------------- | 1622 // ----------------------------------------------------------------------------- |
1623 // A PageIterator iterates the pages in a paged space. | |
1624 | |
1625 class PageIterator BASE_EMBEDDED { | |
1626 public: | |
1627 explicit inline PageIterator(PagedSpace* space); | |
1628 | |
1629 inline bool has_next(); | |
1630 inline Page* next(); | |
1631 | |
1632 private: | |
1633 PagedSpace* space_; | |
1634 Page* prev_page_; // Previous page returned. | |
1635 // Next page that will be returned. Cached here so that we can use this | |
1636 // iterator for operations that deallocate pages. | |
1637 Page* next_page_; | |
1638 }; | |
1639 | |
1640 | |
1641 // ----------------------------------------------------------------------------- | |
1642 // A space has a circular list of pages. The next page can be accessed via | 1623 // A space has a circular list of pages. The next page can be accessed via |
1643 // Page::next_page() call. | 1624 // Page::next_page() call. |
1644 | 1625 |
1645 // An abstraction of allocation and relocation pointers in a page-structured | 1626 // An abstraction of allocation and relocation pointers in a page-structured |
1646 // space. | 1627 // space. |
1647 class AllocationInfo { | 1628 class AllocationInfo { |
1648 public: | 1629 public: |
1649 AllocationInfo() : top_(nullptr), limit_(nullptr) {} | 1630 AllocationInfo() : top_(nullptr), limit_(nullptr) {} |
1650 AllocationInfo(Address top, Address limit) : top_(top), limit_(limit) {} | 1631 AllocationInfo(Address top, Address limit) : top_(top), limit_(limit) {} |
1651 | 1632 |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2079 | 2060 |
2080 private: | 2061 private: |
2081 LocalAllocationBuffer(Heap* heap, AllocationInfo allocation_info); | 2062 LocalAllocationBuffer(Heap* heap, AllocationInfo allocation_info); |
2082 | 2063 |
2083 void Close(); | 2064 void Close(); |
2084 | 2065 |
2085 Heap* heap_; | 2066 Heap* heap_; |
2086 AllocationInfo allocation_info_; | 2067 AllocationInfo allocation_info_; |
2087 }; | 2068 }; |
2088 | 2069 |
| 2070 template <class PAGE_TYPE> |
| 2071 class PageIteratorImpl |
| 2072 : public std::iterator<std::forward_iterator_tag, PAGE_TYPE> { |
| 2073 public: |
| 2074 explicit PageIteratorImpl(PAGE_TYPE* p) : p_(p) {} |
| 2075 PageIteratorImpl(const PageIteratorImpl<PAGE_TYPE>& other) : p_(other.p_) {} |
| 2076 PAGE_TYPE* operator*() { return p_; } |
| 2077 bool operator==(const PageIteratorImpl<PAGE_TYPE>& rhs) { |
| 2078 return rhs.p_ == p_; |
| 2079 } |
| 2080 bool operator!=(const PageIteratorImpl<PAGE_TYPE>& rhs) { |
| 2081 return rhs.p_ != p_; |
| 2082 } |
| 2083 inline PageIteratorImpl<PAGE_TYPE>& operator++(); |
| 2084 inline PageIteratorImpl<PAGE_TYPE> operator++(int); |
| 2085 |
| 2086 private: |
| 2087 PAGE_TYPE* p_; |
| 2088 }; |
| 2089 |
| 2090 typedef PageIteratorImpl<Page> PageIterator; |
| 2091 typedef PageIteratorImpl<LargePage> LargePageIterator; |
| 2092 |
| 2093 class NewSpacePageRange { |
| 2094 public: |
| 2095 typedef PageIterator iterator; |
| 2096 |
| 2097 inline NewSpacePageRange(Address start, Address limit); |
| 2098 |
| 2099 iterator begin() { return iterator(Page::FromAddress(start_)); } |
| 2100 iterator end() { |
| 2101 return iterator(Page::FromAllocationAreaAddress(limit_)->next_page()); |
| 2102 } |
| 2103 |
| 2104 private: |
| 2105 Address start_; |
| 2106 Address limit_; |
| 2107 }; |
| 2108 |
2089 class PagedSpace : public Space { | 2109 class PagedSpace : public Space { |
2090 public: | 2110 public: |
| 2111 typedef PageIterator iterator; |
| 2112 |
2091 static const intptr_t kCompactionMemoryWanted = 500 * KB; | 2113 static const intptr_t kCompactionMemoryWanted = 500 * KB; |
2092 | 2114 |
2093 // Creates a space with an id. | 2115 // Creates a space with an id. |
2094 PagedSpace(Heap* heap, AllocationSpace id, Executability executable); | 2116 PagedSpace(Heap* heap, AllocationSpace id, Executability executable); |
2095 | 2117 |
2096 ~PagedSpace() override { TearDown(); } | 2118 ~PagedSpace() override { TearDown(); } |
2097 | 2119 |
2098 // Set up the space using the given address range of virtual memory (from | 2120 // Set up the space using the given address range of virtual memory (from |
2099 // the memory allocator's initial chunk) if possible. If the block of | 2121 // the memory allocator's initial chunk) if possible. If the block of |
2100 // addresses is not big enough to contain a single page-aligned page, a | 2122 // addresses is not big enough to contain a single page-aligned page, a |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2289 // sweeper. | 2311 // sweeper. |
2290 virtual void RefillFreeList(); | 2312 virtual void RefillFreeList(); |
2291 | 2313 |
2292 FreeList* free_list() { return &free_list_; } | 2314 FreeList* free_list() { return &free_list_; } |
2293 | 2315 |
2294 base::Mutex* mutex() { return &space_mutex_; } | 2316 base::Mutex* mutex() { return &space_mutex_; } |
2295 | 2317 |
2296 inline void UnlinkFreeListCategories(Page* page); | 2318 inline void UnlinkFreeListCategories(Page* page); |
2297 inline intptr_t RelinkFreeListCategories(Page* page); | 2319 inline intptr_t RelinkFreeListCategories(Page* page); |
2298 | 2320 |
| 2321 iterator begin() { return iterator(anchor_.next_page()); } |
| 2322 iterator end() { return iterator(&anchor_); } |
| 2323 |
2299 protected: | 2324 protected: |
2300 // PagedSpaces that should be included in snapshots have different, i.e., | 2325 // PagedSpaces that should be included in snapshots have different, i.e., |
2301 // smaller, initial pages. | 2326 // smaller, initial pages. |
2302 virtual bool snapshotable() { return true; } | 2327 virtual bool snapshotable() { return true; } |
2303 | 2328 |
2304 bool HasPages() { return anchor_.next_page() != &anchor_; } | 2329 bool HasPages() { return anchor_.next_page() != &anchor_; } |
2305 | 2330 |
2306 // Cleans up the space, frees all pages in this space except those belonging | 2331 // Cleans up the space, frees all pages in this space except those belonging |
2307 // to the initial chunk, uncommits addresses in the initial chunk. | 2332 // to the initial chunk, uncommits addresses in the initial chunk. |
2308 void TearDown(); | 2333 void TearDown(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2343 FreeList free_list_; | 2368 FreeList free_list_; |
2344 | 2369 |
2345 // Normal allocation information. | 2370 // Normal allocation information. |
2346 AllocationInfo allocation_info_; | 2371 AllocationInfo allocation_info_; |
2347 | 2372 |
2348 // Mutex guarding any concurrent access to the space. | 2373 // Mutex guarding any concurrent access to the space. |
2349 base::Mutex space_mutex_; | 2374 base::Mutex space_mutex_; |
2350 | 2375 |
2351 friend class IncrementalMarking; | 2376 friend class IncrementalMarking; |
2352 friend class MarkCompactCollector; | 2377 friend class MarkCompactCollector; |
2353 friend class PageIterator; | |
2354 | 2378 |
2355 // Used in cctest. | 2379 // Used in cctest. |
2356 friend class HeapTester; | 2380 friend class HeapTester; |
2357 }; | 2381 }; |
2358 | 2382 |
2359 | 2383 |
2360 class NumberAndSizeInfo BASE_EMBEDDED { | 2384 class NumberAndSizeInfo BASE_EMBEDDED { |
2361 public: | 2385 public: |
2362 NumberAndSizeInfo() : number_(0), bytes_(0) {} | 2386 NumberAndSizeInfo() : number_(0), bytes_(0) {} |
2363 | 2387 |
(...skipping 30 matching lines...) Expand all Loading... |
2394 enum SemiSpaceId { kFromSpace = 0, kToSpace = 1 }; | 2418 enum SemiSpaceId { kFromSpace = 0, kToSpace = 1 }; |
2395 | 2419 |
2396 // ----------------------------------------------------------------------------- | 2420 // ----------------------------------------------------------------------------- |
2397 // SemiSpace in young generation | 2421 // SemiSpace in young generation |
2398 // | 2422 // |
2399 // A SemiSpace is a contiguous chunk of memory holding page-like memory chunks. | 2423 // A SemiSpace is a contiguous chunk of memory holding page-like memory chunks. |
2400 // The mark-compact collector uses the memory of the first page in the from | 2424 // The mark-compact collector uses the memory of the first page in the from |
2401 // space as a marking stack when tracing live objects. | 2425 // space as a marking stack when tracing live objects. |
2402 class SemiSpace : public Space { | 2426 class SemiSpace : public Space { |
2403 public: | 2427 public: |
| 2428 typedef PageIterator iterator; |
| 2429 |
2404 static void Swap(SemiSpace* from, SemiSpace* to); | 2430 static void Swap(SemiSpace* from, SemiSpace* to); |
2405 | 2431 |
2406 SemiSpace(Heap* heap, SemiSpaceId semispace) | 2432 SemiSpace(Heap* heap, SemiSpaceId semispace) |
2407 : Space(heap, NEW_SPACE, NOT_EXECUTABLE), | 2433 : Space(heap, NEW_SPACE, NOT_EXECUTABLE), |
2408 current_capacity_(0), | 2434 current_capacity_(0), |
2409 maximum_capacity_(0), | 2435 maximum_capacity_(0), |
2410 minimum_capacity_(0), | 2436 minimum_capacity_(0), |
2411 age_mark_(nullptr), | 2437 age_mark_(nullptr), |
2412 committed_(false), | 2438 committed_(false), |
2413 id_(semispace), | 2439 id_(semispace), |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2518 static void AssertValidRange(Address from, Address to); | 2544 static void AssertValidRange(Address from, Address to); |
2519 #else | 2545 #else |
2520 // Do nothing. | 2546 // Do nothing. |
2521 inline static void AssertValidRange(Address from, Address to) {} | 2547 inline static void AssertValidRange(Address from, Address to) {} |
2522 #endif | 2548 #endif |
2523 | 2549 |
2524 #ifdef VERIFY_HEAP | 2550 #ifdef VERIFY_HEAP |
2525 virtual void Verify(); | 2551 virtual void Verify(); |
2526 #endif | 2552 #endif |
2527 | 2553 |
| 2554 iterator begin() { return iterator(anchor_.next_page()); } |
| 2555 iterator end() { return iterator(anchor()); } |
| 2556 |
2528 private: | 2557 private: |
2529 void RewindPages(Page* start, int num_pages); | 2558 void RewindPages(Page* start, int num_pages); |
2530 | 2559 |
2531 inline Page* anchor() { return &anchor_; } | 2560 inline Page* anchor() { return &anchor_; } |
2532 inline int max_pages() { return current_capacity_ / Page::kPageSize; } | 2561 inline int max_pages() { return current_capacity_ / Page::kPageSize; } |
2533 | 2562 |
2534 // Copies the flags into the masked positions on all pages in the space. | 2563 // Copies the flags into the masked positions on all pages in the space. |
2535 void FixPagesFlags(intptr_t flags, intptr_t flag_mask); | 2564 void FixPagesFlags(intptr_t flags, intptr_t flag_mask); |
2536 | 2565 |
2537 // The currently committed space capacity. | 2566 // The currently committed space capacity. |
(...skipping 10 matching lines...) Expand all Loading... |
2548 Address age_mark_; | 2577 Address age_mark_; |
2549 | 2578 |
2550 bool committed_; | 2579 bool committed_; |
2551 SemiSpaceId id_; | 2580 SemiSpaceId id_; |
2552 | 2581 |
2553 Page anchor_; | 2582 Page anchor_; |
2554 Page* current_page_; | 2583 Page* current_page_; |
2555 int pages_used_; | 2584 int pages_used_; |
2556 | 2585 |
2557 friend class NewSpace; | 2586 friend class NewSpace; |
2558 friend class NewSpacePageIterator; | |
2559 friend class SemiSpaceIterator; | 2587 friend class SemiSpaceIterator; |
2560 }; | 2588 }; |
2561 | 2589 |
2562 | 2590 |
2563 // A SemiSpaceIterator is an ObjectIterator that iterates over the active | 2591 // A SemiSpaceIterator is an ObjectIterator that iterates over the active |
2564 // semispace of the heap's new space. It iterates over the objects in the | 2592 // semispace of the heap's new space. It iterates over the objects in the |
2565 // semispace from a given start address (defaulting to the bottom of the | 2593 // semispace from a given start address (defaulting to the bottom of the |
2566 // semispace) to the top of the semispace. New objects allocated after the | 2594 // semispace) to the top of the semispace. New objects allocated after the |
2567 // iterator is created are not iterated. | 2595 // iterator is created are not iterated. |
2568 class SemiSpaceIterator : public ObjectIterator { | 2596 class SemiSpaceIterator : public ObjectIterator { |
2569 public: | 2597 public: |
2570 // Create an iterator over the allocated objects in the given to-space. | 2598 // Create an iterator over the allocated objects in the given to-space. |
2571 explicit SemiSpaceIterator(NewSpace* space); | 2599 explicit SemiSpaceIterator(NewSpace* space); |
2572 | 2600 |
2573 inline HeapObject* Next(); | 2601 inline HeapObject* Next(); |
2574 | 2602 |
2575 // Implementation of the ObjectIterator functions. | 2603 // Implementation of the ObjectIterator functions. |
2576 inline HeapObject* next_object() override; | 2604 inline HeapObject* next_object() override; |
2577 | 2605 |
2578 private: | 2606 private: |
2579 void Initialize(Address start, Address end); | 2607 void Initialize(Address start, Address end); |
2580 | 2608 |
2581 // The current iteration point. | 2609 // The current iteration point. |
2582 Address current_; | 2610 Address current_; |
2583 // The end of iteration. | 2611 // The end of iteration. |
2584 Address limit_; | 2612 Address limit_; |
2585 }; | 2613 }; |
2586 | 2614 |
2587 | |
2588 // ----------------------------------------------------------------------------- | |
2589 // A PageIterator iterates the pages in a semi-space. | |
2590 class NewSpacePageIterator BASE_EMBEDDED { | |
2591 public: | |
2592 // Make an iterator that runs over all pages in to-space. | |
2593 explicit inline NewSpacePageIterator(NewSpace* space); | |
2594 | |
2595 // Make an iterator that runs over all pages in the given semispace, | |
2596 // even those not used in allocation. | |
2597 explicit inline NewSpacePageIterator(SemiSpace* space); | |
2598 | |
2599 // Make iterator that iterates from the page containing start | |
2600 // to the page that contains limit in the same semispace. | |
2601 inline NewSpacePageIterator(Address start, Address limit); | |
2602 | |
2603 inline bool has_next(); | |
2604 inline Page* next(); | |
2605 | |
2606 private: | |
2607 Page* prev_page_; // Previous page returned. | |
2608 // Next page that will be returned. Cached here so that we can use this | |
2609 // iterator for operations that deallocate pages. | |
2610 Page* next_page_; | |
2611 // Last page returned. | |
2612 Page* last_page_; | |
2613 }; | |
2614 | |
2615 | |
2616 // ----------------------------------------------------------------------------- | 2615 // ----------------------------------------------------------------------------- |
2617 // The young generation space. | 2616 // The young generation space. |
2618 // | 2617 // |
2619 // The new space consists of a contiguous pair of semispaces. It simply | 2618 // The new space consists of a contiguous pair of semispaces. It simply |
2620 // forwards most functions to the appropriate semispace. | 2619 // forwards most functions to the appropriate semispace. |
2621 | 2620 |
2622 class NewSpace : public Space { | 2621 class NewSpace : public Space { |
2623 public: | 2622 public: |
| 2623 typedef PageIterator iterator; |
| 2624 |
2624 explicit NewSpace(Heap* heap) | 2625 explicit NewSpace(Heap* heap) |
2625 : Space(heap, NEW_SPACE, NOT_EXECUTABLE), | 2626 : Space(heap, NEW_SPACE, NOT_EXECUTABLE), |
2626 to_space_(heap, kToSpace), | 2627 to_space_(heap, kToSpace), |
2627 from_space_(heap, kFromSpace), | 2628 from_space_(heap, kFromSpace), |
2628 reservation_(), | 2629 reservation_(), |
2629 top_on_previous_step_(0), | 2630 top_on_previous_step_(0), |
2630 allocated_histogram_(nullptr), | 2631 allocated_histogram_(nullptr), |
2631 promoted_histogram_(nullptr) {} | 2632 promoted_histogram_(nullptr) {} |
2632 | 2633 |
2633 inline bool Contains(HeapObject* o); | 2634 inline bool Contains(HeapObject* o); |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2877 return from_space_.Uncommit(); | 2878 return from_space_.Uncommit(); |
2878 } | 2879 } |
2879 | 2880 |
2880 bool IsFromSpaceCommitted() { return from_space_.is_committed(); } | 2881 bool IsFromSpaceCommitted() { return from_space_.is_committed(); } |
2881 | 2882 |
2882 SemiSpace* active_space() { return &to_space_; } | 2883 SemiSpace* active_space() { return &to_space_; } |
2883 | 2884 |
2884 void PauseAllocationObservers() override; | 2885 void PauseAllocationObservers() override; |
2885 void ResumeAllocationObservers() override; | 2886 void ResumeAllocationObservers() override; |
2886 | 2887 |
| 2888 iterator begin() { return to_space_.begin(); } |
| 2889 iterator end() { return to_space_.end(); } |
| 2890 |
2887 private: | 2891 private: |
2888 // Update allocation info to match the current to-space page. | 2892 // Update allocation info to match the current to-space page. |
2889 void UpdateAllocationInfo(); | 2893 void UpdateAllocationInfo(); |
2890 | 2894 |
2891 base::Mutex mutex_; | 2895 base::Mutex mutex_; |
2892 | 2896 |
2893 // The semispaces. | 2897 // The semispaces. |
2894 SemiSpace to_space_; | 2898 SemiSpace to_space_; |
2895 SemiSpace from_space_; | 2899 SemiSpace from_space_; |
2896 base::VirtualMemory reservation_; | 2900 base::VirtualMemory reservation_; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3020 | 3024 |
3021 // ----------------------------------------------------------------------------- | 3025 // ----------------------------------------------------------------------------- |
3022 // Large objects ( > Page::kMaxRegularHeapObjectSize ) are allocated and | 3026 // Large objects ( > Page::kMaxRegularHeapObjectSize ) are allocated and |
3023 // managed by the large object space. A large object is allocated from OS | 3027 // managed by the large object space. A large object is allocated from OS |
3024 // heap with extra padding bytes (Page::kPageSize + Page::kObjectStartOffset). | 3028 // heap with extra padding bytes (Page::kPageSize + Page::kObjectStartOffset). |
3025 // A large object always starts at Page::kObjectStartOffset to a page. | 3029 // A large object always starts at Page::kObjectStartOffset to a page. |
3026 // Large objects do not move during garbage collections. | 3030 // Large objects do not move during garbage collections. |
3027 | 3031 |
3028 class LargeObjectSpace : public Space { | 3032 class LargeObjectSpace : public Space { |
3029 public: | 3033 public: |
| 3034 typedef LargePageIterator iterator; |
| 3035 |
3030 LargeObjectSpace(Heap* heap, AllocationSpace id); | 3036 LargeObjectSpace(Heap* heap, AllocationSpace id); |
3031 virtual ~LargeObjectSpace(); | 3037 virtual ~LargeObjectSpace(); |
3032 | 3038 |
3033 // Initializes internal data structures. | 3039 // Initializes internal data structures. |
3034 bool SetUp(); | 3040 bool SetUp(); |
3035 | 3041 |
3036 // Releases internal resources, frees objects in this space. | 3042 // Releases internal resources, frees objects in this space. |
3037 void TearDown(); | 3043 void TearDown(); |
3038 | 3044 |
3039 static intptr_t ObjectSizeFor(intptr_t chunk_size) { | 3045 static intptr_t ObjectSizeFor(intptr_t chunk_size) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3081 // Checks whether the space is empty. | 3087 // Checks whether the space is empty. |
3082 bool IsEmpty() { return first_page_ == NULL; } | 3088 bool IsEmpty() { return first_page_ == NULL; } |
3083 | 3089 |
3084 void AdjustLiveBytes(int by) { objects_size_ += by; } | 3090 void AdjustLiveBytes(int by) { objects_size_ += by; } |
3085 | 3091 |
3086 LargePage* first_page() { return first_page_; } | 3092 LargePage* first_page() { return first_page_; } |
3087 | 3093 |
3088 // Collect code statistics. | 3094 // Collect code statistics. |
3089 void CollectCodeStatistics(); | 3095 void CollectCodeStatistics(); |
3090 | 3096 |
| 3097 iterator begin() { return iterator(first_page_); } |
| 3098 iterator end() { return iterator(nullptr); } |
| 3099 |
3091 #ifdef VERIFY_HEAP | 3100 #ifdef VERIFY_HEAP |
3092 virtual void Verify(); | 3101 virtual void Verify(); |
3093 #endif | 3102 #endif |
3094 | 3103 |
3095 #ifdef DEBUG | 3104 #ifdef DEBUG |
3096 void Print() override; | 3105 void Print() override; |
3097 void ReportStatistics(); | 3106 void ReportStatistics(); |
3098 #endif | 3107 #endif |
3099 | 3108 |
3100 private: | 3109 private: |
(...skipping 15 matching lines...) Expand all Loading... |
3116 | 3125 |
3117 HeapObject* Next(); | 3126 HeapObject* Next(); |
3118 | 3127 |
3119 // implementation of ObjectIterator. | 3128 // implementation of ObjectIterator. |
3120 virtual HeapObject* next_object() { return Next(); } | 3129 virtual HeapObject* next_object() { return Next(); } |
3121 | 3130 |
3122 private: | 3131 private: |
3123 LargePage* current_; | 3132 LargePage* current_; |
3124 }; | 3133 }; |
3125 | 3134 |
3126 class LargePageIterator BASE_EMBEDDED { | |
3127 public: | |
3128 explicit inline LargePageIterator(LargeObjectSpace* space); | |
3129 | |
3130 inline LargePage* next(); | |
3131 | |
3132 private: | |
3133 LargePage* next_page_; | |
3134 }; | |
3135 | |
3136 // Iterates over the chunks (pages and large object pages) that can contain | 3135 // Iterates over the chunks (pages and large object pages) that can contain |
3137 // pointers to new space or to evacuation candidates. | 3136 // pointers to new space or to evacuation candidates. |
3138 class MemoryChunkIterator BASE_EMBEDDED { | 3137 class MemoryChunkIterator BASE_EMBEDDED { |
3139 public: | 3138 public: |
3140 inline explicit MemoryChunkIterator(Heap* heap); | 3139 inline explicit MemoryChunkIterator(Heap* heap); |
3141 | 3140 |
3142 // Return NULL when the iterator is done. | 3141 // Return NULL when the iterator is done. |
3143 inline MemoryChunk* next(); | 3142 inline MemoryChunk* next(); |
3144 | 3143 |
3145 private: | 3144 private: |
3146 enum State { | 3145 enum State { |
3147 kOldSpaceState, | 3146 kOldSpaceState, |
3148 kMapState, | 3147 kMapState, |
3149 kCodeState, | 3148 kCodeState, |
3150 kLargeObjectState, | 3149 kLargeObjectState, |
3151 kFinishedState | 3150 kFinishedState |
3152 }; | 3151 }; |
| 3152 Heap* heap_; |
3153 State state_; | 3153 State state_; |
3154 PageIterator old_iterator_; | 3154 PageIterator old_iterator_; |
3155 PageIterator code_iterator_; | 3155 PageIterator code_iterator_; |
3156 PageIterator map_iterator_; | 3156 PageIterator map_iterator_; |
3157 LargePageIterator lo_iterator_; | 3157 LargePageIterator lo_iterator_; |
3158 }; | 3158 }; |
3159 | 3159 |
3160 #ifdef DEBUG | 3160 #ifdef DEBUG |
3161 struct CommentStatistic { | 3161 struct CommentStatistic { |
3162 const char* comment; | 3162 const char* comment; |
3163 int size; | 3163 int size; |
3164 int count; | 3164 int count; |
3165 void Clear() { | 3165 void Clear() { |
3166 comment = NULL; | 3166 comment = NULL; |
3167 size = 0; | 3167 size = 0; |
3168 count = 0; | 3168 count = 0; |
3169 } | 3169 } |
3170 // Must be small, since an iteration is used for lookup. | 3170 // Must be small, since an iteration is used for lookup. |
3171 static const int kMaxComments = 64; | 3171 static const int kMaxComments = 64; |
3172 }; | 3172 }; |
3173 #endif | 3173 #endif |
3174 } // namespace internal | 3174 } // namespace internal |
3175 } // namespace v8 | 3175 } // namespace v8 |
3176 | 3176 |
3177 #endif // V8_HEAP_SPACES_H_ | 3177 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |