| 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 #include "src/heap/spaces.h" | 5 #include "src/heap/spaces.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 : isolate_(isolate), | 287 : isolate_(isolate), |
| 288 code_range_(nullptr), | 288 code_range_(nullptr), |
| 289 capacity_(0), | 289 capacity_(0), |
| 290 capacity_executable_(0), | 290 capacity_executable_(0), |
| 291 size_(0), | 291 size_(0), |
| 292 size_executable_(0), | 292 size_executable_(0), |
| 293 lowest_ever_allocated_(reinterpret_cast<void*>(-1)), | 293 lowest_ever_allocated_(reinterpret_cast<void*>(-1)), |
| 294 highest_ever_allocated_(reinterpret_cast<void*>(0)), | 294 highest_ever_allocated_(reinterpret_cast<void*>(0)), |
| 295 unmapper_(this) {} | 295 unmapper_(this) {} |
| 296 | 296 |
| 297 bool MemoryAllocator::SetUp(intptr_t capacity, intptr_t capacity_executable, | 297 bool MemoryAllocator::SetUp(size_t capacity, size_t capacity_executable, |
| 298 intptr_t code_range_size) { | 298 size_t code_range_size) { |
| 299 capacity_ = RoundUp(capacity, Page::kPageSize); | 299 capacity_ = RoundUp(capacity, Page::kPageSize); |
| 300 capacity_executable_ = RoundUp(capacity_executable, Page::kPageSize); | 300 capacity_executable_ = RoundUp(capacity_executable, Page::kPageSize); |
| 301 DCHECK_GE(capacity_, capacity_executable_); | 301 DCHECK_GE(capacity_, capacity_executable_); |
| 302 | 302 |
| 303 size_ = 0; | 303 size_ = 0; |
| 304 size_executable_ = 0; | 304 size_executable_ = 0; |
| 305 | 305 |
| 306 code_range_ = new CodeRange(isolate_); | 306 code_range_ = new CodeRange(isolate_); |
| 307 if (!code_range_->SetUp(static_cast<size_t>(code_range_size))) return false; | 307 if (!code_range_->SetUp(code_range_size)) return false; |
| 308 | 308 |
| 309 return true; | 309 return true; |
| 310 } | 310 } |
| 311 | 311 |
| 312 | 312 |
| 313 void MemoryAllocator::TearDown() { | 313 void MemoryAllocator::TearDown() { |
| 314 unmapper()->TearDown(); | 314 unmapper()->TearDown(); |
| 315 | 315 |
| 316 // Check that spaces were torn down before MemoryAllocator. | 316 // Check that spaces were torn down before MemoryAllocator. |
| 317 DCHECK_EQ(size_.Value(), 0u); | 317 DCHECK_EQ(size_.Value(), 0u); |
| (...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1473 } | 1473 } |
| 1474 CHECK_LE(black_size, page->LiveBytes()); | 1474 CHECK_LE(black_size, page->LiveBytes()); |
| 1475 } | 1475 } |
| 1476 CHECK(allocation_pointer_found_in_space); | 1476 CHECK(allocation_pointer_found_in_space); |
| 1477 } | 1477 } |
| 1478 #endif // VERIFY_HEAP | 1478 #endif // VERIFY_HEAP |
| 1479 | 1479 |
| 1480 // ----------------------------------------------------------------------------- | 1480 // ----------------------------------------------------------------------------- |
| 1481 // NewSpace implementation | 1481 // NewSpace implementation |
| 1482 | 1482 |
| 1483 bool NewSpace::SetUp(int initial_semispace_capacity, | 1483 bool NewSpace::SetUp(size_t initial_semispace_capacity, |
| 1484 int maximum_semispace_capacity) { | 1484 size_t maximum_semispace_capacity) { |
| 1485 DCHECK(initial_semispace_capacity <= maximum_semispace_capacity); | 1485 DCHECK(initial_semispace_capacity <= maximum_semispace_capacity); |
| 1486 DCHECK(base::bits::IsPowerOfTwo32(maximum_semispace_capacity)); | 1486 DCHECK(base::bits::IsPowerOfTwo32( |
| 1487 static_cast<uint32_t>(maximum_semispace_capacity))); |
| 1487 | 1488 |
| 1488 to_space_.SetUp(initial_semispace_capacity, maximum_semispace_capacity); | 1489 to_space_.SetUp(initial_semispace_capacity, maximum_semispace_capacity); |
| 1489 from_space_.SetUp(initial_semispace_capacity, maximum_semispace_capacity); | 1490 from_space_.SetUp(initial_semispace_capacity, maximum_semispace_capacity); |
| 1490 if (!to_space_.Commit()) { | 1491 if (!to_space_.Commit()) { |
| 1491 return false; | 1492 return false; |
| 1492 } | 1493 } |
| 1493 DCHECK(!from_space_.is_committed()); // No need to use memory yet. | 1494 DCHECK(!from_space_.is_committed()); // No need to use memory yet. |
| 1494 ResetAllocationInfo(); | 1495 ResetAllocationInfo(); |
| 1495 | 1496 |
| 1496 // Allocate and set up the histogram arrays if necessary. | 1497 // Allocate and set up the histogram arrays if necessary. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1521 to_space_.TearDown(); | 1522 to_space_.TearDown(); |
| 1522 from_space_.TearDown(); | 1523 from_space_.TearDown(); |
| 1523 } | 1524 } |
| 1524 | 1525 |
| 1525 void NewSpace::Flip() { SemiSpace::Swap(&from_space_, &to_space_); } | 1526 void NewSpace::Flip() { SemiSpace::Swap(&from_space_, &to_space_); } |
| 1526 | 1527 |
| 1527 | 1528 |
| 1528 void NewSpace::Grow() { | 1529 void NewSpace::Grow() { |
| 1529 // Double the semispace size but only up to maximum capacity. | 1530 // Double the semispace size but only up to maximum capacity. |
| 1530 DCHECK(TotalCapacity() < MaximumCapacity()); | 1531 DCHECK(TotalCapacity() < MaximumCapacity()); |
| 1531 int new_capacity = | 1532 size_t new_capacity = |
| 1532 Min(MaximumCapacity(), | 1533 Min(MaximumCapacity(), |
| 1533 FLAG_semi_space_growth_factor * static_cast<int>(TotalCapacity())); | 1534 static_cast<size_t>(FLAG_semi_space_growth_factor) * TotalCapacity()); |
| 1534 if (to_space_.GrowTo(new_capacity)) { | 1535 if (to_space_.GrowTo(new_capacity)) { |
| 1535 // Only grow from space if we managed to grow to-space. | 1536 // Only grow from space if we managed to grow to-space. |
| 1536 if (!from_space_.GrowTo(new_capacity)) { | 1537 if (!from_space_.GrowTo(new_capacity)) { |
| 1537 // If we managed to grow to-space but couldn't grow from-space, | 1538 // If we managed to grow to-space but couldn't grow from-space, |
| 1538 // attempt to shrink to-space. | 1539 // attempt to shrink to-space. |
| 1539 if (!to_space_.ShrinkTo(from_space_.current_capacity())) { | 1540 if (!to_space_.ShrinkTo(from_space_.current_capacity())) { |
| 1540 // We are in an inconsistent state because we could not | 1541 // We are in an inconsistent state because we could not |
| 1541 // commit/uncommit memory from new space. | 1542 // commit/uncommit memory from new space. |
| 1542 CHECK(false); | 1543 CHECK(false); |
| 1543 } | 1544 } |
| 1544 } | 1545 } |
| 1545 } | 1546 } |
| 1546 DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); | 1547 DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); |
| 1547 } | 1548 } |
| 1548 | 1549 |
| 1549 | 1550 |
| 1550 void NewSpace::Shrink() { | 1551 void NewSpace::Shrink() { |
| 1551 int new_capacity = Max(InitialTotalCapacity(), 2 * static_cast<int>(Size())); | 1552 size_t new_capacity = Max(InitialTotalCapacity(), 2 * Size()); |
| 1552 int rounded_new_capacity = RoundUp(new_capacity, Page::kPageSize); | 1553 size_t rounded_new_capacity = RoundUp(new_capacity, Page::kPageSize); |
| 1553 if (rounded_new_capacity < TotalCapacity() && | 1554 if (rounded_new_capacity < TotalCapacity() && |
| 1554 to_space_.ShrinkTo(rounded_new_capacity)) { | 1555 to_space_.ShrinkTo(rounded_new_capacity)) { |
| 1555 // Only shrink from-space if we managed to shrink to-space. | 1556 // Only shrink from-space if we managed to shrink to-space. |
| 1556 from_space_.Reset(); | 1557 from_space_.Reset(); |
| 1557 if (!from_space_.ShrinkTo(rounded_new_capacity)) { | 1558 if (!from_space_.ShrinkTo(rounded_new_capacity)) { |
| 1558 // If we managed to shrink to-space but couldn't shrink from | 1559 // If we managed to shrink to-space but couldn't shrink from |
| 1559 // space, attempt to grow to-space again. | 1560 // space, attempt to grow to-space again. |
| 1560 if (!to_space_.GrowTo(from_space_.current_capacity())) { | 1561 if (!to_space_.GrowTo(from_space_.current_capacity())) { |
| 1561 // We are in an inconsistent state because we could not | 1562 // We are in an inconsistent state because we could not |
| 1562 // commit/uncommit memory from new space. | 1563 // commit/uncommit memory from new space. |
| 1563 CHECK(false); | 1564 CHECK(false); |
| 1564 } | 1565 } |
| 1565 } | 1566 } |
| 1566 } | 1567 } |
| 1567 DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); | 1568 DCHECK_SEMISPACE_ALLOCATION_INFO(allocation_info_, to_space_); |
| 1568 } | 1569 } |
| 1569 | 1570 |
| 1570 bool NewSpace::Rebalance() { | 1571 bool NewSpace::Rebalance() { |
| 1571 CHECK(heap()->promotion_queue()->is_empty()); | 1572 CHECK(heap()->promotion_queue()->is_empty()); |
| 1572 // Order here is important to make use of the page pool. | 1573 // Order here is important to make use of the page pool. |
| 1573 return to_space_.EnsureCurrentCapacity() && | 1574 return to_space_.EnsureCurrentCapacity() && |
| 1574 from_space_.EnsureCurrentCapacity(); | 1575 from_space_.EnsureCurrentCapacity(); |
| 1575 } | 1576 } |
| 1576 | 1577 |
| 1577 bool SemiSpace::EnsureCurrentCapacity() { | 1578 bool SemiSpace::EnsureCurrentCapacity() { |
| 1578 if (is_committed()) { | 1579 if (is_committed()) { |
| 1579 const int expected_pages = current_capacity_ / Page::kPageSize; | 1580 const int expected_pages = |
| 1581 static_cast<int>(current_capacity_ / Page::kPageSize); |
| 1580 int actual_pages = 0; | 1582 int actual_pages = 0; |
| 1581 Page* current_page = anchor()->next_page(); | 1583 Page* current_page = anchor()->next_page(); |
| 1582 while (current_page != anchor()) { | 1584 while (current_page != anchor()) { |
| 1583 actual_pages++; | 1585 actual_pages++; |
| 1584 current_page = current_page->next_page(); | 1586 current_page = current_page->next_page(); |
| 1585 if (actual_pages > expected_pages) { | 1587 if (actual_pages > expected_pages) { |
| 1586 Page* to_remove = current_page->prev_page(); | 1588 Page* to_remove = current_page->prev_page(); |
| 1587 // Make sure we don't overtake the actual top pointer. | 1589 // Make sure we don't overtake the actual top pointer. |
| 1588 CHECK_NE(to_remove, current_page_); | 1590 CHECK_NE(to_remove, current_page_); |
| 1589 to_remove->Unlink(); | 1591 to_remove->Unlink(); |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1870 CHECK_EQ(from_space_.id(), kFromSpace); | 1872 CHECK_EQ(from_space_.id(), kFromSpace); |
| 1871 CHECK_EQ(to_space_.id(), kToSpace); | 1873 CHECK_EQ(to_space_.id(), kToSpace); |
| 1872 from_space_.Verify(); | 1874 from_space_.Verify(); |
| 1873 to_space_.Verify(); | 1875 to_space_.Verify(); |
| 1874 } | 1876 } |
| 1875 #endif | 1877 #endif |
| 1876 | 1878 |
| 1877 // ----------------------------------------------------------------------------- | 1879 // ----------------------------------------------------------------------------- |
| 1878 // SemiSpace implementation | 1880 // SemiSpace implementation |
| 1879 | 1881 |
| 1880 void SemiSpace::SetUp(int initial_capacity, int maximum_capacity) { | 1882 void SemiSpace::SetUp(size_t initial_capacity, size_t maximum_capacity) { |
| 1881 DCHECK_GE(maximum_capacity, Page::kPageSize); | 1883 DCHECK_GE(maximum_capacity, static_cast<size_t>(Page::kPageSize)); |
| 1882 minimum_capacity_ = RoundDown(initial_capacity, Page::kPageSize); | 1884 minimum_capacity_ = RoundDown(initial_capacity, Page::kPageSize); |
| 1883 current_capacity_ = minimum_capacity_; | 1885 current_capacity_ = minimum_capacity_; |
| 1884 maximum_capacity_ = RoundDown(maximum_capacity, Page::kPageSize); | 1886 maximum_capacity_ = RoundDown(maximum_capacity, Page::kPageSize); |
| 1885 committed_ = false; | 1887 committed_ = false; |
| 1886 } | 1888 } |
| 1887 | 1889 |
| 1888 | 1890 |
| 1889 void SemiSpace::TearDown() { | 1891 void SemiSpace::TearDown() { |
| 1890 // Properly uncommit memory to keep the allocator counters in sync. | 1892 // Properly uncommit memory to keep the allocator counters in sync. |
| 1891 if (is_committed()) { | 1893 if (is_committed()) { |
| 1892 for (Page* p : *this) { | 1894 for (Page* p : *this) { |
| 1893 ArrayBufferTracker::FreeAll(p); | 1895 ArrayBufferTracker::FreeAll(p); |
| 1894 } | 1896 } |
| 1895 Uncommit(); | 1897 Uncommit(); |
| 1896 } | 1898 } |
| 1897 current_capacity_ = maximum_capacity_ = 0; | 1899 current_capacity_ = maximum_capacity_ = 0; |
| 1898 } | 1900 } |
| 1899 | 1901 |
| 1900 | 1902 |
| 1901 bool SemiSpace::Commit() { | 1903 bool SemiSpace::Commit() { |
| 1902 DCHECK(!is_committed()); | 1904 DCHECK(!is_committed()); |
| 1903 Page* current = anchor(); | 1905 Page* current = anchor(); |
| 1904 const int num_pages = current_capacity_ / Page::kPageSize; | 1906 const int num_pages = static_cast<int>(current_capacity_ / Page::kPageSize); |
| 1905 for (int pages_added = 0; pages_added < num_pages; pages_added++) { | 1907 for (int pages_added = 0; pages_added < num_pages; pages_added++) { |
| 1906 Page* new_page = | 1908 Page* new_page = |
| 1907 heap()->memory_allocator()->AllocatePage<MemoryAllocator::kPooled>( | 1909 heap()->memory_allocator()->AllocatePage<MemoryAllocator::kPooled>( |
| 1908 Page::kAllocatableMemory, this, executable()); | 1910 Page::kAllocatableMemory, this, executable()); |
| 1909 if (new_page == nullptr) { | 1911 if (new_page == nullptr) { |
| 1910 RewindPages(current, pages_added); | 1912 RewindPages(current, pages_added); |
| 1911 return false; | 1913 return false; |
| 1912 } | 1914 } |
| 1913 new_page->InsertAfter(current); | 1915 new_page->InsertAfter(current); |
| 1914 current = new_page; | 1916 current = new_page; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1940 | 1942 |
| 1941 size_t SemiSpace::CommittedPhysicalMemory() { | 1943 size_t SemiSpace::CommittedPhysicalMemory() { |
| 1942 if (!is_committed()) return 0; | 1944 if (!is_committed()) return 0; |
| 1943 size_t size = 0; | 1945 size_t size = 0; |
| 1944 for (Page* p : *this) { | 1946 for (Page* p : *this) { |
| 1945 size += p->CommittedPhysicalMemory(); | 1947 size += p->CommittedPhysicalMemory(); |
| 1946 } | 1948 } |
| 1947 return size; | 1949 return size; |
| 1948 } | 1950 } |
| 1949 | 1951 |
| 1950 | 1952 bool SemiSpace::GrowTo(size_t new_capacity) { |
| 1951 bool SemiSpace::GrowTo(int new_capacity) { | |
| 1952 if (!is_committed()) { | 1953 if (!is_committed()) { |
| 1953 if (!Commit()) return false; | 1954 if (!Commit()) return false; |
| 1954 } | 1955 } |
| 1955 DCHECK_EQ(new_capacity & Page::kPageAlignmentMask, 0); | 1956 DCHECK_EQ(new_capacity & Page::kPageAlignmentMask, 0u); |
| 1956 DCHECK_LE(new_capacity, maximum_capacity_); | 1957 DCHECK_LE(new_capacity, maximum_capacity_); |
| 1957 DCHECK_GT(new_capacity, current_capacity_); | 1958 DCHECK_GT(new_capacity, current_capacity_); |
| 1958 const int delta = new_capacity - current_capacity_; | 1959 const size_t delta = new_capacity - current_capacity_; |
| 1959 DCHECK(IsAligned(delta, base::OS::AllocateAlignment())); | 1960 DCHECK(IsAligned(delta, base::OS::AllocateAlignment())); |
| 1960 const int delta_pages = delta / Page::kPageSize; | 1961 const int delta_pages = static_cast<int>(delta / Page::kPageSize); |
| 1961 Page* last_page = anchor()->prev_page(); | 1962 Page* last_page = anchor()->prev_page(); |
| 1962 DCHECK_NE(last_page, anchor()); | 1963 DCHECK_NE(last_page, anchor()); |
| 1963 for (int pages_added = 0; pages_added < delta_pages; pages_added++) { | 1964 for (int pages_added = 0; pages_added < delta_pages; pages_added++) { |
| 1964 Page* new_page = | 1965 Page* new_page = |
| 1965 heap()->memory_allocator()->AllocatePage<MemoryAllocator::kPooled>( | 1966 heap()->memory_allocator()->AllocatePage<MemoryAllocator::kPooled>( |
| 1966 Page::kAllocatableMemory, this, executable()); | 1967 Page::kAllocatableMemory, this, executable()); |
| 1967 if (new_page == nullptr) { | 1968 if (new_page == nullptr) { |
| 1968 RewindPages(last_page, pages_added); | 1969 RewindPages(last_page, pages_added); |
| 1969 return false; | 1970 return false; |
| 1970 } | 1971 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1985 while (num_pages > 0) { | 1986 while (num_pages > 0) { |
| 1986 DCHECK_NE(last_page, anchor()); | 1987 DCHECK_NE(last_page, anchor()); |
| 1987 new_last_page = last_page->prev_page(); | 1988 new_last_page = last_page->prev_page(); |
| 1988 last_page->prev_page()->set_next_page(last_page->next_page()); | 1989 last_page->prev_page()->set_next_page(last_page->next_page()); |
| 1989 last_page->next_page()->set_prev_page(last_page->prev_page()); | 1990 last_page->next_page()->set_prev_page(last_page->prev_page()); |
| 1990 last_page = new_last_page; | 1991 last_page = new_last_page; |
| 1991 num_pages--; | 1992 num_pages--; |
| 1992 } | 1993 } |
| 1993 } | 1994 } |
| 1994 | 1995 |
| 1995 bool SemiSpace::ShrinkTo(int new_capacity) { | 1996 bool SemiSpace::ShrinkTo(size_t new_capacity) { |
| 1996 DCHECK_EQ(new_capacity & Page::kPageAlignmentMask, 0); | 1997 DCHECK_EQ(new_capacity & Page::kPageAlignmentMask, 0u); |
| 1997 DCHECK_GE(new_capacity, minimum_capacity_); | 1998 DCHECK_GE(new_capacity, minimum_capacity_); |
| 1998 DCHECK_LT(new_capacity, current_capacity_); | 1999 DCHECK_LT(new_capacity, current_capacity_); |
| 1999 if (is_committed()) { | 2000 if (is_committed()) { |
| 2000 const int delta = current_capacity_ - new_capacity; | 2001 const size_t delta = current_capacity_ - new_capacity; |
| 2001 DCHECK(IsAligned(delta, base::OS::AllocateAlignment())); | 2002 DCHECK(IsAligned(delta, base::OS::AllocateAlignment())); |
| 2002 int delta_pages = delta / Page::kPageSize; | 2003 int delta_pages = static_cast<int>(delta / Page::kPageSize); |
| 2003 Page* new_last_page; | 2004 Page* new_last_page; |
| 2004 Page* last_page; | 2005 Page* last_page; |
| 2005 while (delta_pages > 0) { | 2006 while (delta_pages > 0) { |
| 2006 last_page = anchor()->prev_page(); | 2007 last_page = anchor()->prev_page(); |
| 2007 new_last_page = last_page->prev_page(); | 2008 new_last_page = last_page->prev_page(); |
| 2008 new_last_page->set_next_page(anchor()); | 2009 new_last_page->set_next_page(anchor()); |
| 2009 anchor()->set_prev_page(new_last_page); | 2010 anchor()->set_prev_page(new_last_page); |
| 2010 heap()->memory_allocator()->Free<MemoryAllocator::kPooledAndQueue>( | 2011 heap()->memory_allocator()->Free<MemoryAllocator::kPooledAndQueue>( |
| 2011 last_page); | 2012 last_page); |
| 2012 delta_pages--; | 2013 delta_pages--; |
| (...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2764 | 2765 |
| 2765 void PagedSpace::PrepareForMarkCompact() { | 2766 void PagedSpace::PrepareForMarkCompact() { |
| 2766 // We don't have a linear allocation area while sweeping. It will be restored | 2767 // We don't have a linear allocation area while sweeping. It will be restored |
| 2767 // on the first allocation after the sweep. | 2768 // on the first allocation after the sweep. |
| 2768 EmptyAllocationInfo(); | 2769 EmptyAllocationInfo(); |
| 2769 | 2770 |
| 2770 // Clear the free list before a full GC---it will be rebuilt afterward. | 2771 // Clear the free list before a full GC---it will be rebuilt afterward. |
| 2771 free_list_.Reset(); | 2772 free_list_.Reset(); |
| 2772 } | 2773 } |
| 2773 | 2774 |
| 2774 | 2775 size_t PagedSpace::SizeOfObjects() { |
| 2775 intptr_t PagedSpace::SizeOfObjects() { | |
| 2776 const intptr_t size = Size() - (limit() - top()); | |
| 2777 CHECK_GE(limit(), top()); | 2776 CHECK_GE(limit(), top()); |
| 2778 CHECK_GE(size, 0); | 2777 DCHECK_GE(Size(), static_cast<size_t>(limit() - top())); |
| 2779 USE(size); | 2778 return Size() - (limit() - top()); |
| 2780 return size; | |
| 2781 } | 2779 } |
| 2782 | 2780 |
| 2783 | 2781 |
| 2784 // After we have booted, we have created a map which represents free space | 2782 // After we have booted, we have created a map which represents free space |
| 2785 // on the heap. If there was already a free list then the elements on it | 2783 // on the heap. If there was already a free list then the elements on it |
| 2786 // were created with the wrong FreeSpaceMap (normally NULL), so we need to | 2784 // were created with the wrong FreeSpaceMap (normally NULL), so we need to |
| 2787 // fix them. | 2785 // fix them. |
| 2788 void PagedSpace::RepairFreeListsAfterDeserialization() { | 2786 void PagedSpace::RepairFreeListsAfterDeserialization() { |
| 2789 free_list_.RepairLists(heap()); | 2787 free_list_.RepairLists(heap()); |
| 2790 // Each page may have a small free space that is not tracked by a free list. | 2788 // Each page may have a small free space that is not tracked by a free list. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2817 HeapObject* CompactionSpace::SweepAndRetryAllocation(int size_in_bytes) { | 2815 HeapObject* CompactionSpace::SweepAndRetryAllocation(int size_in_bytes) { |
| 2818 MarkCompactCollector* collector = heap()->mark_compact_collector(); | 2816 MarkCompactCollector* collector = heap()->mark_compact_collector(); |
| 2819 if (collector->sweeping_in_progress()) { | 2817 if (collector->sweeping_in_progress()) { |
| 2820 collector->SweepAndRefill(this); | 2818 collector->SweepAndRefill(this); |
| 2821 return free_list_.Allocate(size_in_bytes); | 2819 return free_list_.Allocate(size_in_bytes); |
| 2822 } | 2820 } |
| 2823 return nullptr; | 2821 return nullptr; |
| 2824 } | 2822 } |
| 2825 | 2823 |
| 2826 HeapObject* PagedSpace::SlowAllocateRaw(int size_in_bytes) { | 2824 HeapObject* PagedSpace::SlowAllocateRaw(int size_in_bytes) { |
| 2825 DCHECK_GE(size_in_bytes, 0); |
| 2827 const int kMaxPagesToSweep = 1; | 2826 const int kMaxPagesToSweep = 1; |
| 2828 | 2827 |
| 2829 // Allocation in this space has failed. | 2828 // Allocation in this space has failed. |
| 2830 | 2829 |
| 2831 MarkCompactCollector* collector = heap()->mark_compact_collector(); | 2830 MarkCompactCollector* collector = heap()->mark_compact_collector(); |
| 2832 // Sweeping is still in progress. | 2831 // Sweeping is still in progress. |
| 2833 if (collector->sweeping_in_progress()) { | 2832 if (collector->sweeping_in_progress()) { |
| 2834 // First try to refill the free-list, concurrent sweeper threads | 2833 // First try to refill the free-list, concurrent sweeper threads |
| 2835 // may have freed some objects in the meantime. | 2834 // may have freed some objects in the meantime. |
| 2836 RefillFreeList(); | 2835 RefillFreeList(); |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3232 object->ShortPrint(); | 3231 object->ShortPrint(); |
| 3233 PrintF("\n"); | 3232 PrintF("\n"); |
| 3234 } | 3233 } |
| 3235 printf(" --------------------------------------\n"); | 3234 printf(" --------------------------------------\n"); |
| 3236 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3235 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3237 } | 3236 } |
| 3238 | 3237 |
| 3239 #endif // DEBUG | 3238 #endif // DEBUG |
| 3240 } // namespace internal | 3239 } // namespace internal |
| 3241 } // namespace v8 | 3240 } // namespace v8 |
| OLD | NEW |