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 1741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1752 | 1752 |
1753 // The allocation limit address. | 1753 // The allocation limit address. |
1754 Address* allocation_limit_address() { | 1754 Address* allocation_limit_address() { |
1755 return allocation_info_.limit_address(); | 1755 return allocation_info_.limit_address(); |
1756 } | 1756 } |
1757 | 1757 |
1758 // Allocate the requested number of bytes in the space if possible, return a | 1758 // Allocate the requested number of bytes in the space if possible, return a |
1759 // failure object if not. | 1759 // failure object if not. |
1760 MUST_USE_RESULT inline AllocationResult AllocateRaw(int size_in_bytes); | 1760 MUST_USE_RESULT inline AllocationResult AllocateRaw(int size_in_bytes); |
1761 | 1761 |
| 1762 // Allocate the requested number of bytes in the space double aligned if |
| 1763 // possible, return a failure object if not. |
| 1764 MUST_USE_RESULT inline AllocationResult AllocateRawDoubleAligned( |
| 1765 int size_in_bytes); |
| 1766 |
1762 // Give a block of memory to the space's free list. It might be added to | 1767 // Give a block of memory to the space's free list. It might be added to |
1763 // the free list or accounted as waste. | 1768 // the free list or accounted as waste. |
1764 // If add_to_freelist is false then just accounting stats are updated and | 1769 // If add_to_freelist is false then just accounting stats are updated and |
1765 // no attempt to add area to free list is made. | 1770 // no attempt to add area to free list is made. |
1766 int Free(Address start, int size_in_bytes) { | 1771 int Free(Address start, int size_in_bytes) { |
1767 int wasted = free_list_.Free(start, size_in_bytes); | 1772 int wasted = free_list_.Free(start, size_in_bytes); |
1768 accounting_stats_.DeallocateBytes(size_in_bytes); | 1773 accounting_stats_.DeallocateBytes(size_in_bytes); |
1769 accounting_stats_.WasteBytes(wasted); | 1774 accounting_stats_.WasteBytes(wasted); |
1770 return size_in_bytes - wasted; | 1775 return size_in_bytes - wasted; |
1771 } | 1776 } |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1912 | 1917 |
1913 // Expands the space by allocating a fixed number of pages. Returns false if | 1918 // Expands the space by allocating a fixed number of pages. Returns false if |
1914 // it cannot allocate requested number of pages from OS, or if the hard heap | 1919 // it cannot allocate requested number of pages from OS, or if the hard heap |
1915 // size limit has been hit. | 1920 // size limit has been hit. |
1916 bool Expand(); | 1921 bool Expand(); |
1917 | 1922 |
1918 // Generic fast case allocation function that tries linear allocation at the | 1923 // Generic fast case allocation function that tries linear allocation at the |
1919 // address denoted by top in allocation_info_. | 1924 // address denoted by top in allocation_info_. |
1920 inline HeapObject* AllocateLinearly(int size_in_bytes); | 1925 inline HeapObject* AllocateLinearly(int size_in_bytes); |
1921 | 1926 |
| 1927 // Generic fast case allocation function that tries double aligned linear |
| 1928 // allocation at the address denoted by top in allocation_info_. |
| 1929 inline HeapObject* AllocateLinearlyDoubleAlign(int size_in_bytes); |
| 1930 |
1922 // If sweeping is still in progress try to sweep unswept pages. If that is | 1931 // If sweeping is still in progress try to sweep unswept pages. If that is |
1923 // not successful, wait for the sweeper threads and re-try free-list | 1932 // not successful, wait for the sweeper threads and re-try free-list |
1924 // allocation. | 1933 // allocation. |
1925 MUST_USE_RESULT HeapObject* WaitForSweeperThreadsAndRetryAllocation( | 1934 MUST_USE_RESULT HeapObject* WaitForSweeperThreadsAndRetryAllocation( |
1926 int size_in_bytes); | 1935 int size_in_bytes); |
1927 | 1936 |
1928 // Slow path of AllocateRaw. This function is space-dependent. | 1937 // Slow path of AllocateRaw. This function is space-dependent. |
1929 MUST_USE_RESULT HeapObject* SlowAllocateRaw(int size_in_bytes); | 1938 MUST_USE_RESULT HeapObject* SlowAllocateRaw(int size_in_bytes); |
1930 | 1939 |
1931 friend class PageIterator; | 1940 friend class PageIterator; |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2477 } | 2486 } |
2478 | 2487 |
2479 // The allocation top and limit address. | 2488 // The allocation top and limit address. |
2480 Address* allocation_top_address() { return allocation_info_.top_address(); } | 2489 Address* allocation_top_address() { return allocation_info_.top_address(); } |
2481 | 2490 |
2482 // The allocation limit address. | 2491 // The allocation limit address. |
2483 Address* allocation_limit_address() { | 2492 Address* allocation_limit_address() { |
2484 return allocation_info_.limit_address(); | 2493 return allocation_info_.limit_address(); |
2485 } | 2494 } |
2486 | 2495 |
| 2496 MUST_USE_RESULT INLINE( |
| 2497 AllocationResult AllocateRawDoubleAligned(int size_in_bytes)); |
| 2498 |
2487 MUST_USE_RESULT INLINE(AllocationResult AllocateRaw(int size_in_bytes)); | 2499 MUST_USE_RESULT INLINE(AllocationResult AllocateRaw(int size_in_bytes)); |
2488 | 2500 |
2489 // Reset the allocation pointer to the beginning of the active semispace. | 2501 // Reset the allocation pointer to the beginning of the active semispace. |
2490 void ResetAllocationInfo(); | 2502 void ResetAllocationInfo(); |
2491 | 2503 |
2492 void UpdateInlineAllocationLimit(int size_in_bytes); | 2504 void UpdateInlineAllocationLimit(int size_in_bytes); |
2493 void LowerInlineAllocationLimit(intptr_t step) { | 2505 void LowerInlineAllocationLimit(intptr_t step) { |
2494 inline_allocation_limit_step_ = step; | 2506 inline_allocation_limit_step_ = step; |
2495 UpdateInlineAllocationLimit(0); | 2507 UpdateInlineAllocationLimit(0); |
2496 top_on_previous_step_ = allocation_info_.top(); | 2508 top_on_previous_step_ = allocation_info_.top(); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2594 // to be lower than actual limit and then will gradually increase it | 2606 // to be lower than actual limit and then will gradually increase it |
2595 // in steps to guarantee that we do incremental marking steps even | 2607 // in steps to guarantee that we do incremental marking steps even |
2596 // when all allocation is performed from inlined generated code. | 2608 // when all allocation is performed from inlined generated code. |
2597 intptr_t inline_allocation_limit_step_; | 2609 intptr_t inline_allocation_limit_step_; |
2598 | 2610 |
2599 Address top_on_previous_step_; | 2611 Address top_on_previous_step_; |
2600 | 2612 |
2601 HistogramInfo* allocated_histogram_; | 2613 HistogramInfo* allocated_histogram_; |
2602 HistogramInfo* promoted_histogram_; | 2614 HistogramInfo* promoted_histogram_; |
2603 | 2615 |
2604 MUST_USE_RESULT AllocationResult SlowAllocateRaw(int size_in_bytes); | 2616 MUST_USE_RESULT AllocationResult |
| 2617 SlowAllocateRaw(int size_in_bytes, bool double_aligned); |
2605 | 2618 |
2606 friend class SemiSpaceIterator; | 2619 friend class SemiSpaceIterator; |
2607 | 2620 |
2608 public: | 2621 public: |
2609 TRACK_MEMORY("NewSpace") | 2622 TRACK_MEMORY("NewSpace") |
2610 }; | 2623 }; |
2611 | 2624 |
2612 | 2625 |
2613 // ----------------------------------------------------------------------------- | 2626 // ----------------------------------------------------------------------------- |
2614 // Old object space (includes the old space of objects and code space) | 2627 // 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... |
2853 count = 0; | 2866 count = 0; |
2854 } | 2867 } |
2855 // Must be small, since an iteration is used for lookup. | 2868 // Must be small, since an iteration is used for lookup. |
2856 static const int kMaxComments = 64; | 2869 static const int kMaxComments = 64; |
2857 }; | 2870 }; |
2858 #endif | 2871 #endif |
2859 } | 2872 } |
2860 } // namespace v8::internal | 2873 } // namespace v8::internal |
2861 | 2874 |
2862 #endif // V8_HEAP_SPACES_H_ | 2875 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |