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 1750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1761 Address* allocation_limit_address() { | 1761 Address* allocation_limit_address() { |
1762 return allocation_info_.limit_address(); | 1762 return allocation_info_.limit_address(); |
1763 } | 1763 } |
1764 | 1764 |
1765 // Allocate the requested number of bytes in the space if possible, return a | 1765 // Allocate the requested number of bytes in the space if possible, return a |
1766 // failure object if not. | 1766 // failure object if not. |
1767 MUST_USE_RESULT inline AllocationResult AllocateRaw(int size_in_bytes); | 1767 MUST_USE_RESULT inline AllocationResult AllocateRaw(int size_in_bytes); |
1768 | 1768 |
1769 // Allocate the requested number of bytes in the space double aligned if | 1769 // Allocate the requested number of bytes in the space double aligned if |
1770 // possible, return a failure object if not. | 1770 // possible, return a failure object if not. |
1771 MUST_USE_RESULT inline AllocationResult AllocateRawDoubleAligned( | 1771 MUST_USE_RESULT inline AllocationResult AllocateRawAligned( |
1772 int size_in_bytes); | 1772 int size_in_bytes, AllocationAlignment alignment); |
1773 | 1773 |
1774 // Give a block of memory to the space's free list. It might be added to | 1774 // Give a block of memory to the space's free list. It might be added to |
1775 // the free list or accounted as waste. | 1775 // the free list or accounted as waste. |
1776 // If add_to_freelist is false then just accounting stats are updated and | 1776 // If add_to_freelist is false then just accounting stats are updated and |
1777 // no attempt to add area to free list is made. | 1777 // no attempt to add area to free list is made. |
1778 int Free(Address start, int size_in_bytes) { | 1778 int Free(Address start, int size_in_bytes) { |
1779 int wasted = free_list_.Free(start, size_in_bytes); | 1779 int wasted = free_list_.Free(start, size_in_bytes); |
1780 accounting_stats_.DeallocateBytes(size_in_bytes); | 1780 accounting_stats_.DeallocateBytes(size_in_bytes); |
1781 accounting_stats_.WasteBytes(wasted); | 1781 accounting_stats_.WasteBytes(wasted); |
1782 return size_in_bytes - wasted; | 1782 return size_in_bytes - wasted; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1926 // it cannot allocate requested number of pages from OS, or if the hard heap | 1926 // it cannot allocate requested number of pages from OS, or if the hard heap |
1927 // size limit has been hit. | 1927 // size limit has been hit. |
1928 bool Expand(); | 1928 bool Expand(); |
1929 | 1929 |
1930 // Generic fast case allocation function that tries linear allocation at the | 1930 // Generic fast case allocation function that tries linear allocation at the |
1931 // address denoted by top in allocation_info_. | 1931 // address denoted by top in allocation_info_. |
1932 inline HeapObject* AllocateLinearly(int size_in_bytes); | 1932 inline HeapObject* AllocateLinearly(int size_in_bytes); |
1933 | 1933 |
1934 // Generic fast case allocation function that tries double aligned linear | 1934 // Generic fast case allocation function that tries double aligned linear |
1935 // allocation at the address denoted by top in allocation_info_. | 1935 // allocation at the address denoted by top in allocation_info_. |
1936 inline HeapObject* AllocateLinearlyDoubleAlign(int size_in_bytes); | 1936 inline HeapObject* AllocateLinearlyAligned(int size_in_bytes, |
| 1937 AllocationAlignment alignment); |
1937 | 1938 |
1938 // If sweeping is still in progress try to sweep unswept pages. If that is | 1939 // If sweeping is still in progress try to sweep unswept pages. If that is |
1939 // not successful, wait for the sweeper threads and re-try free-list | 1940 // not successful, wait for the sweeper threads and re-try free-list |
1940 // allocation. | 1941 // allocation. |
1941 MUST_USE_RESULT HeapObject* WaitForSweeperThreadsAndRetryAllocation( | 1942 MUST_USE_RESULT HeapObject* WaitForSweeperThreadsAndRetryAllocation( |
1942 int size_in_bytes); | 1943 int size_in_bytes); |
1943 | 1944 |
1944 // Slow path of AllocateRaw. This function is space-dependent. | 1945 // Slow path of AllocateRaw. This function is space-dependent. |
1945 MUST_USE_RESULT HeapObject* SlowAllocateRaw(int size_in_bytes); | 1946 MUST_USE_RESULT HeapObject* SlowAllocateRaw(int size_in_bytes); |
1946 | 1947 |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2493 } | 2494 } |
2494 | 2495 |
2495 // The allocation top and limit address. | 2496 // The allocation top and limit address. |
2496 Address* allocation_top_address() { return allocation_info_.top_address(); } | 2497 Address* allocation_top_address() { return allocation_info_.top_address(); } |
2497 | 2498 |
2498 // The allocation limit address. | 2499 // The allocation limit address. |
2499 Address* allocation_limit_address() { | 2500 Address* allocation_limit_address() { |
2500 return allocation_info_.limit_address(); | 2501 return allocation_info_.limit_address(); |
2501 } | 2502 } |
2502 | 2503 |
2503 MUST_USE_RESULT INLINE( | 2504 MUST_USE_RESULT INLINE(AllocationResult AllocateRawAligned( |
2504 AllocationResult AllocateRawDoubleAligned(int size_in_bytes)); | 2505 int size_in_bytes, AllocationAlignment alignment)); |
2505 | 2506 |
2506 MUST_USE_RESULT INLINE(AllocationResult AllocateRaw(int size_in_bytes)); | 2507 MUST_USE_RESULT INLINE(AllocationResult AllocateRaw(int size_in_bytes)); |
2507 | 2508 |
2508 // Reset the allocation pointer to the beginning of the active semispace. | 2509 // Reset the allocation pointer to the beginning of the active semispace. |
2509 void ResetAllocationInfo(); | 2510 void ResetAllocationInfo(); |
2510 | 2511 |
2511 void UpdateInlineAllocationLimit(int size_in_bytes); | 2512 void UpdateInlineAllocationLimit(int size_in_bytes); |
2512 void LowerInlineAllocationLimit(intptr_t step) { | 2513 void LowerInlineAllocationLimit(intptr_t step) { |
2513 inline_allocation_limit_step_ = step; | 2514 inline_allocation_limit_step_ = step; |
2514 UpdateInlineAllocationLimit(0); | 2515 UpdateInlineAllocationLimit(0); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2614 // in steps to guarantee that we do incremental marking steps even | 2615 // in steps to guarantee that we do incremental marking steps even |
2615 // when all allocation is performed from inlined generated code. | 2616 // when all allocation is performed from inlined generated code. |
2616 intptr_t inline_allocation_limit_step_; | 2617 intptr_t inline_allocation_limit_step_; |
2617 | 2618 |
2618 Address top_on_previous_step_; | 2619 Address top_on_previous_step_; |
2619 | 2620 |
2620 HistogramInfo* allocated_histogram_; | 2621 HistogramInfo* allocated_histogram_; |
2621 HistogramInfo* promoted_histogram_; | 2622 HistogramInfo* promoted_histogram_; |
2622 | 2623 |
2623 MUST_USE_RESULT AllocationResult | 2624 MUST_USE_RESULT AllocationResult |
2624 SlowAllocateRaw(int size_in_bytes, bool double_aligned); | 2625 SlowAllocateRaw(int size_in_bytes, AllocationAlignment alignment); |
2625 | 2626 |
2626 friend class SemiSpaceIterator; | 2627 friend class SemiSpaceIterator; |
2627 | 2628 |
2628 public: | 2629 public: |
2629 TRACK_MEMORY("NewSpace") | 2630 TRACK_MEMORY("NewSpace") |
2630 }; | 2631 }; |
2631 | 2632 |
2632 | 2633 |
2633 // ----------------------------------------------------------------------------- | 2634 // ----------------------------------------------------------------------------- |
2634 // Old object space (includes the old space of objects and code space) | 2635 // Old object space (includes the old space of objects and code space) |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2873 count = 0; | 2874 count = 0; |
2874 } | 2875 } |
2875 // Must be small, since an iteration is used for lookup. | 2876 // Must be small, since an iteration is used for lookup. |
2876 static const int kMaxComments = 64; | 2877 static const int kMaxComments = 64; |
2877 }; | 2878 }; |
2878 #endif | 2879 #endif |
2879 } | 2880 } |
2880 } // namespace v8::internal | 2881 } // namespace v8::internal |
2881 | 2882 |
2882 #endif // V8_HEAP_SPACES_H_ | 2883 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |