 Chromium Code Reviews
 Chromium Code Reviews Issue 1404523002:
  [heap] inline allocation steps refactor  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master
    
  
    Issue 1404523002:
  [heap] inline allocation steps refactor  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master| 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 2458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2469 | 2469 | 
| 2470 class NewSpace : public Space { | 2470 class NewSpace : public Space { | 
| 2471 public: | 2471 public: | 
| 2472 // Constructor. | 2472 // Constructor. | 
| 2473 explicit NewSpace(Heap* heap) | 2473 explicit NewSpace(Heap* heap) | 
| 2474 : Space(heap, NEW_SPACE, NOT_EXECUTABLE), | 2474 : Space(heap, NEW_SPACE, NOT_EXECUTABLE), | 
| 2475 to_space_(heap, kToSpace), | 2475 to_space_(heap, kToSpace), | 
| 2476 from_space_(heap, kFromSpace), | 2476 from_space_(heap, kFromSpace), | 
| 2477 reservation_(), | 2477 reservation_(), | 
| 2478 inline_allocation_limit_step_(0), | 2478 inline_allocation_limit_step_(0), | 
| 2479 incremental_marking_step_(0), | |
| 2480 idle_scavenge_step_(0), | |
| 2479 top_on_previous_step_(0) {} | 2481 top_on_previous_step_(0) {} | 
| 2480 | 2482 | 
| 2481 // Sets up the new space using the given chunk. | 2483 // Sets up the new space using the given chunk. | 
| 2482 bool SetUp(int reserved_semispace_size_, int max_semi_space_size); | 2484 bool SetUp(int reserved_semispace_size_, int max_semi_space_size); | 
| 2483 | 2485 | 
| 2484 // Tears down the space. Heap memory was not allocated by the space, so it | 2486 // Tears down the space. Heap memory was not allocated by the space, so it | 
| 2485 // is not deallocated here. | 2487 // is not deallocated here. | 
| 2486 void TearDown(); | 2488 void TearDown(); | 
| 2487 | 2489 | 
| 2488 // True if the space has been set up but not torn down. | 2490 // True if the space has been set up but not torn down. | 
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2642 MUST_USE_RESULT INLINE( | 2644 MUST_USE_RESULT INLINE( | 
| 2643 AllocationResult AllocateRawUnaligned(int size_in_bytes)); | 2645 AllocationResult AllocateRawUnaligned(int size_in_bytes)); | 
| 2644 | 2646 | 
| 2645 MUST_USE_RESULT INLINE(AllocationResult AllocateRaw( | 2647 MUST_USE_RESULT INLINE(AllocationResult AllocateRaw( | 
| 2646 int size_in_bytes, AllocationAlignment alignment)); | 2648 int size_in_bytes, AllocationAlignment alignment)); | 
| 2647 | 2649 | 
| 2648 // Reset the allocation pointer to the beginning of the active semispace. | 2650 // Reset the allocation pointer to the beginning of the active semispace. | 
| 2649 void ResetAllocationInfo(); | 2651 void ResetAllocationInfo(); | 
| 2650 | 2652 | 
| 2651 void UpdateInlineAllocationLimit(int size_in_bytes); | 2653 void UpdateInlineAllocationLimit(int size_in_bytes); | 
| 2652 void LowerInlineAllocationLimit(intptr_t step) { | 2654 | 
| 2653 inline_allocation_limit_step_ = step; | 2655 void SetIncrementalMarkingStep(intptr_t step) { | 
| 2654 UpdateInlineAllocationLimit(0); | 2656 incremental_marking_step_ = step; | 
| 2655 top_on_previous_step_ = step ? allocation_info_.top() : 0; | 2657 LowerInlineAllocationLimit(); | 
| 2658 } | |
| 2659 void SetIdleScavengeStep(intptr_t step) { | |
| 2660 idle_scavenge_step_ = step; | |
| 2661 LowerInlineAllocationLimit(); | |
| 2656 } | 2662 } | 
| 2657 | 2663 | 
| 2658 // Get the extent of the inactive semispace (for use as a marking stack, | 2664 // Get the extent of the inactive semispace (for use as a marking stack, | 
| 2659 // or to zap it). Notice: space-addresses are not necessarily on the | 2665 // or to zap it). Notice: space-addresses are not necessarily on the | 
| 2660 // same page, so FromSpaceStart() might be above FromSpaceEnd(). | 2666 // same page, so FromSpaceStart() might be above FromSpaceEnd(). | 
| 2661 Address FromSpacePageLow() { return from_space_.page_low(); } | 2667 Address FromSpacePageLow() { return from_space_.page_low(); } | 
| 2662 Address FromSpacePageHigh() { return from_space_.page_high(); } | 2668 Address FromSpacePageHigh() { return from_space_.page_high(); } | 
| 2663 Address FromSpaceStart() { return from_space_.space_start(); } | 2669 Address FromSpaceStart() { return from_space_.space_start(); } | 
| 2664 Address FromSpaceEnd() { return from_space_.space_end(); } | 2670 Address FromSpaceEnd() { return from_space_.space_end(); } | 
| 2665 | 2671 | 
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2721 } | 2727 } | 
| 2722 | 2728 | 
| 2723 bool IsFromSpaceCommitted() { return from_space_.is_committed(); } | 2729 bool IsFromSpaceCommitted() { return from_space_.is_committed(); } | 
| 2724 | 2730 | 
| 2725 SemiSpace* active_space() { return &to_space_; } | 2731 SemiSpace* active_space() { return &to_space_; } | 
| 2726 | 2732 | 
| 2727 private: | 2733 private: | 
| 2728 // Update allocation info to match the current to-space page. | 2734 // Update allocation info to match the current to-space page. | 
| 2729 void UpdateAllocationInfo(); | 2735 void UpdateAllocationInfo(); | 
| 2730 | 2736 | 
| 2737 void LowerInlineAllocationLimit() { | |
| 2738 intptr_t step; | |
| 2739 if (incremental_marking_step_ && idle_scavenge_step_) { | |
| 2740 step = Min(incremental_marking_step_, idle_scavenge_step_); | |
| 2741 } else { | |
| 2742 step = incremental_marking_step_ ? incremental_marking_step_ | |
| 2743 : idle_scavenge_step_; | |
| 2744 } | |
| 2745 inline_allocation_limit_step_ = step; | |
| 2746 top_on_previous_step_ = step ? allocation_info_.top() : 0; | |
| 2747 UpdateInlineAllocationLimit(0); | |
| 2748 } | |
| 2749 | |
| 2731 Address chunk_base_; | 2750 Address chunk_base_; | 
| 2732 uintptr_t chunk_size_; | 2751 uintptr_t chunk_size_; | 
| 2733 | 2752 | 
| 2734 // The semispaces. | 2753 // The semispaces. | 
| 2735 SemiSpace to_space_; | 2754 SemiSpace to_space_; | 
| 2736 SemiSpace from_space_; | 2755 SemiSpace from_space_; | 
| 2737 base::VirtualMemory reservation_; | 2756 base::VirtualMemory reservation_; | 
| 2738 int pages_used_; | 2757 int pages_used_; | 
| 2739 | 2758 | 
| 2740 // Start address and bit mask for containment testing. | 2759 // Start address and bit mask for containment testing. | 
| 2741 Address start_; | 2760 Address start_; | 
| 2742 uintptr_t address_mask_; | 2761 uintptr_t address_mask_; | 
| 2743 uintptr_t object_mask_; | 2762 uintptr_t object_mask_; | 
| 2744 uintptr_t object_expected_; | 2763 uintptr_t object_expected_; | 
| 2745 | 2764 | 
| 2746 // Allocation pointer and limit for normal allocation and allocation during | 2765 // Allocation pointer and limit for normal allocation and allocation during | 
| 2747 // mark-compact collection. | 2766 // mark-compact collection. | 
| 2748 AllocationInfo allocation_info_; | 2767 AllocationInfo allocation_info_; | 
| 2749 | 2768 | 
| 2750 // When incremental marking is active we will set allocation_info_.limit | 2769 // When inline allocation stepping is active, either because of incremental | 
| 2751 // to be lower than actual limit and then will gradually increase it | 2770 // marking or because of idle scavenge, we 'interrupt' inline allocation every | 
| 2752 // in steps to guarantee that we do incremental marking steps even | 2771 // once in a while. This is done by setting allocation_info_.limit to be lower | 
| 2753 // when all allocation is performed from inlined generated code. | 2772 // than the actual limit and and increasing it in steps to guarantee that the | 
| 2773 // observers are notified periodically. | |
| 2754 intptr_t inline_allocation_limit_step_; | 2774 intptr_t inline_allocation_limit_step_; | 
| 
Hannes Payer (out of office)
2015/10/13 16:51:24
Having a state that belongs to incremental marking
 | |
| 2775 intptr_t incremental_marking_step_; | |
| 2776 intptr_t idle_scavenge_step_; | |
| 2755 | 2777 | 
| 2756 Address top_on_previous_step_; | 2778 Address top_on_previous_step_; | 
| 2757 | 2779 | 
| 2758 HistogramInfo* allocated_histogram_; | 2780 HistogramInfo* allocated_histogram_; | 
| 2759 HistogramInfo* promoted_histogram_; | 2781 HistogramInfo* promoted_histogram_; | 
| 2760 | 2782 | 
| 2761 bool EnsureAllocation(int size_in_bytes, AllocationAlignment alignment); | 2783 bool EnsureAllocation(int size_in_bytes, AllocationAlignment alignment); | 
| 2762 | 2784 | 
| 2763 // If we are doing inline allocation in steps, this method performs the 'step' | 2785 // If we are doing inline allocation in steps, this method performs the 'step' | 
| 2764 // operation. Right now incremental marking is the only consumer of inline | 2786 // operation. top is the memory address of the bump pointer at the last | 
| 2765 // allocation steps. top is the memory address of the bump pointer at the last | |
| 2766 // inline allocation (i.e. it determines the numbers of bytes actually | 2787 // inline allocation (i.e. it determines the numbers of bytes actually | 
| 2767 // allocated since the last step.) new_top is the address of the bump pointer | 2788 // allocated since the last step.) new_top is the address of the bump pointer | 
| 2768 // where the next byte is going to be allocated from. top and new_top may be | 2789 // where the next byte is going to be allocated from. top and new_top may be | 
| 2769 // different when we cross a page boundary or reset the space. | 2790 // different when we cross a page boundary or reset the space. | 
| 2770 void InlineAllocationStep(Address top, Address new_top); | 2791 void InlineAllocationStep(Address top, Address new_top); | 
| 2771 | 2792 | 
| 2772 friend class SemiSpaceIterator; | 2793 friend class SemiSpaceIterator; | 
| 2773 }; | 2794 }; | 
| 2774 | 2795 | 
| 2775 // ----------------------------------------------------------------------------- | 2796 // ----------------------------------------------------------------------------- | 
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3009 count = 0; | 3030 count = 0; | 
| 3010 } | 3031 } | 
| 3011 // Must be small, since an iteration is used for lookup. | 3032 // Must be small, since an iteration is used for lookup. | 
| 3012 static const int kMaxComments = 64; | 3033 static const int kMaxComments = 64; | 
| 3013 }; | 3034 }; | 
| 3014 #endif | 3035 #endif | 
| 3015 } // namespace internal | 3036 } // namespace internal | 
| 3016 } // namespace v8 | 3037 } // namespace v8 | 
| 3017 | 3038 | 
| 3018 #endif // V8_HEAP_SPACES_H_ | 3039 #endif // V8_HEAP_SPACES_H_ | 
| OLD | NEW |