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 "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 2235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2246 uintptr_t object_expected_; | 2246 uintptr_t object_expected_; |
2247 | 2247 |
2248 bool committed_; | 2248 bool committed_; |
2249 SemiSpaceId id_; | 2249 SemiSpaceId id_; |
2250 | 2250 |
2251 NewSpacePage anchor_; | 2251 NewSpacePage anchor_; |
2252 NewSpacePage* current_page_; | 2252 NewSpacePage* current_page_; |
2253 | 2253 |
2254 friend class SemiSpaceIterator; | 2254 friend class SemiSpaceIterator; |
2255 friend class NewSpacePageIterator; | 2255 friend class NewSpacePageIterator; |
2256 | |
2257 public: | |
2258 TRACK_MEMORY("SemiSpace") | |
2259 }; | 2256 }; |
2260 | 2257 |
2261 | 2258 |
2262 // A SemiSpaceIterator is an ObjectIterator that iterates over the active | 2259 // A SemiSpaceIterator is an ObjectIterator that iterates over the active |
2263 // semispace of the heap's new space. It iterates over the objects in the | 2260 // semispace of the heap's new space. It iterates over the objects in the |
2264 // semispace from a given start address (defaulting to the bottom of the | 2261 // semispace from a given start address (defaulting to the bottom of the |
2265 // semispace) to the top of the semispace. New objects allocated after the | 2262 // semispace) to the top of the semispace. New objects allocated after the |
2266 // iterator is created are not iterated. | 2263 // iterator is created are not iterated. |
2267 class SemiSpaceIterator : public ObjectIterator { | 2264 class SemiSpaceIterator : public ObjectIterator { |
2268 public: | 2265 public: |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2618 | 2615 |
2619 Address top_on_previous_step_; | 2616 Address top_on_previous_step_; |
2620 | 2617 |
2621 HistogramInfo* allocated_histogram_; | 2618 HistogramInfo* allocated_histogram_; |
2622 HistogramInfo* promoted_histogram_; | 2619 HistogramInfo* promoted_histogram_; |
2623 | 2620 |
2624 MUST_USE_RESULT AllocationResult | 2621 MUST_USE_RESULT AllocationResult |
2625 SlowAllocateRaw(int size_in_bytes, AllocationAlignment alignment); | 2622 SlowAllocateRaw(int size_in_bytes, AllocationAlignment alignment); |
2626 | 2623 |
2627 friend class SemiSpaceIterator; | 2624 friend class SemiSpaceIterator; |
2628 | |
2629 public: | |
2630 TRACK_MEMORY("NewSpace") | |
2631 }; | 2625 }; |
2632 | 2626 |
2633 | 2627 |
2634 // ----------------------------------------------------------------------------- | 2628 // ----------------------------------------------------------------------------- |
2635 // Old object space (includes the old space of objects and code space) | 2629 // Old object space (includes the old space of objects and code space) |
2636 | 2630 |
2637 class OldSpace : public PagedSpace { | 2631 class OldSpace : public PagedSpace { |
2638 public: | 2632 public: |
2639 // Creates an old space object with a given maximum capacity. | 2633 // Creates an old space object with a given maximum capacity. |
2640 // The constructor does not allocate pages from OS. | 2634 // The constructor does not allocate pages from OS. |
2641 OldSpace(Heap* heap, intptr_t max_capacity, AllocationSpace id, | 2635 OldSpace(Heap* heap, intptr_t max_capacity, AllocationSpace id, |
2642 Executability executable) | 2636 Executability executable) |
2643 : PagedSpace(heap, max_capacity, id, executable) {} | 2637 : PagedSpace(heap, max_capacity, id, executable) {} |
2644 | |
2645 public: | |
2646 TRACK_MEMORY("OldSpace") | |
2647 }; | 2638 }; |
2648 | 2639 |
2649 | 2640 |
2650 // For contiguous spaces, top should be in the space (or at the end) and limit | 2641 // For contiguous spaces, top should be in the space (or at the end) and limit |
2651 // should be the end of the space. | 2642 // should be the end of the space. |
2652 #define DCHECK_SEMISPACE_ALLOCATION_INFO(info, space) \ | 2643 #define DCHECK_SEMISPACE_ALLOCATION_INFO(info, space) \ |
2653 SLOW_DCHECK((space).page_low() <= (info).top() && \ | 2644 SLOW_DCHECK((space).page_low() <= (info).top() && \ |
2654 (info).top() <= (space).page_high() && \ | 2645 (info).top() <= (space).page_high() && \ |
2655 (info).limit() <= (space).page_high()) | 2646 (info).limit() <= (space).page_high()) |
2656 | 2647 |
(...skipping 25 matching lines...) Expand all Loading... |
2682 | 2673 |
2683 private: | 2674 private: |
2684 static const int kMapsPerPage = Page::kMaxRegularHeapObjectSize / Map::kSize; | 2675 static const int kMapsPerPage = Page::kMaxRegularHeapObjectSize / Map::kSize; |
2685 | 2676 |
2686 // Do map space compaction if there is a page gap. | 2677 // Do map space compaction if there is a page gap. |
2687 int CompactionThreshold() { | 2678 int CompactionThreshold() { |
2688 return kMapsPerPage * (max_map_space_pages_ - 1); | 2679 return kMapsPerPage * (max_map_space_pages_ - 1); |
2689 } | 2680 } |
2690 | 2681 |
2691 const int max_map_space_pages_; | 2682 const int max_map_space_pages_; |
2692 | |
2693 public: | |
2694 TRACK_MEMORY("MapSpace") | |
2695 }; | 2683 }; |
2696 | 2684 |
2697 | 2685 |
2698 // ----------------------------------------------------------------------------- | 2686 // ----------------------------------------------------------------------------- |
2699 // Large objects ( > Page::kMaxHeapObjectSize ) are allocated and managed by | 2687 // Large objects ( > Page::kMaxHeapObjectSize ) are allocated and managed by |
2700 // the large object space. A large object is allocated from OS heap with | 2688 // the large object space. A large object is allocated from OS heap with |
2701 // extra padding bytes (Page::kPageSize + Page::kObjectStartOffset). | 2689 // extra padding bytes (Page::kPageSize + Page::kObjectStartOffset). |
2702 // A large object always starts at Page::kObjectStartOffset to a page. | 2690 // A large object always starts at Page::kObjectStartOffset to a page. |
2703 // Large objects do not move during garbage collections. | 2691 // Large objects do not move during garbage collections. |
2704 | 2692 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2778 intptr_t maximum_committed_; | 2766 intptr_t maximum_committed_; |
2779 // The head of the linked list of large object chunks. | 2767 // The head of the linked list of large object chunks. |
2780 LargePage* first_page_; | 2768 LargePage* first_page_; |
2781 intptr_t size_; // allocated bytes | 2769 intptr_t size_; // allocated bytes |
2782 int page_count_; // number of chunks | 2770 int page_count_; // number of chunks |
2783 intptr_t objects_size_; // size of objects | 2771 intptr_t objects_size_; // size of objects |
2784 // Map MemoryChunk::kAlignment-aligned chunks to large pages covering them | 2772 // Map MemoryChunk::kAlignment-aligned chunks to large pages covering them |
2785 HashMap chunk_map_; | 2773 HashMap chunk_map_; |
2786 | 2774 |
2787 friend class LargeObjectIterator; | 2775 friend class LargeObjectIterator; |
2788 | |
2789 public: | |
2790 TRACK_MEMORY("LargeObjectSpace") | |
2791 }; | 2776 }; |
2792 | 2777 |
2793 | 2778 |
2794 class LargeObjectIterator : public ObjectIterator { | 2779 class LargeObjectIterator : public ObjectIterator { |
2795 public: | 2780 public: |
2796 explicit LargeObjectIterator(LargeObjectSpace* space); | 2781 explicit LargeObjectIterator(LargeObjectSpace* space); |
2797 LargeObjectIterator(LargeObjectSpace* space, HeapObjectCallback size_func); | 2782 LargeObjectIterator(LargeObjectSpace* space, HeapObjectCallback size_func); |
2798 | 2783 |
2799 HeapObject* Next(); | 2784 HeapObject* Next(); |
2800 | 2785 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2874 count = 0; | 2859 count = 0; |
2875 } | 2860 } |
2876 // Must be small, since an iteration is used for lookup. | 2861 // Must be small, since an iteration is used for lookup. |
2877 static const int kMaxComments = 64; | 2862 static const int kMaxComments = 64; |
2878 }; | 2863 }; |
2879 #endif | 2864 #endif |
2880 } | 2865 } |
2881 } // namespace v8::internal | 2866 } // namespace v8::internal |
2882 | 2867 |
2883 #endif // V8_HEAP_SPACES_H_ | 2868 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |