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/atomic-utils.h" | 9 #include "src/atomic-utils.h" |
10 #include "src/base/atomicops.h" | 10 #include "src/base/atomicops.h" |
(...skipping 2541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2552 // forwards most functions to the appropriate semispace. | 2552 // forwards most functions to the appropriate semispace. |
2553 | 2553 |
2554 class NewSpace : public Space { | 2554 class NewSpace : public Space { |
2555 public: | 2555 public: |
2556 // Constructor. | 2556 // Constructor. |
2557 explicit NewSpace(Heap* heap) | 2557 explicit NewSpace(Heap* heap) |
2558 : Space(heap, NEW_SPACE, NOT_EXECUTABLE), | 2558 : Space(heap, NEW_SPACE, NOT_EXECUTABLE), |
2559 to_space_(heap, kToSpace), | 2559 to_space_(heap, kToSpace), |
2560 from_space_(heap, kFromSpace), | 2560 from_space_(heap, kFromSpace), |
2561 reservation_(), | 2561 reservation_(), |
2562 top_on_previous_step_(0) {} | 2562 top_on_previous_step_(0), |
| 2563 inline_allocation_observers_paused_(false) {} |
2563 | 2564 |
2564 // Sets up the new space using the given chunk. | 2565 // Sets up the new space using the given chunk. |
2565 bool SetUp(int reserved_semispace_size_, int max_semi_space_size); | 2566 bool SetUp(int reserved_semispace_size_, int max_semi_space_size); |
2566 | 2567 |
2567 // Tears down the space. Heap memory was not allocated by the space, so it | 2568 // Tears down the space. Heap memory was not allocated by the space, so it |
2568 // is not deallocated here. | 2569 // is not deallocated here. |
2569 void TearDown(); | 2570 void TearDown(); |
2570 | 2571 |
2571 // True if the space has been set up but not torn down. | 2572 // True if the space has been set up but not torn down. |
2572 bool HasBeenSetUp() { | 2573 bool HasBeenSetUp() { |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2725 MUST_USE_RESULT INLINE( | 2726 MUST_USE_RESULT INLINE( |
2726 AllocationResult AllocateRawUnaligned(int size_in_bytes)); | 2727 AllocationResult AllocateRawUnaligned(int size_in_bytes)); |
2727 | 2728 |
2728 MUST_USE_RESULT INLINE(AllocationResult AllocateRaw( | 2729 MUST_USE_RESULT INLINE(AllocationResult AllocateRaw( |
2729 int size_in_bytes, AllocationAlignment alignment)); | 2730 int size_in_bytes, AllocationAlignment alignment)); |
2730 | 2731 |
2731 // Reset the allocation pointer to the beginning of the active semispace. | 2732 // Reset the allocation pointer to the beginning of the active semispace. |
2732 void ResetAllocationInfo(); | 2733 void ResetAllocationInfo(); |
2733 | 2734 |
2734 void UpdateInlineAllocationLimit(int size_in_bytes); | 2735 void UpdateInlineAllocationLimit(int size_in_bytes); |
2735 void StartNextInlineAllocationStep(); | |
2736 | 2736 |
2737 // Allows observation of inline allocation. The observer->Step() method gets | 2737 // Allows observation of inline allocation. The observer->Step() method gets |
2738 // called after every step_size bytes have been allocated (approximately). | 2738 // called after every step_size bytes have been allocated (approximately). |
2739 // This works by adjusting the allocation limit to a lower value and adjusting | 2739 // This works by adjusting the allocation limit to a lower value and adjusting |
2740 // it after each step. | 2740 // it after each step. |
2741 void AddInlineAllocationObserver(InlineAllocationObserver* observer); | 2741 void AddInlineAllocationObserver(InlineAllocationObserver* observer); |
2742 | 2742 |
2743 // Removes a previously installed observer. | 2743 // Removes a previously installed observer. |
2744 void RemoveInlineAllocationObserver(InlineAllocationObserver* observer); | 2744 void RemoveInlineAllocationObserver(InlineAllocationObserver* observer); |
2745 | 2745 |
| 2746 void PauseInlineAllocationObservers(); |
| 2747 void ResumeInlineAllocationObservers(); |
| 2748 |
2746 void DisableInlineAllocationSteps() { | 2749 void DisableInlineAllocationSteps() { |
2747 top_on_previous_step_ = 0; | 2750 top_on_previous_step_ = 0; |
2748 UpdateInlineAllocationLimit(0); | 2751 UpdateInlineAllocationLimit(0); |
2749 } | 2752 } |
2750 | 2753 |
2751 // Get the extent of the inactive semispace (for use as a marking stack, | 2754 // Get the extent of the inactive semispace (for use as a marking stack, |
2752 // or to zap it). Notice: space-addresses are not necessarily on the | 2755 // or to zap it). Notice: space-addresses are not necessarily on the |
2753 // same page, so FromSpaceStart() might be above FromSpaceEnd(). | 2756 // same page, so FromSpaceStart() might be above FromSpaceEnd(). |
2754 Address FromSpacePageLow() { return from_space_.page_low(); } | 2757 Address FromSpacePageLow() { return from_space_.page_low(); } |
2755 Address FromSpacePageHigh() { return from_space_.page_high(); } | 2758 Address FromSpacePageHigh() { return from_space_.page_high(); } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2839 // Allocation pointer and limit for normal allocation and allocation during | 2842 // Allocation pointer and limit for normal allocation and allocation during |
2840 // mark-compact collection. | 2843 // mark-compact collection. |
2841 AllocationInfo allocation_info_; | 2844 AllocationInfo allocation_info_; |
2842 | 2845 |
2843 // When inline allocation stepping is active, either because of incremental | 2846 // When inline allocation stepping is active, either because of incremental |
2844 // marking or because of idle scavenge, we 'interrupt' inline allocation every | 2847 // marking or because of idle scavenge, we 'interrupt' inline allocation every |
2845 // once in a while. This is done by setting allocation_info_.limit to be lower | 2848 // once in a while. This is done by setting allocation_info_.limit to be lower |
2846 // than the actual limit and and increasing it in steps to guarantee that the | 2849 // than the actual limit and and increasing it in steps to guarantee that the |
2847 // observers are notified periodically. | 2850 // observers are notified periodically. |
2848 List<InlineAllocationObserver*> inline_allocation_observers_; | 2851 List<InlineAllocationObserver*> inline_allocation_observers_; |
2849 | |
2850 Address top_on_previous_step_; | 2852 Address top_on_previous_step_; |
| 2853 bool inline_allocation_observers_paused_; |
2851 | 2854 |
2852 HistogramInfo* allocated_histogram_; | 2855 HistogramInfo* allocated_histogram_; |
2853 HistogramInfo* promoted_histogram_; | 2856 HistogramInfo* promoted_histogram_; |
2854 | 2857 |
2855 bool EnsureAllocation(int size_in_bytes, AllocationAlignment alignment); | 2858 bool EnsureAllocation(int size_in_bytes, AllocationAlignment alignment); |
2856 | 2859 |
2857 // If we are doing inline allocation in steps, this method performs the 'step' | 2860 // If we are doing inline allocation in steps, this method performs the 'step' |
2858 // operation. top is the memory address of the bump pointer at the last | 2861 // operation. top is the memory address of the bump pointer at the last |
2859 // inline allocation (i.e. it determines the numbers of bytes actually | 2862 // inline allocation (i.e. it determines the numbers of bytes actually |
2860 // allocated since the last step.) new_top is the address of the bump pointer | 2863 // allocated since the last step.) new_top is the address of the bump pointer |
2861 // where the next byte is going to be allocated from. top and new_top may be | 2864 // where the next byte is going to be allocated from. top and new_top may be |
2862 // different when we cross a page boundary or reset the space. | 2865 // different when we cross a page boundary or reset the space. |
2863 void InlineAllocationStep(Address top, Address new_top); | 2866 void InlineAllocationStep(Address top, Address new_top); |
2864 intptr_t GetNextInlineAllocationStepSize(); | 2867 intptr_t GetNextInlineAllocationStepSize(); |
| 2868 void StartNextInlineAllocationStep(); |
2865 | 2869 |
2866 friend class SemiSpaceIterator; | 2870 friend class SemiSpaceIterator; |
2867 }; | 2871 }; |
2868 | 2872 |
2869 // ----------------------------------------------------------------------------- | 2873 // ----------------------------------------------------------------------------- |
2870 // Compaction space that is used temporarily during compaction. | 2874 // Compaction space that is used temporarily during compaction. |
2871 | 2875 |
2872 class CompactionSpace : public PagedSpace { | 2876 class CompactionSpace : public PagedSpace { |
2873 public: | 2877 public: |
2874 CompactionSpace(Heap* heap, AllocationSpace id, Executability executable) | 2878 CompactionSpace(Heap* heap, AllocationSpace id, Executability executable) |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3123 count = 0; | 3127 count = 0; |
3124 } | 3128 } |
3125 // Must be small, since an iteration is used for lookup. | 3129 // Must be small, since an iteration is used for lookup. |
3126 static const int kMaxComments = 64; | 3130 static const int kMaxComments = 64; |
3127 }; | 3131 }; |
3128 #endif | 3132 #endif |
3129 } // namespace internal | 3133 } // namespace internal |
3130 } // namespace v8 | 3134 } // namespace v8 |
3131 | 3135 |
3132 #endif // V8_HEAP_SPACES_H_ | 3136 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |