| 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 <list> | 8 #include <list> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <unordered_set> | 10 #include <unordered_set> |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 // x64 and ia32 architectures. | 810 // x64 and ia32 architectures. |
| 811 static const int kMaxCodePageSize = 512 * MB; | 811 static const int kMaxCodePageSize = 512 * MB; |
| 812 | 812 |
| 813 private: | 813 private: |
| 814 static inline LargePage* Initialize(Heap* heap, MemoryChunk* chunk, | 814 static inline LargePage* Initialize(Heap* heap, MemoryChunk* chunk, |
| 815 Executability executable, Space* owner); | 815 Executability executable, Space* owner); |
| 816 | 816 |
| 817 friend class MemoryAllocator; | 817 friend class MemoryAllocator; |
| 818 }; | 818 }; |
| 819 | 819 |
| 820 | |
| 821 // ---------------------------------------------------------------------------- | 820 // ---------------------------------------------------------------------------- |
| 822 // Space is the abstract superclass for all allocation spaces. | 821 // Space is the abstract superclass for all allocation spaces. |
| 823 class Space : public Malloced { | 822 class Space : public Malloced { |
| 824 public: | 823 public: |
| 825 Space(Heap* heap, AllocationSpace id, Executability executable) | 824 Space(Heap* heap, AllocationSpace id, Executability executable) |
| 826 : allocation_observers_(new List<AllocationObserver*>()), | 825 : allocation_observers_(new List<AllocationObserver*>()), |
| 827 allocation_observers_paused_(false), | 826 allocation_observers_paused_(false), |
| 828 heap_(heap), | 827 heap_(heap), |
| 829 id_(id), | 828 id_(id), |
| 830 executable_(executable), | 829 executable_(executable), |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 AllocationSpace id_; | 915 AllocationSpace id_; |
| 917 Executability executable_; | 916 Executability executable_; |
| 918 | 917 |
| 919 // Keeps track of committed memory in a space. | 918 // Keeps track of committed memory in a space. |
| 920 size_t committed_; | 919 size_t committed_; |
| 921 size_t max_committed_; | 920 size_t max_committed_; |
| 922 | 921 |
| 923 DISALLOW_COPY_AND_ASSIGN(Space); | 922 DISALLOW_COPY_AND_ASSIGN(Space); |
| 924 }; | 923 }; |
| 925 | 924 |
| 925 // An abstraction of allocation and relocation pointers in a page-structured |
| 926 // space. |
| 927 class AllocationInfo { |
| 928 public: |
| 929 AllocationInfo() : original_top_(nullptr), top_(nullptr), limit_(nullptr) {} |
| 930 AllocationInfo(Address top, Address limit) |
| 931 : original_top_(top), top_(top), limit_(limit) {} |
| 932 |
| 933 void Reset(Address top, Address limit) { |
| 934 original_top_ = top; |
| 935 set_top(top); |
| 936 set_limit(limit); |
| 937 } |
| 938 |
| 939 Address original_top() { |
| 940 SLOW_DCHECK(top_ == NULL || |
| 941 (reinterpret_cast<intptr_t>(top_) & kHeapObjectTagMask) == 0); |
| 942 return original_top_; |
| 943 } |
| 944 |
| 945 INLINE(void set_top(Address top)) { |
| 946 SLOW_DCHECK(top == NULL || |
| 947 (reinterpret_cast<intptr_t>(top) & kHeapObjectTagMask) == 0); |
| 948 top_ = top; |
| 949 } |
| 950 |
| 951 INLINE(Address top()) const { |
| 952 SLOW_DCHECK(top_ == NULL || |
| 953 (reinterpret_cast<intptr_t>(top_) & kHeapObjectTagMask) == 0); |
| 954 return top_; |
| 955 } |
| 956 |
| 957 Address* top_address() { return &top_; } |
| 958 |
| 959 INLINE(void set_limit(Address limit)) { limit_ = limit; } |
| 960 |
| 961 INLINE(Address limit()) const { return limit_; } |
| 962 |
| 963 Address* limit_address() { return &limit_; } |
| 964 |
| 965 #ifdef DEBUG |
| 966 bool VerifyPagedAllocation() { |
| 967 return (Page::FromAllocationAreaAddress(top_) == |
| 968 Page::FromAllocationAreaAddress(limit_)) && |
| 969 (top_ <= limit_); |
| 970 } |
| 971 #endif |
| 972 |
| 973 private: |
| 974 // The original top address when the allocation info was initialized. |
| 975 Address original_top_; |
| 976 // Current allocation top. |
| 977 Address top_; |
| 978 // Current allocation limit. |
| 979 Address limit_; |
| 980 }; |
| 981 |
| 982 class SpaceWithInlineAllocationArea : public Space { |
| 983 public: |
| 984 SpaceWithInlineAllocationArea(Heap* heap, AllocationSpace id, |
| 985 Executability executable) |
| 986 : Space(heap, id, executable), allocation_info_(nullptr, nullptr) {} |
| 987 |
| 988 Address top() { return allocation_info_.top(); } |
| 989 Address limit() { return allocation_info_.limit(); } |
| 990 |
| 991 Address* allocation_top_address() { return allocation_info_.top_address(); } |
| 992 |
| 993 Address* allocation_limit_address() { |
| 994 return allocation_info_.limit_address(); |
| 995 } |
| 996 |
| 997 protected: |
| 998 AllocationInfo allocation_info_; |
| 999 }; |
| 926 | 1000 |
| 927 class MemoryChunkValidator { | 1001 class MemoryChunkValidator { |
| 928 // Computed offsets should match the compiler generated ones. | 1002 // Computed offsets should match the compiler generated ones. |
| 929 STATIC_ASSERT(MemoryChunk::kSizeOffset == offsetof(MemoryChunk, size_)); | 1003 STATIC_ASSERT(MemoryChunk::kSizeOffset == offsetof(MemoryChunk, size_)); |
| 930 | 1004 |
| 931 // Validate our estimates on the header size. | 1005 // Validate our estimates on the header size. |
| 932 STATIC_ASSERT(sizeof(MemoryChunk) <= MemoryChunk::kHeaderSize); | 1006 STATIC_ASSERT(sizeof(MemoryChunk) <= MemoryChunk::kHeaderSize); |
| 933 STATIC_ASSERT(sizeof(LargePage) <= MemoryChunk::kHeaderSize); | 1007 STATIC_ASSERT(sizeof(LargePage) <= MemoryChunk::kHeaderSize); |
| 934 STATIC_ASSERT(sizeof(Page) <= MemoryChunk::kHeaderSize); | 1008 STATIC_ASSERT(sizeof(Page) <= MemoryChunk::kHeaderSize); |
| 935 }; | 1009 }; |
| (...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1409 private: | 1483 private: |
| 1410 PAGE_TYPE* p_; | 1484 PAGE_TYPE* p_; |
| 1411 }; | 1485 }; |
| 1412 | 1486 |
| 1413 typedef PageIteratorImpl<Page> PageIterator; | 1487 typedef PageIteratorImpl<Page> PageIterator; |
| 1414 typedef PageIteratorImpl<LargePage> LargePageIterator; | 1488 typedef PageIteratorImpl<LargePage> LargePageIterator; |
| 1415 | 1489 |
| 1416 class PageRange { | 1490 class PageRange { |
| 1417 public: | 1491 public: |
| 1418 typedef PageIterator iterator; | 1492 typedef PageIterator iterator; |
| 1493 |
| 1494 explicit PageRange(Page* page) : PageRange(page, page->next_page()) {} |
| 1419 PageRange(Page* begin, Page* end) : begin_(begin), end_(end) {} | 1495 PageRange(Page* begin, Page* end) : begin_(begin), end_(end) {} |
| 1420 explicit PageRange(Page* page) : PageRange(page, page->next_page()) {} | 1496 inline PageRange(Address start, Address limit); |
| 1497 |
| 1421 iterator begin() { return iterator(begin_); } | 1498 iterator begin() { return iterator(begin_); } |
| 1422 iterator end() { return iterator(end_); } | 1499 iterator end() { return iterator(end_); } |
| 1423 | 1500 |
| 1424 private: | 1501 private: |
| 1425 Page* begin_; | 1502 Page* begin_; |
| 1426 Page* end_; | 1503 Page* end_; |
| 1427 }; | 1504 }; |
| 1428 | 1505 |
| 1429 // ----------------------------------------------------------------------------- | 1506 // ----------------------------------------------------------------------------- |
| 1430 // Heap object iterator in new/old/map spaces. | 1507 // Heap object iterator in new/old/map spaces. |
| 1431 // | 1508 // |
| 1432 // A HeapObjectIterator iterates objects from the bottom of the given space | 1509 // A HeapObjectIterator iterates objects from the bottom of the given space |
| 1433 // to its top or from the bottom of the given page to its top. | 1510 // to its top or from the bottom of the given page to its top. |
| 1434 // | 1511 // |
| 1435 // If objects are allocated in the page during iteration the iterator may | 1512 // If objects are allocated in the page during iteration the iterator may |
| 1436 // or may not iterate over those objects. The caller must create a new | 1513 // or may not iterate over those objects. The caller must create a new |
| 1437 // iterator in order to be sure to visit these new objects. | 1514 // iterator in order to be sure to visit these new objects. |
| 1438 class V8_EXPORT_PRIVATE HeapObjectIterator : public ObjectIterator { | 1515 class V8_EXPORT_PRIVATE HeapObjectIterator : public ObjectIterator { |
| 1439 public: | 1516 public: |
| 1440 // Creates a new object iterator in a given space. | |
| 1441 explicit HeapObjectIterator(PagedSpace* space); | 1517 explicit HeapObjectIterator(PagedSpace* space); |
| 1518 explicit HeapObjectIterator(NewSpace* space); |
| 1442 explicit HeapObjectIterator(Page* page); | 1519 explicit HeapObjectIterator(Page* page); |
| 1443 | 1520 |
| 1444 // Advance to the next object, skipping free spaces and other fillers and | 1521 // Advance to the next object, skipping free spaces and other fillers and |
| 1445 // skipping the special garbage section of which there is one per space. | 1522 // skipping the special garbage section of which there is one per space. |
| 1446 // Returns nullptr when the iteration has ended. | 1523 // Returns nullptr when the iteration has ended. |
| 1447 inline HeapObject* Next() override; | 1524 inline HeapObject* Next() override; |
| 1448 | 1525 |
| 1449 private: | 1526 private: |
| 1527 inline Page* current_page() { return (*next_page_)->prev_page(); } |
| 1450 // Fast (inlined) path of next(). | 1528 // Fast (inlined) path of next(). |
| 1451 inline HeapObject* FromCurrentPage(); | 1529 inline HeapObject* FromCurrentPage(); |
| 1452 | 1530 |
| 1453 // Slow path of next(), goes into the next page. Returns false if the | 1531 // Slow path of next(), goes into the next page. Returns false if the |
| 1454 // iteration has ended. | 1532 // iteration has ended. |
| 1455 bool AdvanceToNextPage(); | 1533 bool AdvanceToNextPage(); |
| 1456 | 1534 |
| 1457 Address cur_addr_; // Current iteration point. | 1535 Address cur_addr_; // Current iteration point. |
| 1458 Address cur_end_; // End iteration point. | 1536 Address cur_end_; // End iteration point. |
| 1459 PagedSpace* space_; | 1537 SpaceWithInlineAllocationArea* space_; |
| 1460 PageRange page_range_; | 1538 PageRange page_range_; |
| 1461 PageRange::iterator current_page_; | 1539 PageRange::iterator next_page_; |
| 1462 }; | 1540 }; |
| 1463 | 1541 |
| 1464 | |
| 1465 // ----------------------------------------------------------------------------- | |
| 1466 // A space has a circular list of pages. The next page can be accessed via | |
| 1467 // Page::next_page() call. | |
| 1468 | |
| 1469 // An abstraction of allocation and relocation pointers in a page-structured | |
| 1470 // space. | |
| 1471 class AllocationInfo { | |
| 1472 public: | |
| 1473 AllocationInfo() : original_top_(nullptr), top_(nullptr), limit_(nullptr) {} | |
| 1474 AllocationInfo(Address top, Address limit) | |
| 1475 : original_top_(top), top_(top), limit_(limit) {} | |
| 1476 | |
| 1477 void Reset(Address top, Address limit) { | |
| 1478 original_top_ = top; | |
| 1479 set_top(top); | |
| 1480 set_limit(limit); | |
| 1481 } | |
| 1482 | |
| 1483 Address original_top() { | |
| 1484 SLOW_DCHECK(top_ == NULL || | |
| 1485 (reinterpret_cast<intptr_t>(top_) & kHeapObjectTagMask) == 0); | |
| 1486 return original_top_; | |
| 1487 } | |
| 1488 | |
| 1489 INLINE(void set_top(Address top)) { | |
| 1490 SLOW_DCHECK(top == NULL || | |
| 1491 (reinterpret_cast<intptr_t>(top) & kHeapObjectTagMask) == 0); | |
| 1492 top_ = top; | |
| 1493 } | |
| 1494 | |
| 1495 INLINE(Address top()) const { | |
| 1496 SLOW_DCHECK(top_ == NULL || | |
| 1497 (reinterpret_cast<intptr_t>(top_) & kHeapObjectTagMask) == 0); | |
| 1498 return top_; | |
| 1499 } | |
| 1500 | |
| 1501 Address* top_address() { return &top_; } | |
| 1502 | |
| 1503 INLINE(void set_limit(Address limit)) { | |
| 1504 limit_ = limit; | |
| 1505 } | |
| 1506 | |
| 1507 INLINE(Address limit()) const { | |
| 1508 return limit_; | |
| 1509 } | |
| 1510 | |
| 1511 Address* limit_address() { return &limit_; } | |
| 1512 | |
| 1513 #ifdef DEBUG | |
| 1514 bool VerifyPagedAllocation() { | |
| 1515 return (Page::FromAllocationAreaAddress(top_) == | |
| 1516 Page::FromAllocationAreaAddress(limit_)) && | |
| 1517 (top_ <= limit_); | |
| 1518 } | |
| 1519 #endif | |
| 1520 | |
| 1521 private: | |
| 1522 // The original top address when the allocation info was initialized. | |
| 1523 Address original_top_; | |
| 1524 // Current allocation top. | |
| 1525 Address top_; | |
| 1526 // Current allocation limit. | |
| 1527 Address limit_; | |
| 1528 }; | |
| 1529 | |
| 1530 | |
| 1531 // An abstraction of the accounting statistics of a page-structured space. | 1542 // An abstraction of the accounting statistics of a page-structured space. |
| 1532 // | 1543 // |
| 1533 // The stats are only set by functions that ensure they stay balanced. These | 1544 // The stats are only set by functions that ensure they stay balanced. These |
| 1534 // functions increase or decrease one of the non-capacity stats in conjunction | 1545 // functions increase or decrease one of the non-capacity stats in conjunction |
| 1535 // with capacity, or else they always balance increases and decreases to the | 1546 // with capacity, or else they always balance increases and decreases to the |
| 1536 // non-capacity stats. | 1547 // non-capacity stats. |
| 1537 class AllocationStats BASE_EMBEDDED { | 1548 class AllocationStats BASE_EMBEDDED { |
| 1538 public: | 1549 public: |
| 1539 AllocationStats() { Clear(); } | 1550 AllocationStats() { Clear(); } |
| 1540 | 1551 |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1870 | 1881 |
| 1871 private: | 1882 private: |
| 1872 LocalAllocationBuffer(Heap* heap, AllocationInfo allocation_info); | 1883 LocalAllocationBuffer(Heap* heap, AllocationInfo allocation_info); |
| 1873 | 1884 |
| 1874 void Close(); | 1885 void Close(); |
| 1875 | 1886 |
| 1876 Heap* heap_; | 1887 Heap* heap_; |
| 1877 AllocationInfo allocation_info_; | 1888 AllocationInfo allocation_info_; |
| 1878 }; | 1889 }; |
| 1879 | 1890 |
| 1880 class NewSpacePageRange { | 1891 class PagedSpace : public SpaceWithInlineAllocationArea { |
| 1881 public: | |
| 1882 typedef PageRange::iterator iterator; | |
| 1883 inline NewSpacePageRange(Address start, Address limit); | |
| 1884 iterator begin() { return range_.begin(); } | |
| 1885 iterator end() { return range_.end(); } | |
| 1886 | |
| 1887 private: | |
| 1888 PageRange range_; | |
| 1889 }; | |
| 1890 | |
| 1891 class PagedSpace : public Space { | |
| 1892 public: | 1892 public: |
| 1893 typedef PageIterator iterator; | 1893 typedef PageIterator iterator; |
| 1894 | 1894 |
| 1895 static const intptr_t kCompactionMemoryWanted = 500 * KB; | 1895 static const intptr_t kCompactionMemoryWanted = 500 * KB; |
| 1896 | 1896 |
| 1897 // Creates a space with an id. | 1897 // Creates a space with an id. |
| 1898 PagedSpace(Heap* heap, AllocationSpace id, Executability executable); | 1898 PagedSpace(Heap* heap, AllocationSpace id, Executability executable); |
| 1899 | 1899 |
| 1900 ~PagedSpace() override { TearDown(); } | 1900 ~PagedSpace() override { TearDown(); } |
| 1901 | 1901 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1959 size_t Size() override { return accounting_stats_.Size(); } | 1959 size_t Size() override { return accounting_stats_.Size(); } |
| 1960 | 1960 |
| 1961 // As size, but the bytes in lazily swept pages are estimated and the bytes | 1961 // As size, but the bytes in lazily swept pages are estimated and the bytes |
| 1962 // in the current linear allocation area are not included. | 1962 // in the current linear allocation area are not included. |
| 1963 size_t SizeOfObjects() override; | 1963 size_t SizeOfObjects() override; |
| 1964 | 1964 |
| 1965 // Wasted bytes in this space. These are just the bytes that were thrown away | 1965 // Wasted bytes in this space. These are just the bytes that were thrown away |
| 1966 // due to being too small to use for allocation. | 1966 // due to being too small to use for allocation. |
| 1967 virtual size_t Waste() { return free_list_.wasted_bytes(); } | 1967 virtual size_t Waste() { return free_list_.wasted_bytes(); } |
| 1968 | 1968 |
| 1969 // Returns the allocation pointer in this space. | |
| 1970 Address top() { return allocation_info_.top(); } | |
| 1971 Address limit() { return allocation_info_.limit(); } | |
| 1972 | |
| 1973 // The allocation top address. | |
| 1974 Address* allocation_top_address() { return allocation_info_.top_address(); } | |
| 1975 | |
| 1976 // The allocation limit address. | |
| 1977 Address* allocation_limit_address() { | |
| 1978 return allocation_info_.limit_address(); | |
| 1979 } | |
| 1980 | |
| 1981 enum UpdateSkipList { UPDATE_SKIP_LIST, IGNORE_SKIP_LIST }; | 1969 enum UpdateSkipList { UPDATE_SKIP_LIST, IGNORE_SKIP_LIST }; |
| 1982 | 1970 |
| 1983 // Allocate the requested number of bytes in the space if possible, return a | 1971 // Allocate the requested number of bytes in the space if possible, return a |
| 1984 // failure object if not. Only use IGNORE_SKIP_LIST if the skip list is going | 1972 // failure object if not. Only use IGNORE_SKIP_LIST if the skip list is going |
| 1985 // to be manually updated later. | 1973 // to be manually updated later. |
| 1986 MUST_USE_RESULT inline AllocationResult AllocateRawUnaligned( | 1974 MUST_USE_RESULT inline AllocationResult AllocateRawUnaligned( |
| 1987 int size_in_bytes, UpdateSkipList update_skip_list = UPDATE_SKIP_LIST); | 1975 int size_in_bytes, UpdateSkipList update_skip_list = UPDATE_SKIP_LIST); |
| 1988 | 1976 |
| 1989 MUST_USE_RESULT inline AllocationResult AllocateRawUnalignedSynchronized( | 1977 MUST_USE_RESULT inline AllocationResult AllocateRawUnalignedSynchronized( |
| 1990 int size_in_bytes); | 1978 int size_in_bytes); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2143 | 2131 |
| 2144 // Accounting information for this space. | 2132 // Accounting information for this space. |
| 2145 AllocationStats accounting_stats_; | 2133 AllocationStats accounting_stats_; |
| 2146 | 2134 |
| 2147 // The dummy page that anchors the double linked list of pages. | 2135 // The dummy page that anchors the double linked list of pages. |
| 2148 Page anchor_; | 2136 Page anchor_; |
| 2149 | 2137 |
| 2150 // The space's free list. | 2138 // The space's free list. |
| 2151 FreeList free_list_; | 2139 FreeList free_list_; |
| 2152 | 2140 |
| 2153 // Normal allocation information. | |
| 2154 AllocationInfo allocation_info_; | |
| 2155 | |
| 2156 // Mutex guarding any concurrent access to the space. | 2141 // Mutex guarding any concurrent access to the space. |
| 2157 base::Mutex space_mutex_; | 2142 base::Mutex space_mutex_; |
| 2158 | 2143 |
| 2159 friend class IncrementalMarking; | 2144 friend class IncrementalMarking; |
| 2160 friend class MarkCompactCollector; | 2145 friend class MarkCompactCollector; |
| 2161 | 2146 |
| 2162 // Used in cctest. | 2147 // Used in cctest. |
| 2163 friend class HeapTester; | 2148 friend class HeapTester; |
| 2164 }; | 2149 }; |
| 2165 | 2150 |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2360 // The end of iteration. | 2345 // The end of iteration. |
| 2361 Address limit_; | 2346 Address limit_; |
| 2362 }; | 2347 }; |
| 2363 | 2348 |
| 2364 // ----------------------------------------------------------------------------- | 2349 // ----------------------------------------------------------------------------- |
| 2365 // The young generation space. | 2350 // The young generation space. |
| 2366 // | 2351 // |
| 2367 // The new space consists of a contiguous pair of semispaces. It simply | 2352 // The new space consists of a contiguous pair of semispaces. It simply |
| 2368 // forwards most functions to the appropriate semispace. | 2353 // forwards most functions to the appropriate semispace. |
| 2369 | 2354 |
| 2370 class NewSpace : public Space { | 2355 class NewSpace : public SpaceWithInlineAllocationArea { |
| 2371 public: | 2356 public: |
| 2372 typedef PageIterator iterator; | 2357 typedef PageIterator iterator; |
| 2373 | 2358 |
| 2374 explicit NewSpace(Heap* heap) | 2359 explicit NewSpace(Heap* heap) |
| 2375 : Space(heap, NEW_SPACE, NOT_EXECUTABLE), | 2360 : SpaceWithInlineAllocationArea(heap, NEW_SPACE, NOT_EXECUTABLE), |
| 2376 to_space_(heap, kToSpace), | 2361 to_space_(heap, kToSpace), |
| 2377 from_space_(heap, kFromSpace), | 2362 from_space_(heap, kFromSpace), |
| 2378 reservation_(), | 2363 reservation_(), |
| 2379 top_on_previous_step_(0), | 2364 top_on_previous_step_(0), |
| 2380 allocated_histogram_(nullptr), | 2365 allocated_histogram_(nullptr), |
| 2381 promoted_histogram_(nullptr) {} | 2366 promoted_histogram_(nullptr) {} |
| 2382 | 2367 |
| 2383 inline bool Contains(HeapObject* o); | 2368 inline bool Contains(HeapObject* o); |
| 2384 inline bool ContainsSlow(Address a); | 2369 inline bool ContainsSlow(Address a); |
| 2385 inline bool Contains(Object* o); | 2370 inline bool Contains(Object* o); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2501 } | 2486 } |
| 2502 | 2487 |
| 2503 bool IsAtMaximumCapacity() { return TotalCapacity() == MaximumCapacity(); } | 2488 bool IsAtMaximumCapacity() { return TotalCapacity() == MaximumCapacity(); } |
| 2504 | 2489 |
| 2505 // Returns the initial capacity of a semispace. | 2490 // Returns the initial capacity of a semispace. |
| 2506 size_t InitialTotalCapacity() { | 2491 size_t InitialTotalCapacity() { |
| 2507 DCHECK(to_space_.minimum_capacity() == from_space_.minimum_capacity()); | 2492 DCHECK(to_space_.minimum_capacity() == from_space_.minimum_capacity()); |
| 2508 return to_space_.minimum_capacity(); | 2493 return to_space_.minimum_capacity(); |
| 2509 } | 2494 } |
| 2510 | 2495 |
| 2511 // Return the address of the allocation pointer in the active semispace. | |
| 2512 Address top() { | |
| 2513 DCHECK(to_space_.current_page()->ContainsLimit(allocation_info_.top())); | |
| 2514 return allocation_info_.top(); | |
| 2515 } | |
| 2516 | |
| 2517 // Return the address of the allocation pointer limit in the active semispace. | |
| 2518 Address limit() { | |
| 2519 DCHECK(to_space_.current_page()->ContainsLimit(allocation_info_.limit())); | |
| 2520 return allocation_info_.limit(); | |
| 2521 } | |
| 2522 | |
| 2523 // Return the address of the first object in the active semispace. | 2496 // Return the address of the first object in the active semispace. |
| 2524 Address bottom() { return to_space_.space_start(); } | 2497 Address bottom() { return to_space_.space_start(); } |
| 2525 | 2498 |
| 2526 // Get the age mark of the inactive semispace. | 2499 // Get the age mark of the inactive semispace. |
| 2527 Address age_mark() { return from_space_.age_mark(); } | 2500 Address age_mark() { return from_space_.age_mark(); } |
| 2528 // Set the age mark in the active semispace. | 2501 // Set the age mark in the active semispace. |
| 2529 void set_age_mark(Address mark) { to_space_.set_age_mark(mark); } | 2502 void set_age_mark(Address mark) { to_space_.set_age_mark(mark); } |
| 2530 | 2503 |
| 2531 // The allocation top and limit address. | |
| 2532 Address* allocation_top_address() { return allocation_info_.top_address(); } | |
| 2533 | |
| 2534 // The allocation limit address. | |
| 2535 Address* allocation_limit_address() { | |
| 2536 return allocation_info_.limit_address(); | |
| 2537 } | |
| 2538 | |
| 2539 MUST_USE_RESULT INLINE(AllocationResult AllocateRawAligned( | 2504 MUST_USE_RESULT INLINE(AllocationResult AllocateRawAligned( |
| 2540 int size_in_bytes, AllocationAlignment alignment)); | 2505 int size_in_bytes, AllocationAlignment alignment)); |
| 2541 | 2506 |
| 2542 MUST_USE_RESULT INLINE( | 2507 MUST_USE_RESULT INLINE( |
| 2543 AllocationResult AllocateRawUnaligned(int size_in_bytes)); | 2508 AllocationResult AllocateRawUnaligned(int size_in_bytes)); |
| 2544 | 2509 |
| 2545 MUST_USE_RESULT INLINE(AllocationResult AllocateRaw( | 2510 MUST_USE_RESULT INLINE(AllocationResult AllocateRaw( |
| 2546 int size_in_bytes, AllocationAlignment alignment)); | 2511 int size_in_bytes, AllocationAlignment alignment)); |
| 2547 | 2512 |
| 2548 MUST_USE_RESULT inline AllocationResult AllocateRawSynchronized( | 2513 MUST_USE_RESULT inline AllocationResult AllocateRawSynchronized( |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2645 // Update allocation info to match the current to-space page. | 2610 // Update allocation info to match the current to-space page. |
| 2646 void UpdateAllocationInfo(); | 2611 void UpdateAllocationInfo(); |
| 2647 | 2612 |
| 2648 base::Mutex mutex_; | 2613 base::Mutex mutex_; |
| 2649 | 2614 |
| 2650 // The semispaces. | 2615 // The semispaces. |
| 2651 SemiSpace to_space_; | 2616 SemiSpace to_space_; |
| 2652 SemiSpace from_space_; | 2617 SemiSpace from_space_; |
| 2653 base::VirtualMemory reservation_; | 2618 base::VirtualMemory reservation_; |
| 2654 | 2619 |
| 2655 // Allocation pointer and limit for normal allocation and allocation during | |
| 2656 // mark-compact collection. | |
| 2657 AllocationInfo allocation_info_; | |
| 2658 | |
| 2659 Address top_on_previous_step_; | 2620 Address top_on_previous_step_; |
| 2660 | 2621 |
| 2661 HistogramInfo* allocated_histogram_; | 2622 HistogramInfo* allocated_histogram_; |
| 2662 HistogramInfo* promoted_histogram_; | 2623 HistogramInfo* promoted_histogram_; |
| 2663 | 2624 |
| 2664 bool EnsureAllocation(int size_in_bytes, AllocationAlignment alignment); | 2625 bool EnsureAllocation(int size_in_bytes, AllocationAlignment alignment); |
| 2665 | 2626 |
| 2666 // If we are doing inline allocation in steps, this method performs the 'step' | 2627 // If we are doing inline allocation in steps, this method performs the 'step' |
| 2667 // operation. top is the memory address of the bump pointer at the last | 2628 // operation. top is the memory address of the bump pointer at the last |
| 2668 // inline allocation (i.e. it determines the numbers of bytes actually | 2629 // inline allocation (i.e. it determines the numbers of bytes actually |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2916 PageIterator old_iterator_; | 2877 PageIterator old_iterator_; |
| 2917 PageIterator code_iterator_; | 2878 PageIterator code_iterator_; |
| 2918 PageIterator map_iterator_; | 2879 PageIterator map_iterator_; |
| 2919 LargePageIterator lo_iterator_; | 2880 LargePageIterator lo_iterator_; |
| 2920 }; | 2881 }; |
| 2921 | 2882 |
| 2922 } // namespace internal | 2883 } // namespace internal |
| 2923 } // namespace v8 | 2884 } // namespace v8 |
| 2924 | 2885 |
| 2925 #endif // V8_HEAP_SPACES_H_ | 2886 #endif // V8_HEAP_SPACES_H_ |
| OLD | NEW |