| 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 2321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2332 // forwards most functions to the appropriate semispace. | 2332 // forwards most functions to the appropriate semispace. |
| 2333 | 2333 |
| 2334 class NewSpace : public Space { | 2334 class NewSpace : public Space { |
| 2335 public: | 2335 public: |
| 2336 // Constructor. | 2336 // Constructor. |
| 2337 explicit NewSpace(Heap* heap) | 2337 explicit NewSpace(Heap* heap) |
| 2338 : Space(heap, NEW_SPACE, NOT_EXECUTABLE), | 2338 : Space(heap, NEW_SPACE, NOT_EXECUTABLE), |
| 2339 to_space_(heap, kToSpace), | 2339 to_space_(heap, kToSpace), |
| 2340 from_space_(heap, kFromSpace), | 2340 from_space_(heap, kFromSpace), |
| 2341 reservation_(), | 2341 reservation_(), |
| 2342 inline_allocation_limit_step_(0) {} | 2342 inline_allocation_limit_step_(0), |
| 2343 grow_to_target_capacity_(false) {} |
| 2343 | 2344 |
| 2344 // Sets up the new space using the given chunk. | 2345 // Sets up the new space using the given chunk. |
| 2345 bool SetUp(int reserved_semispace_size_, int max_semi_space_size); | 2346 bool SetUp(int reserved_semispace_size_, int max_semi_space_size); |
| 2346 | 2347 |
| 2347 // Tears down the space. Heap memory was not allocated by the space, so it | 2348 // Tears down the space. Heap memory was not allocated by the space, so it |
| 2348 // is not deallocated here. | 2349 // is not deallocated here. |
| 2349 void TearDown(); | 2350 void TearDown(); |
| 2350 | 2351 |
| 2351 // True if the space has been set up but not torn down. | 2352 // True if the space has been set up but not torn down. |
| 2352 bool HasBeenSetUp() { | 2353 bool HasBeenSetUp() { |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2562 if (!from_space_.is_committed()) return true; | 2563 if (!from_space_.is_committed()) return true; |
| 2563 return from_space_.Uncommit(); | 2564 return from_space_.Uncommit(); |
| 2564 } | 2565 } |
| 2565 | 2566 |
| 2566 inline intptr_t inline_allocation_limit_step() { | 2567 inline intptr_t inline_allocation_limit_step() { |
| 2567 return inline_allocation_limit_step_; | 2568 return inline_allocation_limit_step_; |
| 2568 } | 2569 } |
| 2569 | 2570 |
| 2570 SemiSpace* active_space() { return &to_space_; } | 2571 SemiSpace* active_space() { return &to_space_; } |
| 2571 | 2572 |
| 2573 void set_grow_to_target_capacity(bool grow_to_target_capacity) { |
| 2574 grow_to_target_capacity_ = grow_to_target_capacity; |
| 2575 } |
| 2576 |
| 2572 private: | 2577 private: |
| 2573 // Update allocation info to match the current to-space page. | 2578 // Update allocation info to match the current to-space page. |
| 2574 void UpdateAllocationInfo(); | 2579 void UpdateAllocationInfo(); |
| 2575 | 2580 |
| 2576 Address chunk_base_; | 2581 Address chunk_base_; |
| 2577 uintptr_t chunk_size_; | 2582 uintptr_t chunk_size_; |
| 2578 | 2583 |
| 2579 // The semispaces. | 2584 // The semispaces. |
| 2580 SemiSpace to_space_; | 2585 SemiSpace to_space_; |
| 2581 SemiSpace from_space_; | 2586 SemiSpace from_space_; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2593 AllocationInfo allocation_info_; | 2598 AllocationInfo allocation_info_; |
| 2594 | 2599 |
| 2595 // When incremental marking is active we will set allocation_info_.limit | 2600 // When incremental marking is active we will set allocation_info_.limit |
| 2596 // to be lower than actual limit and then will gradually increase it | 2601 // to be lower than actual limit and then will gradually increase it |
| 2597 // in steps to guarantee that we do incremental marking steps even | 2602 // in steps to guarantee that we do incremental marking steps even |
| 2598 // when all allocation is performed from inlined generated code. | 2603 // when all allocation is performed from inlined generated code. |
| 2599 intptr_t inline_allocation_limit_step_; | 2604 intptr_t inline_allocation_limit_step_; |
| 2600 | 2605 |
| 2601 Address top_on_previous_step_; | 2606 Address top_on_previous_step_; |
| 2602 | 2607 |
| 2608 // True if the new space should be expanded up to the target capacity |
| 2609 // when the current page is full. |
| 2610 bool grow_to_target_capacity_; |
| 2611 |
| 2603 HistogramInfo* allocated_histogram_; | 2612 HistogramInfo* allocated_histogram_; |
| 2604 HistogramInfo* promoted_histogram_; | 2613 HistogramInfo* promoted_histogram_; |
| 2605 | 2614 |
| 2606 MUST_USE_RESULT AllocationResult SlowAllocateRaw(int size_in_bytes); | 2615 MUST_USE_RESULT AllocationResult SlowAllocateRaw(int size_in_bytes); |
| 2607 | 2616 |
| 2608 friend class SemiSpaceIterator; | 2617 friend class SemiSpaceIterator; |
| 2609 | 2618 |
| 2610 public: | 2619 public: |
| 2611 TRACK_MEMORY("NewSpace") | 2620 TRACK_MEMORY("NewSpace") |
| 2612 }; | 2621 }; |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2905 count = 0; | 2914 count = 0; |
| 2906 } | 2915 } |
| 2907 // Must be small, since an iteration is used for lookup. | 2916 // Must be small, since an iteration is used for lookup. |
| 2908 static const int kMaxComments = 64; | 2917 static const int kMaxComments = 64; |
| 2909 }; | 2918 }; |
| 2910 #endif | 2919 #endif |
| 2911 } | 2920 } |
| 2912 } // namespace v8::internal | 2921 } // namespace v8::internal |
| 2913 | 2922 |
| 2914 #endif // V8_HEAP_SPACES_H_ | 2923 #endif // V8_HEAP_SPACES_H_ |
| OLD | NEW |