Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(279)

Side by Side Diff: src/spaces.h

Issue 7124006: Two-page newspace. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/gc
Patch Set: Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 Address body() { return address() + kObjectStartOffset; } 364 Address body() { return address() + kObjectStartOffset; }
365 365
366 Address body_limit() { return address() + size(); } 366 Address body_limit() { return address() + size(); }
367 367
368 int body_size() { return size() - kObjectStartOffset; } 368 int body_size() { return size() - kObjectStartOffset; }
369 369
370 bool Contains(Address addr) { 370 bool Contains(Address addr) {
371 return addr >= body() && addr < address() + size(); 371 return addr >= body() && addr < address() + size();
372 } 372 }
373 373
374 // Checks whether addr can be a limit of addresses in this page.
375 // It's a limit if it's in the page, or if it's just after the
376 // last byte of the page.
377 bool ContainsLimit(Address addr) {
378 return addr >= body() && addr <= address() + size();
379 }
380
374 enum MemoryChunkFlags { 381 enum MemoryChunkFlags {
375 IS_EXECUTABLE, 382 IS_EXECUTABLE,
376 WAS_SWEPT_CONSERVATIVELY, 383 WAS_SWEPT_CONSERVATIVELY,
377 CONTAINS_ONLY_DATA, 384 CONTAINS_ONLY_DATA,
378 POINTERS_TO_HERE_ARE_INTERESTING, 385 POINTERS_TO_HERE_ARE_INTERESTING,
379 POINTERS_FROM_HERE_ARE_INTERESTING, 386 POINTERS_FROM_HERE_ARE_INTERESTING,
380 SCAN_ON_SCAVENGE, 387 SCAN_ON_SCAVENGE,
381 IN_FROM_SPACE, // Mutually exclusive with IN_TO_SPACE. 388 IN_FROM_SPACE, // Mutually exclusive with IN_TO_SPACE.
382 IN_TO_SPACE, // All pages in new space has one of these two set. 389 IN_TO_SPACE, // All pages in new space has one of these two set.
383 NUM_MEMORY_CHUNK_FLAGS 390 NUM_MEMORY_CHUNK_FLAGS
(...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
1322 accounting_stats_.ExpandSpace(size); 1329 accounting_stats_.ExpandSpace(size);
1323 } 1330 }
1324 1331
1325 // Releases half of unused pages. 1332 // Releases half of unused pages.
1326 void Shrink(); 1333 void Shrink();
1327 1334
1328 // Ensures that the capacity is at least 'capacity'. Returns false on failure. 1335 // Ensures that the capacity is at least 'capacity'. Returns false on failure.
1329 bool EnsureCapacity(int capacity); 1336 bool EnsureCapacity(int capacity);
1330 1337
1331 // The dummy page that anchors the linked list of pages. 1338 // The dummy page that anchors the linked list of pages.
1332 Page *anchor() { return &anchor_; } 1339 Page* anchor() { return &anchor_; }
1333 1340
1334 #ifdef ENABLE_HEAP_PROTECTION 1341 #ifdef ENABLE_HEAP_PROTECTION
1335 // Protect/unprotect the space by marking it read-only/writable. 1342 // Protect/unprotect the space by marking it read-only/writable.
1336 void Protect(); 1343 void Protect();
1337 void Unprotect(); 1344 void Unprotect();
1338 #endif 1345 #endif
1339 1346
1340 #ifdef DEBUG 1347 #ifdef DEBUG
1341 // Print meta info and objects in this space. 1348 // Print meta info and objects in this space.
1342 virtual void Print(); 1349 virtual void Print();
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 } 1509 }
1503 1510
1504 inline void set_prev_page(NewSpacePage* page) { 1511 inline void set_prev_page(NewSpacePage* page) {
1505 set_prev_chunk(page); 1512 set_prev_chunk(page);
1506 } 1513 }
1507 1514
1508 SemiSpace* semi_space() { 1515 SemiSpace* semi_space() {
1509 return reinterpret_cast<SemiSpace*>(owner()); 1516 return reinterpret_cast<SemiSpace*>(owner());
1510 } 1517 }
1511 1518
1519 bool is_anchor() { return !this->InNewSpace(); }
1520
1521 // Finds the NewSpacePage containg the given address.
1522 static inline NewSpacePage* FromAddress(Address address_in_page) {
1523 Address page_start =
1524 reinterpret_cast<Address>(reinterpret_cast<uintptr_t>(address_in_page) &
1525 ~Page::kPageAlignmentMask);
1526 NewSpacePage* page = reinterpret_cast<NewSpacePage*>(page_start);
1527 ASSERT(page->InNewSpace());
1528 return page;
1529 }
1530
1531 // Find the page for a limit address. A limit address is either an address
1532 // inside a page, or the address right after the last byte of a page.
1533 static inline NewSpacePage* FromLimit(Address address_limit) {
1534 return NewSpacePage::FromAddress(address_limit - 1);
1535 }
1536
1512 private: 1537 private:
1513 NewSpacePage(SemiSpace* owner) { 1538 // Create a NewSpacePage object that is only used as anchor
1539 // for the doubly-linked list of real pages.
1540 explicit NewSpacePage(SemiSpace* owner) {
1514 InitializeAsAnchor(owner); 1541 InitializeAsAnchor(owner);
1515 } 1542 }
1516 1543
1517 // Finds the NewSpacePage containg the given address.
1518 static NewSpacePage* FromAddress(Address address_in_page) {
1519 Address page_start =
1520 reinterpret_cast<Address>(reinterpret_cast<uintptr_t>(address_in_page) &
1521 ~Page::kPageAlignmentMask);
1522 return reinterpret_cast<NewSpacePage*>(page_start);
1523 }
1524
1525 static NewSpacePage* Initialize(Heap* heap, 1544 static NewSpacePage* Initialize(Heap* heap,
1526 Address start, 1545 Address start,
1527 SemiSpace* semi_space); 1546 SemiSpace* semi_space);
1528 1547
1529 // Intialize a fake NewSpacePage used as sentinel at the ends 1548 // Intialize a fake NewSpacePage used as sentinel at the ends
1530 // of a doubly-linked list of real NewSpacePages. 1549 // of a doubly-linked list of real NewSpacePages.
1531 // Only uses the prev/next links. 1550 // Only uses the prev/next links, and sets flags to not be in new-space.
1532 void InitializeAsAnchor(SemiSpace* owner); 1551 void InitializeAsAnchor(SemiSpace* owner);
1533 1552
1534 friend class SemiSpace; 1553 friend class SemiSpace;
1535 friend class SemiSpaceIterator; 1554 friend class SemiSpaceIterator;
1536 }; 1555 };
1537 1556
1538 1557
1539 // ----------------------------------------------------------------------------- 1558 // -----------------------------------------------------------------------------
1540 // SemiSpace in young generation 1559 // SemiSpace in young generation
1541 // 1560 //
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1573 // Grow the semispace to the new capacity. The new capacity 1592 // Grow the semispace to the new capacity. The new capacity
1574 // requested must be larger than the current capacity. 1593 // requested must be larger than the current capacity.
1575 bool GrowTo(int new_capacity); 1594 bool GrowTo(int new_capacity);
1576 1595
1577 // Shrinks the semispace to the new capacity. The new capacity 1596 // Shrinks the semispace to the new capacity. The new capacity
1578 // requested must be more than the amount of used memory in the 1597 // requested must be more than the amount of used memory in the
1579 // semispace and less than the current capacity. 1598 // semispace and less than the current capacity.
1580 bool ShrinkTo(int new_capacity); 1599 bool ShrinkTo(int new_capacity);
1581 1600
1582 // Returns the start address of the first page of the space. 1601 // Returns the start address of the first page of the space.
1583 Address low() { 1602 Address space_low() {
1584 ASSERT(anchor_.next_page() != &anchor_); 1603 ASSERT(anchor_.next_page() != &anchor_);
1585 return anchor_.next_page()->body(); 1604 return anchor_.next_page()->body();
1586 } 1605 }
1587 1606
1588 // Returns the start address of the current page of the space. 1607 // Returns the start address of the current page of the space.
1589 Address page_low() { 1608 Address page_low() {
1590 ASSERT(anchor_.next_page() != &anchor_); 1609 ASSERT(anchor_.next_page() != &anchor_);
1591 return current_page_->body(); 1610 return current_page_->body();
1592 } 1611 }
1593 1612
1594 // Returns one past the end address of the space. 1613 // Returns one past the end address of the space.
1595 Address high() { 1614 Address space_high() {
1596 // TODO(gc): Change when there is more than one page. 1615 return anchor_.prev_page()->body_limit();
1616 }
1617
1618 // Returns one past the end address of the current page of the space.
1619 Address page_high() {
1597 return current_page_->body_limit(); 1620 return current_page_->body_limit();
1598 } 1621 }
1599 1622
1623 bool AdvancePage() {
1624 NewSpacePage* next_page = current_page_->next_page();
1625 if (next_page == &anchor_) return false;
1626 current_page_ = next_page;
1627 return true;
1628 }
1629
1600 // Resets the space to using the first page. 1630 // Resets the space to using the first page.
1601 void Reset(); 1631 void Reset();
1602 1632
1603 // Age mark accessors. 1633 // Age mark accessors.
1604 Address age_mark() { return age_mark_; } 1634 Address age_mark() { return age_mark_; }
1605 void set_age_mark(Address mark) { age_mark_ = mark; } 1635 void set_age_mark(Address mark) { age_mark_ = mark; }
1606 1636
1607 // The offset of an address from the beginning of the space. 1637 // The offset of an address from the beginning of the space.
Erik Corry 2011/06/07 08:49:55 We can't delete this function?
Lasse Reichstein 2011/06/07 09:36:06 Whaddayaknow, we can! And there was much rejoycing
1608 int SpaceOffsetForAddress(Address addr) { 1638 int SpaceOffsetForAddress(Address addr) {
1609 return static_cast<int>(addr - low()); 1639 // TODO(gc): This generally won't make sense for paged new-space.
1640 return static_cast<int>(addr - space_low());
1610 } 1641 }
1611 1642
1612 // If we don't have these here then SemiSpace will be abstract. However 1643 // If we don't have these here then SemiSpace will be abstract. However
1613 // they should never be called. 1644 // they should never be called.
1614 virtual intptr_t Size() { 1645 virtual intptr_t Size() {
1615 UNREACHABLE(); 1646 UNREACHABLE();
1616 return 0; 1647 return 0;
1617 } 1648 }
1618 1649
1619 virtual bool ReserveSpace(int bytes) { 1650 virtual bool ReserveSpace(int bytes) {
1620 UNREACHABLE(); 1651 UNREACHABLE();
1621 return false; 1652 return false;
1622 } 1653 }
1623 1654
1624 bool is_committed() { return committed_; } 1655 bool is_committed() { return committed_; }
1625 bool Commit(); 1656 bool Commit();
1626 bool Uncommit(); 1657 bool Uncommit();
1627 1658
1628 NewSpacePage* first_page() { return NewSpacePage::FromAddress(start_); } 1659 NewSpacePage* first_page() { return anchor_.next_page(); }
1629 NewSpacePage* current_page() { return current_page_; } 1660 NewSpacePage* current_page() { return current_page_; }
1630 1661
1631 #ifdef ENABLE_HEAP_PROTECTION 1662 #ifdef ENABLE_HEAP_PROTECTION
1632 // Protect/unprotect the space by marking it read-only/writable. 1663 // Protect/unprotect the space by marking it read-only/writable.
1633 virtual void Protect() {} 1664 virtual void Protect() {}
1634 virtual void Unprotect() {} 1665 virtual void Unprotect() {}
1635 #endif 1666 #endif
1636 1667
1637 #ifdef DEBUG 1668 #ifdef DEBUG
1638 virtual void Print(); 1669 virtual void Print();
1639 virtual void Verify(); 1670 virtual void Verify();
1671 static void ValidateRange(Address from, Address to);
1640 #endif 1672 #endif
1641 1673
1642 // Returns the current capacity of the semi space. 1674 // Returns the current capacity of the semi space.
1643 int Capacity() { return capacity_; } 1675 int Capacity() { return capacity_; }
1644 1676
1645 // Returns the maximum capacity of the semi space. 1677 // Returns the maximum capacity of the semi space.
1646 int MaximumCapacity() { return maximum_capacity_; } 1678 int MaximumCapacity() { return maximum_capacity_; }
1647 1679
1648 // Returns the initial capacity of the semi space. 1680 // Returns the initial capacity of the semi space.
1649 int InitialCapacity() { return initial_capacity_; } 1681 int InitialCapacity() { return initial_capacity_; }
1650 1682
1651 SemiSpaceId id() { return id_; } 1683 SemiSpaceId id() { return id_; }
1652 1684
1653 static void Swap(SemiSpace* from, SemiSpace* to); 1685 static void Swap(SemiSpace* from, SemiSpace* to);
1654 1686
1655 private: 1687 private:
1656 // Flips the semispace between being from-space and to-space. 1688 // Flips the semispace between being from-space and to-space.
1657 // Copies the flags into the masked positions on all pages in the space. 1689 // Copies the flags into the masked positions on all pages in the space.
1658 void FlipPages(intptr_t flags, intptr_t flag_mask); 1690 void FlipPages(intptr_t flags, intptr_t flag_mask);
1659 1691
1692 NewSpacePage* anchor() { return &anchor_; }
1693
1660 // The current and maximum capacity of the space. 1694 // The current and maximum capacity of the space.
1661 int capacity_; 1695 int capacity_;
1662 int maximum_capacity_; 1696 int maximum_capacity_;
1663 int initial_capacity_; 1697 int initial_capacity_;
1664 1698
1665 // The start address of the space. 1699 // The start address of the space.
1666 Address start_; 1700 Address start_;
1667 // Used to govern object promotion during mark-compact collection. 1701 // Used to govern object promotion during mark-compact collection.
1668 Address age_mark_; 1702 Address age_mark_;
1669 1703
1670 // Masks and comparison values to test for containment in this semispace. 1704 // Masks and comparison values to test for containment in this semispace.
1671 uintptr_t address_mask_; 1705 uintptr_t address_mask_;
1672 uintptr_t object_mask_; 1706 uintptr_t object_mask_;
1673 uintptr_t object_expected_; 1707 uintptr_t object_expected_;
1674 1708
1675 bool committed_; 1709 bool committed_;
1676 SemiSpaceId id_; 1710 SemiSpaceId id_;
1677 1711
1678 NewSpacePage anchor_; 1712 NewSpacePage anchor_;
1679 NewSpacePage* current_page_; 1713 NewSpacePage* current_page_;
1680 1714
1715 friend class SemiSpaceIterator;
1716 friend class NewSpacePageIterator;
1681 public: 1717 public:
1682 TRACK_MEMORY("SemiSpace") 1718 TRACK_MEMORY("SemiSpace")
1683 }; 1719 };
1684 1720
1685 1721
1686 // A SemiSpaceIterator is an ObjectIterator that iterates over the active 1722 // A SemiSpaceIterator is an ObjectIterator that iterates over the active
1687 // semispace of the heap's new space. It iterates over the objects in the 1723 // semispace of the heap's new space. It iterates over the objects in the
1688 // semispace from a given start address (defaulting to the bottom of the 1724 // semispace from a given start address (defaulting to the bottom of the
1689 // semispace) to the top of the semispace. New objects allocated after the 1725 // semispace) to the top of the semispace. New objects allocated after the
1690 // iterator is created are not iterated. 1726 // iterator is created are not iterated.
1691 class SemiSpaceIterator : public ObjectIterator { 1727 class SemiSpaceIterator : public ObjectIterator {
1692 public: 1728 public:
1693 // Create an iterator over the objects in the given space. If no start 1729 // Create an iterator over the objects in the given space. If no start
1694 // address is given, the iterator starts from the bottom of the space. If 1730 // address is given, the iterator starts from the bottom of the space. If
1695 // no size function is given, the iterator calls Object::Size(). 1731 // no size function is given, the iterator calls Object::Size().
1732
1733 // Iterate over all of allocated to-space.
1696 explicit SemiSpaceIterator(NewSpace* space); 1734 explicit SemiSpaceIterator(NewSpace* space);
1735 // Iterate over all of allocated to-space, with a custome size function.
1697 SemiSpaceIterator(NewSpace* space, HeapObjectCallback size_func); 1736 SemiSpaceIterator(NewSpace* space, HeapObjectCallback size_func);
1737 // Iterate over part of allocated to-space, from start to the end
1738 // of allocation.
1698 SemiSpaceIterator(NewSpace* space, Address start); 1739 SemiSpaceIterator(NewSpace* space, Address start);
1740 // Iterate from one address to another in the same semi-space.
1741 SemiSpaceIterator(Address from, Address to);
1699 1742
1700 HeapObject* Next() { 1743 HeapObject* Next() {
1744 if (current_ == limit_) return NULL;
1701 if (current_ == current_page_limit_) { 1745 if (current_ == current_page_limit_) {
1702 // TODO(gc): Add something here when we have more than one page. 1746 NewSpacePage* page = NewSpacePage::FromAddress(current_ - 1);
1747 page = page->next_page();
1748 ASSERT(!page->is_anchor());
1749 current_ = page->body();
1750 if (current_ == limit_) return NULL;
1703 } 1751 }
1704 if (current_ == limit_) return NULL;
1705 1752
1706 HeapObject* object = HeapObject::FromAddress(current_); 1753 HeapObject* object = HeapObject::FromAddress(current_);
1707 int size = (size_func_ == NULL) ? object->Size() : size_func_(object); 1754 int size = (size_func_ == NULL) ? object->Size() : size_func_(object);
1708 1755
1709 current_ += size; 1756 current_ += size;
1710 return object; 1757 return object;
1711 } 1758 }
1712 1759
1713 // Implementation of the ObjectIterator functions. 1760 // Implementation of the ObjectIterator functions.
1714 virtual HeapObject* next_object() { return Next(); } 1761 virtual HeapObject* next_object() { return Next(); }
1715 1762
1716 private: 1763 private:
1717 void Initialize(NewSpace* space, 1764 void Initialize(Address start,
1718 Address start,
1719 Address end, 1765 Address end,
1720 HeapObjectCallback size_func); 1766 HeapObjectCallback size_func);
1721 1767
1722 // The semispace.
1723 SemiSpace* space_;
1724 // The current iteration point. 1768 // The current iteration point.
1725 Address current_; 1769 Address current_;
1726 // The end of the current page. 1770 // The end of the current page.
1727 Address current_page_limit_; 1771 Address current_page_limit_;
1728 // The end of iteration. 1772 // The end of iteration.
1729 Address limit_; 1773 Address limit_;
1730 // The callback function. 1774 // The callback function.
1731 HeapObjectCallback size_func_; 1775 HeapObjectCallback size_func_;
1732 }; 1776 };
1733 1777
1734 1778
1735 // ----------------------------------------------------------------------------- 1779 // -----------------------------------------------------------------------------
1780 // A PageIterator iterates the pages in a semi-space.
1781 class NewSpacePageIterator BASE_EMBEDDED {
1782 public:
1783 // Make an iterator that runs over all pages in the given semispace,
1784 // even those not used in allocation.
1785 explicit inline NewSpacePageIterator(SemiSpace* space);
1786 // Make iterator that iterates from the page containing start
1787 // to the page that contains limit in the same semispace.
1788 inline NewSpacePageIterator(Address start, Address limit);
1789
1790 inline bool has_next();
1791 inline NewSpacePage* next();
1792
1793 private:
1794 NewSpacePage* prev_page_; // Previous page returned.
1795 // Next page that will be returned. Cached here so that we can use this
1796 // iterator for operations that deallocate pages.
1797 NewSpacePage* next_page_;
1798 // Last page returned.
1799 NewSpacePage* last_page_;
1800 };
1801
1802
1803 // -----------------------------------------------------------------------------
1736 // The young generation space. 1804 // The young generation space.
1737 // 1805 //
1738 // The new space consists of a contiguous pair of semispaces. It simply 1806 // The new space consists of a contiguous pair of semispaces. It simply
1739 // forwards most functions to the appropriate semispace. 1807 // forwards most functions to the appropriate semispace.
1740 1808
1741 class NewSpace : public Space { 1809 class NewSpace : public Space {
1742 public: 1810 public:
1743 // Constructor. 1811 // Constructor.
1744 explicit NewSpace(Heap* heap) 1812 explicit NewSpace(Heap* heap)
1745 : Space(heap, NEW_SPACE, NOT_EXECUTABLE), 1813 : Space(heap, NEW_SPACE, NOT_EXECUTABLE),
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1811 ASSERT(to_space_.Capacity() == from_space_.Capacity()); 1879 ASSERT(to_space_.Capacity() == from_space_.Capacity());
1812 return to_space_.Capacity(); 1880 return to_space_.Capacity();
1813 } 1881 }
1814 1882
1815 // Return the total amount of memory committed for new space. 1883 // Return the total amount of memory committed for new space.
1816 intptr_t CommittedMemory() { 1884 intptr_t CommittedMemory() {
1817 if (from_space_.is_committed()) return 2 * Capacity(); 1885 if (from_space_.is_committed()) return 2 * Capacity();
1818 return Capacity(); 1886 return Capacity();
1819 } 1887 }
1820 1888
1821 // Return the available bytes without growing in the active semispace. 1889 // Return the available bytes without growing or switching page in the
1822 intptr_t Available() { return Capacity() - Size(); } 1890 // active semispace.
1891 intptr_t Available() {
1892 return allocation_info_.limit - allocation_info_.top;
1893 }
1823 1894
1824 // Return the maximum capacity of a semispace. 1895 // Return the maximum capacity of a semispace.
1825 int MaximumCapacity() { 1896 int MaximumCapacity() {
1826 ASSERT(to_space_.MaximumCapacity() == from_space_.MaximumCapacity()); 1897 ASSERT(to_space_.MaximumCapacity() == from_space_.MaximumCapacity());
1827 return to_space_.MaximumCapacity(); 1898 return to_space_.MaximumCapacity();
1828 } 1899 }
1829 1900
1830 // Returns the initial capacity of a semispace. 1901 // Returns the initial capacity of a semispace.
1831 int InitialCapacity() { 1902 int InitialCapacity() {
1832 ASSERT(to_space_.InitialCapacity() == from_space_.InitialCapacity()); 1903 ASSERT(to_space_.InitialCapacity() == from_space_.InitialCapacity());
1833 return to_space_.InitialCapacity(); 1904 return to_space_.InitialCapacity();
1834 } 1905 }
1835 1906
1836 // Return the address of the allocation pointer in the active semispace. 1907 // Return the address of the allocation pointer in the active semispace.
1837 Address top() { return allocation_info_.top; } 1908 Address top() { return allocation_info_.top; }
1838 // Return the address of the first object in the active semispace. 1909 // Return the address of the first object in the active semispace.
1839 Address bottom() { return to_space_.low(); } 1910 Address bottom() { return to_space_.space_low(); }
1840 1911
1841 // Get the age mark of the inactive semispace. 1912 // Get the age mark of the inactive semispace.
1842 Address age_mark() { return from_space_.age_mark(); } 1913 Address age_mark() { return from_space_.age_mark(); }
1843 // Set the age mark in the active semispace. 1914 // Set the age mark in the active semispace.
1844 void set_age_mark(Address mark) { to_space_.set_age_mark(mark); } 1915 void set_age_mark(Address mark) { to_space_.set_age_mark(mark); }
1845 1916
1846 // The start address of the space and a bit mask. Anding an address in the 1917 // The start address of the space and a bit mask. Anding an address in the
1847 // new space with the mask will result in the start address. 1918 // new space with the mask will result in the start address.
1848 Address start() { return start_; } 1919 Address start() { return start_; }
1849 uintptr_t mask() { return address_mask_; } 1920 uintptr_t mask() { return address_mask_; }
(...skipping 16 matching lines...) Expand all
1866 MUST_USE_RESULT MaybeObject* AllocateRaw(int size_in_bytes) { 1937 MUST_USE_RESULT MaybeObject* AllocateRaw(int size_in_bytes) {
1867 return AllocateRawInternal(size_in_bytes); 1938 return AllocateRawInternal(size_in_bytes);
1868 } 1939 }
1869 1940
1870 // Reset the allocation pointer to the beginning of the active semispace. 1941 // Reset the allocation pointer to the beginning of the active semispace.
1871 void ResetAllocationInfo(); 1942 void ResetAllocationInfo();
1872 1943
1873 void LowerInlineAllocationLimit(intptr_t step) { 1944 void LowerInlineAllocationLimit(intptr_t step) {
1874 inline_alloction_limit_step_ = step; 1945 inline_alloction_limit_step_ = step;
1875 if (step == 0) { 1946 if (step == 0) {
1876 allocation_info_.limit = to_space_.high(); 1947 allocation_info_.limit = to_space_.page_high();
1877 } else { 1948 } else {
1878 allocation_info_.limit = Min( 1949 allocation_info_.limit = Min(
1879 allocation_info_.top + inline_alloction_limit_step_, 1950 allocation_info_.top + inline_alloction_limit_step_,
1880 allocation_info_.limit); 1951 allocation_info_.limit);
1881 } 1952 }
1882 top_on_previous_step_ = allocation_info_.top; 1953 top_on_previous_step_ = allocation_info_.top;
1883 } 1954 }
1884 1955
1885 // Get the extent of the inactive semispace (for use as a marking stack). 1956 // Get the extent of the inactive semispace (for use as a marking stack,
1886 Address FromSpaceLow() { return from_space_.low(); } 1957 // or to zap it).
1887 Address FromSpaceHigh() { return from_space_.high(); } 1958 Address FromSpacePageLow() { return from_space_.page_low(); }
1959 Address FromSpaceLow() { return from_space_.space_low(); }
1960 Address FromSpaceHigh() { return from_space_.space_high(); }
1888 1961
1889 // Get the extent of the active semispace (to sweep newly copied objects 1962 // Get the extent of the active semispace (to sweep newly copied objects
1890 // during a scavenge collection). 1963 // during a scavenge collection).
1891 Address ToSpaceLow() { return to_space_.low(); } 1964 Address ToSpaceLow() { return to_space_.space_low(); }
Erik Corry 2011/06/07 08:49:55 This does not really make sense, at least for the
Lasse Reichstein 2011/06/07 09:36:06 Did it ever? The to_space_.high() value is the end
1892 Address ToSpaceHigh() { return to_space_.high(); } 1965 Address ToSpaceHigh() { return to_space_.space_high(); }
1893 1966
1894 // Offsets from the beginning of the semispaces. 1967 // Offsets from the beginning of the semispaces.
1895 int ToSpaceOffsetForAddress(Address a) { 1968 int ToSpaceOffsetForAddress(Address a) {
1896 return to_space_.SpaceOffsetForAddress(a); 1969 return to_space_.SpaceOffsetForAddress(a);
1897 } 1970 }
1898 int FromSpaceOffsetForAddress(Address a) { 1971 int FromSpaceOffsetForAddress(Address a) {
1899 return from_space_.SpaceOffsetForAddress(a); 1972 return from_space_.SpaceOffsetForAddress(a);
1900 } 1973 }
1901 1974
1902 inline bool ToSpaceContains(Address address) { 1975 inline bool ToSpaceContains(Address address) {
(...skipping 13 matching lines...) Expand all
1916 if (o->IsSmi()) return false; 1989 if (o->IsSmi()) return false;
1917 Address address = reinterpret_cast<Address>(o); 1990 Address address = reinterpret_cast<Address>(o);
1918 return ToSpaceContains(address); 1991 return ToSpaceContains(address);
1919 } 1992 }
1920 1993
1921 bool FromSpaceContains(Object* o) { 1994 bool FromSpaceContains(Object* o) {
1922 if (o->IsSmi()) return false; 1995 if (o->IsSmi()) return false;
1923 Address address = reinterpret_cast<Address>(o); 1996 Address address = reinterpret_cast<Address>(o);
1924 return FromSpaceContains(address); 1997 return FromSpaceContains(address);
1925 } 1998 }
1926 1999
Erik Corry 2011/06/07 08:49:55 Comment on what the return value means.
Lasse Reichstein 2011/06/07 09:36:06 Done.
2000 bool AddFreshPage();
2001
1927 virtual bool ReserveSpace(int bytes); 2002 virtual bool ReserveSpace(int bytes);
1928 2003
1929 // Resizes a sequential string which must be the most recent thing that was 2004 // Resizes a sequential string which must be the most recent thing that was
1930 // allocated in new space. 2005 // allocated in new space.
1931 template <typename StringType> 2006 template <typename StringType>
1932 inline void ShrinkStringAtAllocationBoundary(String* string, int len); 2007 inline void ShrinkStringAtAllocationBoundary(String* string, int len);
1933 2008
1934 #ifdef ENABLE_HEAP_PROTECTION 2009 #ifdef ENABLE_HEAP_PROTECTION
1935 // Protect/unprotect the space by marking it read-only/writable. 2010 // Protect/unprotect the space by marking it read-only/writable.
1936 virtual void Protect(); 2011 virtual void Protect();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 2051
1977 NewSpacePage* ActivePage() { 2052 NewSpacePage* ActivePage() {
1978 return to_space_.current_page(); 2053 return to_space_.current_page();
1979 } 2054 }
1980 2055
1981 NewSpacePage* InactivePage() { 2056 NewSpacePage* InactivePage() {
1982 return from_space_.current_page(); 2057 return from_space_.current_page();
1983 } 2058 }
1984 2059
1985 private: 2060 private:
2061 // Update allocation info to match the current to-space page.
2062 void UpdateAllocationInfo();
2063
1986 Address chunk_base_; 2064 Address chunk_base_;
1987 uintptr_t chunk_size_; 2065 uintptr_t chunk_size_;
1988 2066
1989 // The semispaces. 2067 // The semispaces.
1990 SemiSpace to_space_; 2068 SemiSpace to_space_;
1991 SemiSpace from_space_; 2069 SemiSpace from_space_;
1992 2070
1993 // Start address and bit mask for containment testing. 2071 // Start address and bit mask for containment testing.
1994 Address start_; 2072 Address start_;
1995 uintptr_t address_mask_; 2073 uintptr_t address_mask_;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2048 virtual void PrepareForMarkCompact(bool will_compact); 2126 virtual void PrepareForMarkCompact(bool will_compact);
2049 2127
2050 public: 2128 public:
2051 TRACK_MEMORY("OldSpace") 2129 TRACK_MEMORY("OldSpace")
2052 }; 2130 };
2053 2131
2054 2132
2055 // For contiguous spaces, top should be in the space (or at the end) and limit 2133 // For contiguous spaces, top should be in the space (or at the end) and limit
2056 // should be the end of the space. 2134 // should be the end of the space.
2057 #define ASSERT_SEMISPACE_ALLOCATION_INFO(info, space) \ 2135 #define ASSERT_SEMISPACE_ALLOCATION_INFO(info, space) \
2058 ASSERT((space).low() <= (info).top \ 2136 ASSERT((space).page_low() <= (info).top \
2059 && (info).top <= (space).high() \ 2137 && (info).top <= (space).page_high() \
2060 && (info).limit <= (space).high()) 2138 && (info).limit <= (space).page_high())
2061 2139
2062 2140
2063 // ----------------------------------------------------------------------------- 2141 // -----------------------------------------------------------------------------
2064 // Old space for objects of a fixed size 2142 // Old space for objects of a fixed size
2065 2143
2066 class FixedSpace : public PagedSpace { 2144 class FixedSpace : public PagedSpace {
2067 public: 2145 public:
2068 FixedSpace(Heap* heap, 2146 FixedSpace(Heap* heap,
2069 intptr_t max_capacity, 2147 intptr_t max_capacity,
2070 AllocationSpace id, 2148 AllocationSpace id,
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
2371 } 2449 }
2372 // Must be small, since an iteration is used for lookup. 2450 // Must be small, since an iteration is used for lookup.
2373 static const int kMaxComments = 64; 2451 static const int kMaxComments = 64;
2374 }; 2452 };
2375 #endif 2453 #endif
2376 2454
2377 2455
2378 } } // namespace v8::internal 2456 } } // namespace v8::internal
2379 2457
2380 #endif // V8_SPACES_H_ 2458 #endif // V8_SPACES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698