| 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/atomic-utils.h" | 9 #include "src/atomic-utils.h" |
| 10 #include "src/base/atomicops.h" | 10 #include "src/base/atomicops.h" |
| (...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1413 | 1413 |
| 1414 private: | 1414 private: |
| 1415 // Current allocation top. | 1415 // Current allocation top. |
| 1416 Address top_; | 1416 Address top_; |
| 1417 // Current allocation limit. | 1417 // Current allocation limit. |
| 1418 Address limit_; | 1418 Address limit_; |
| 1419 }; | 1419 }; |
| 1420 | 1420 |
| 1421 | 1421 |
| 1422 // An abstraction of the accounting statistics of a page-structured space. | 1422 // An abstraction of the accounting statistics of a page-structured space. |
| 1423 // The 'capacity' of a space is the number of object-area bytes (i.e., not | |
| 1424 // including page bookkeeping structures) currently in the space. The 'size' | |
| 1425 // of a space is the number of allocated bytes, the 'waste' in the space is | |
| 1426 // the number of bytes that are not allocated and not available to | |
| 1427 // allocation without reorganizing the space via a GC (e.g. small blocks due | |
| 1428 // to internal fragmentation, top of page areas in map space), and the bytes | |
| 1429 // 'available' is the number of unallocated bytes that are not waste. The | |
| 1430 // capacity is the sum of size, waste, and available. | |
| 1431 // | 1423 // |
| 1432 // The stats are only set by functions that ensure they stay balanced. These | 1424 // The stats are only set by functions that ensure they stay balanced. These |
| 1433 // functions increase or decrease one of the non-capacity stats in | 1425 // functions increase or decrease one of the non-capacity stats in conjunction |
| 1434 // conjunction with capacity, or else they always balance increases and | 1426 // with capacity, or else they always balance increases and decreases to the |
| 1435 // decreases to the non-capacity stats. | 1427 // non-capacity stats. |
| 1436 class AllocationStats BASE_EMBEDDED { | 1428 class AllocationStats BASE_EMBEDDED { |
| 1437 public: | 1429 public: |
| 1438 AllocationStats() { Clear(); } | 1430 AllocationStats() { Clear(); } |
| 1439 | 1431 |
| 1440 // Zero out all the allocation statistics (i.e., no capacity). | 1432 // Zero out all the allocation statistics (i.e., no capacity). |
| 1441 void Clear() { | 1433 void Clear() { |
| 1442 capacity_ = 0; | 1434 capacity_ = 0; |
| 1443 max_capacity_ = 0; | 1435 max_capacity_ = 0; |
| 1444 size_ = 0; | 1436 size_ = 0; |
| 1445 waste_ = 0; | |
| 1446 } | 1437 } |
| 1447 | 1438 |
| 1448 void ClearSizeWaste() { | 1439 void ClearSize() { size_ = capacity_; } |
| 1449 size_ = capacity_; | |
| 1450 waste_ = 0; | |
| 1451 } | |
| 1452 | 1440 |
| 1453 // Reset the allocation statistics (i.e., available = capacity with no | 1441 // Reset the allocation statistics (i.e., available = capacity with no wasted |
| 1454 // wasted or allocated bytes). | 1442 // or allocated bytes). |
| 1455 void Reset() { | 1443 void Reset() { |
| 1456 size_ = 0; | 1444 size_ = 0; |
| 1457 waste_ = 0; | |
| 1458 } | 1445 } |
| 1459 | 1446 |
| 1460 // Accessors for the allocation statistics. | 1447 // Accessors for the allocation statistics. |
| 1461 intptr_t Capacity() { return capacity_; } | 1448 intptr_t Capacity() { return capacity_; } |
| 1462 intptr_t MaxCapacity() { return max_capacity_; } | 1449 intptr_t MaxCapacity() { return max_capacity_; } |
| 1463 intptr_t Size() { return size_; } | 1450 intptr_t Size() { return size_; } |
| 1464 intptr_t Waste() { return waste_; } | |
| 1465 | 1451 |
| 1466 // Grow the space by adding available bytes. They are initially marked as | 1452 // Grow the space by adding available bytes. They are initially marked as |
| 1467 // being in use (part of the size), but will normally be immediately freed, | 1453 // being in use (part of the size), but will normally be immediately freed, |
| 1468 // putting them on the free list and removing them from size_. | 1454 // putting them on the free list and removing them from size_. |
| 1469 void ExpandSpace(int size_in_bytes) { | 1455 void ExpandSpace(int size_in_bytes) { |
| 1470 capacity_ += size_in_bytes; | 1456 capacity_ += size_in_bytes; |
| 1471 size_ += size_in_bytes; | 1457 size_ += size_in_bytes; |
| 1472 if (capacity_ > max_capacity_) { | 1458 if (capacity_ > max_capacity_) { |
| 1473 max_capacity_ = capacity_; | 1459 max_capacity_ = capacity_; |
| 1474 } | 1460 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1489 size_ += size_in_bytes; | 1475 size_ += size_in_bytes; |
| 1490 DCHECK(size_ >= 0); | 1476 DCHECK(size_ >= 0); |
| 1491 } | 1477 } |
| 1492 | 1478 |
| 1493 // Free allocated bytes, making them available (size -> available). | 1479 // Free allocated bytes, making them available (size -> available). |
| 1494 void DeallocateBytes(intptr_t size_in_bytes) { | 1480 void DeallocateBytes(intptr_t size_in_bytes) { |
| 1495 size_ -= size_in_bytes; | 1481 size_ -= size_in_bytes; |
| 1496 DCHECK(size_ >= 0); | 1482 DCHECK(size_ >= 0); |
| 1497 } | 1483 } |
| 1498 | 1484 |
| 1499 // Waste free bytes (available -> waste). | |
| 1500 void WasteBytes(int size_in_bytes) { | |
| 1501 DCHECK(size_in_bytes >= 0); | |
| 1502 waste_ += size_in_bytes; | |
| 1503 } | |
| 1504 | |
| 1505 // Merge {other} into {this}. | 1485 // Merge {other} into {this}. |
| 1506 void Merge(const AllocationStats& other) { | 1486 void Merge(const AllocationStats& other) { |
| 1507 capacity_ += other.capacity_; | 1487 capacity_ += other.capacity_; |
| 1508 size_ += other.size_; | 1488 size_ += other.size_; |
| 1509 waste_ += other.waste_; | |
| 1510 if (other.max_capacity_ > max_capacity_) { | 1489 if (other.max_capacity_ > max_capacity_) { |
| 1511 max_capacity_ = other.max_capacity_; | 1490 max_capacity_ = other.max_capacity_; |
| 1512 } | 1491 } |
| 1513 } | 1492 } |
| 1514 | 1493 |
| 1515 void DecreaseCapacity(intptr_t size_in_bytes) { | 1494 void DecreaseCapacity(intptr_t size_in_bytes) { |
| 1516 capacity_ -= size_in_bytes; | 1495 capacity_ -= size_in_bytes; |
| 1517 DCHECK_GE(capacity_, 0); | 1496 DCHECK_GE(capacity_, 0); |
| 1518 } | 1497 } |
| 1519 | 1498 |
| 1520 void IncreaseCapacity(intptr_t size_in_bytes) { capacity_ += size_in_bytes; } | 1499 void IncreaseCapacity(intptr_t size_in_bytes) { capacity_ += size_in_bytes; } |
| 1521 | 1500 |
| 1522 private: | 1501 private: |
| 1502 // |capacity_|: The number of object-area bytes (i.e., not including page |
| 1503 // bookkeeping structures) currently in the space. |
| 1523 intptr_t capacity_; | 1504 intptr_t capacity_; |
| 1505 |
| 1506 // |max_capacity_|: The maximum capacity ever observed. |
| 1524 intptr_t max_capacity_; | 1507 intptr_t max_capacity_; |
| 1508 |
| 1509 // |size_|: The number of allocated bytes. |
| 1525 intptr_t size_; | 1510 intptr_t size_; |
| 1526 intptr_t waste_; | |
| 1527 }; | 1511 }; |
| 1528 | 1512 |
| 1529 | 1513 |
| 1530 // ----------------------------------------------------------------------------- | 1514 // ----------------------------------------------------------------------------- |
| 1531 // Free lists for old object spaces | 1515 // Free lists for old object spaces |
| 1532 | 1516 |
| 1533 // The free list category holds a pointer to the top element and a pointer to | 1517 // The free list category holds a pointer to the top element and a pointer to |
| 1534 // the end element of the linked list of free memory blocks. | 1518 // the end element of the linked list of free memory blocks. |
| 1535 class FreeListCategory { | 1519 class FreeListCategory { |
| 1536 public: | 1520 public: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1559 base::NoBarrier_Store(&top_, reinterpret_cast<base::AtomicWord>(top)); | 1543 base::NoBarrier_Store(&top_, reinterpret_cast<base::AtomicWord>(top)); |
| 1560 } | 1544 } |
| 1561 | 1545 |
| 1562 FreeSpace* end() const { return end_; } | 1546 FreeSpace* end() const { return end_; } |
| 1563 void set_end(FreeSpace* end) { end_ = end; } | 1547 void set_end(FreeSpace* end) { end_ = end; } |
| 1564 | 1548 |
| 1565 int* GetAvailableAddress() { return &available_; } | 1549 int* GetAvailableAddress() { return &available_; } |
| 1566 int available() const { return available_; } | 1550 int available() const { return available_; } |
| 1567 void set_available(int available) { available_ = available; } | 1551 void set_available(int available) { available_ = available; } |
| 1568 | 1552 |
| 1569 base::Mutex* mutex() { return &mutex_; } | |
| 1570 | |
| 1571 bool IsEmpty() { return top() == 0; } | 1553 bool IsEmpty() { return top() == 0; } |
| 1572 | 1554 |
| 1573 #ifdef DEBUG | 1555 #ifdef DEBUG |
| 1574 intptr_t SumFreeList(); | 1556 intptr_t SumFreeList(); |
| 1575 int FreeListLength(); | 1557 int FreeListLength(); |
| 1576 #endif | 1558 #endif |
| 1577 | 1559 |
| 1578 FreeList* owner() { return owner_; } | 1560 FreeList* owner() { return owner_; } |
| 1579 | 1561 |
| 1580 private: | 1562 private: |
| 1581 // top_ points to the top FreeSpace* in the free list category. | 1563 // top_ points to the top FreeSpace* in the free list category. |
| 1582 base::AtomicWord top_; | 1564 base::AtomicWord top_; |
| 1583 FreeSpace* end_; | 1565 FreeSpace* end_; |
| 1584 base::Mutex mutex_; | |
| 1585 | |
| 1586 // Total available bytes in all blocks of this free list category. | 1566 // Total available bytes in all blocks of this free list category. |
| 1587 int available_; | 1567 int available_; |
| 1588 | 1568 |
| 1589 FreeList* owner_; | 1569 FreeList* owner_; |
| 1590 }; | 1570 }; |
| 1591 | 1571 |
| 1592 | 1572 |
| 1593 // The free list for the old space. The free list is organized in such a way | 1573 // The free list for the old space. The free list is organized in such a way |
| 1594 // as to encourage objects allocated around the same time to be near each | 1574 // as to encourage objects allocated around the same time to be near each |
| 1595 // other. The normal way to allocate is intended to be by bumping a 'top' | 1575 // other. The normal way to allocate is intended to be by bumping a 'top' |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1610 // spaces are called medium. | 1590 // spaces are called medium. |
| 1611 // 1048-16383 words: There is a list of spaces this large. It is used for top | 1591 // 1048-16383 words: There is a list of spaces this large. It is used for top |
| 1612 // and limit when the object we need to allocate is 256-2047 words in size. | 1592 // and limit when the object we need to allocate is 256-2047 words in size. |
| 1613 // These spaces are call large. | 1593 // These spaces are call large. |
| 1614 // At least 16384 words. This list is for objects of 2048 words or larger. | 1594 // At least 16384 words. This list is for objects of 2048 words or larger. |
| 1615 // Empty pages are added to this list. These spaces are called huge. | 1595 // Empty pages are added to this list. These spaces are called huge. |
| 1616 class FreeList { | 1596 class FreeList { |
| 1617 public: | 1597 public: |
| 1618 explicit FreeList(PagedSpace* owner); | 1598 explicit FreeList(PagedSpace* owner); |
| 1619 | 1599 |
| 1620 intptr_t Concatenate(FreeList* free_list); | 1600 intptr_t Concatenate(FreeList* other); |
| 1621 | 1601 |
| 1622 // Clear the free list. | 1602 // Clear the free list. |
| 1623 void Reset(); | 1603 void Reset(); |
| 1624 | 1604 |
| 1605 void ResetStats() { wasted_bytes_ = 0; } |
| 1606 |
| 1625 // Return the number of bytes available on the free list. | 1607 // Return the number of bytes available on the free list. |
| 1626 intptr_t available() { | 1608 intptr_t available() { |
| 1627 return small_list_.available() + medium_list_.available() + | 1609 return small_list_.available() + medium_list_.available() + |
| 1628 large_list_.available() + huge_list_.available(); | 1610 large_list_.available() + huge_list_.available(); |
| 1629 } | 1611 } |
| 1630 | 1612 |
| 1631 // Place a node on the free list. The block of size 'size_in_bytes' | 1613 // Place a node on the free list. The block of size 'size_in_bytes' |
| 1632 // starting at 'start' is placed on the free list. The return value is the | 1614 // starting at 'start' is placed on the free list. The return value is the |
| 1633 // number of bytes that have been lost due to internal fragmentation by | 1615 // number of bytes that have been lost due to internal fragmentation by |
| 1634 // freeing the block. Bookkeeping information will be written to the block, | 1616 // freeing the block. Bookkeeping information will be written to the block, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1645 return kSmallAllocationMax; | 1627 return kSmallAllocationMax; |
| 1646 } else if (maximum_freed <= kMediumListMax) { | 1628 } else if (maximum_freed <= kMediumListMax) { |
| 1647 return kMediumAllocationMax; | 1629 return kMediumAllocationMax; |
| 1648 } else if (maximum_freed <= kLargeListMax) { | 1630 } else if (maximum_freed <= kLargeListMax) { |
| 1649 return kLargeAllocationMax; | 1631 return kLargeAllocationMax; |
| 1650 } | 1632 } |
| 1651 return maximum_freed; | 1633 return maximum_freed; |
| 1652 } | 1634 } |
| 1653 | 1635 |
| 1654 // Allocate a block of size 'size_in_bytes' from the free list. The block | 1636 // Allocate a block of size 'size_in_bytes' from the free list. The block |
| 1655 // is unitialized. A failure is returned if no block is available. The | 1637 // is unitialized. A failure is returned if no block is available. |
| 1656 // number of bytes lost to fragmentation is returned in the output parameter | 1638 // The size should be a non-zero multiple of the word size. |
| 1657 // 'wasted_bytes'. The size should be a non-zero multiple of the word size. | |
| 1658 MUST_USE_RESULT HeapObject* Allocate(int size_in_bytes); | 1639 MUST_USE_RESULT HeapObject* Allocate(int size_in_bytes); |
| 1659 | 1640 |
| 1660 bool IsEmpty() { | 1641 bool IsEmpty() { |
| 1661 return small_list_.IsEmpty() && medium_list_.IsEmpty() && | 1642 return small_list_.IsEmpty() && medium_list_.IsEmpty() && |
| 1662 large_list_.IsEmpty() && huge_list_.IsEmpty(); | 1643 large_list_.IsEmpty() && huge_list_.IsEmpty(); |
| 1663 } | 1644 } |
| 1664 | 1645 |
| 1665 #ifdef DEBUG | 1646 #ifdef DEBUG |
| 1666 void Zap(); | 1647 void Zap(); |
| 1667 intptr_t SumFreeLists(); | 1648 intptr_t SumFreeLists(); |
| 1668 bool IsVeryLong(); | 1649 bool IsVeryLong(); |
| 1669 #endif | 1650 #endif |
| 1670 | 1651 |
| 1671 // Used after booting the VM. | 1652 // Used after booting the VM. |
| 1672 void RepairLists(Heap* heap); | 1653 void RepairLists(Heap* heap); |
| 1673 | 1654 |
| 1674 intptr_t EvictFreeListItems(Page* p); | 1655 intptr_t EvictFreeListItems(Page* p); |
| 1675 bool ContainsPageFreeListItems(Page* p); | 1656 bool ContainsPageFreeListItems(Page* p); |
| 1676 | 1657 |
| 1677 FreeListCategory* small_list() { return &small_list_; } | 1658 FreeListCategory* small_list() { return &small_list_; } |
| 1678 FreeListCategory* medium_list() { return &medium_list_; } | 1659 FreeListCategory* medium_list() { return &medium_list_; } |
| 1679 FreeListCategory* large_list() { return &large_list_; } | 1660 FreeListCategory* large_list() { return &large_list_; } |
| 1680 FreeListCategory* huge_list() { return &huge_list_; } | 1661 FreeListCategory* huge_list() { return &huge_list_; } |
| 1681 | 1662 |
| 1682 PagedSpace* owner() { return owner_; } | 1663 PagedSpace* owner() { return owner_; } |
| 1664 intptr_t wasted_bytes() { return wasted_bytes_; } |
| 1665 base::Mutex* mutex() { return &mutex_; } |
| 1683 | 1666 |
| 1684 private: | 1667 private: |
| 1685 // The size range of blocks, in bytes. | 1668 // The size range of blocks, in bytes. |
| 1686 static const int kMinBlockSize = 3 * kPointerSize; | 1669 static const int kMinBlockSize = 3 * kPointerSize; |
| 1687 static const int kMaxBlockSize = Page::kMaxRegularHeapObjectSize; | 1670 static const int kMaxBlockSize = Page::kMaxRegularHeapObjectSize; |
| 1688 | 1671 |
| 1689 static const int kSmallListMin = 0x1f * kPointerSize; | 1672 static const int kSmallListMin = 0x1f * kPointerSize; |
| 1690 static const int kSmallListMax = 0xff * kPointerSize; | 1673 static const int kSmallListMax = 0xff * kPointerSize; |
| 1691 static const int kMediumListMax = 0x7ff * kPointerSize; | 1674 static const int kMediumListMax = 0x7ff * kPointerSize; |
| 1692 static const int kLargeListMax = 0x3fff * kPointerSize; | 1675 static const int kLargeListMax = 0x3fff * kPointerSize; |
| 1693 static const int kSmallAllocationMax = kSmallListMin; | 1676 static const int kSmallAllocationMax = kSmallListMin; |
| 1694 static const int kMediumAllocationMax = kSmallListMax; | 1677 static const int kMediumAllocationMax = kSmallListMax; |
| 1695 static const int kLargeAllocationMax = kMediumListMax; | 1678 static const int kLargeAllocationMax = kMediumListMax; |
| 1696 | 1679 |
| 1697 FreeSpace* FindNodeFor(int size_in_bytes, int* node_size); | 1680 FreeSpace* FindNodeFor(int size_in_bytes, int* node_size); |
| 1698 | 1681 |
| 1699 PagedSpace* owner_; | 1682 PagedSpace* owner_; |
| 1700 Heap* heap_; | 1683 Heap* heap_; |
| 1684 base::Mutex mutex_; |
| 1685 intptr_t wasted_bytes_; |
| 1701 FreeListCategory small_list_; | 1686 FreeListCategory small_list_; |
| 1702 FreeListCategory medium_list_; | 1687 FreeListCategory medium_list_; |
| 1703 FreeListCategory large_list_; | 1688 FreeListCategory large_list_; |
| 1704 FreeListCategory huge_list_; | 1689 FreeListCategory huge_list_; |
| 1705 | 1690 |
| 1706 DISALLOW_IMPLICIT_CONSTRUCTORS(FreeList); | 1691 DISALLOW_IMPLICIT_CONSTRUCTORS(FreeList); |
| 1707 }; | 1692 }; |
| 1708 | 1693 |
| 1709 | 1694 |
| 1710 class AllocationResult { | 1695 class AllocationResult { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1801 size_t CommittedPhysicalMemory() override; | 1786 size_t CommittedPhysicalMemory() override; |
| 1802 | 1787 |
| 1803 void ResetFreeListStatistics(); | 1788 void ResetFreeListStatistics(); |
| 1804 | 1789 |
| 1805 // Sets the capacity, the available space and the wasted space to zero. | 1790 // Sets the capacity, the available space and the wasted space to zero. |
| 1806 // The stats are rebuilt during sweeping by adding each page to the | 1791 // The stats are rebuilt during sweeping by adding each page to the |
| 1807 // capacity and the size when it is encountered. As free spaces are | 1792 // capacity and the size when it is encountered. As free spaces are |
| 1808 // discovered during the sweeping they are subtracted from the size and added | 1793 // discovered during the sweeping they are subtracted from the size and added |
| 1809 // to the available and wasted totals. | 1794 // to the available and wasted totals. |
| 1810 void ClearStats() { | 1795 void ClearStats() { |
| 1811 accounting_stats_.ClearSizeWaste(); | 1796 accounting_stats_.ClearSize(); |
| 1797 free_list_.ResetStats(); |
| 1812 ResetFreeListStatistics(); | 1798 ResetFreeListStatistics(); |
| 1813 } | 1799 } |
| 1814 | 1800 |
| 1815 // Increases the number of available bytes of that space. | 1801 // Increases the number of available bytes of that space. |
| 1816 void AddToAccountingStats(intptr_t bytes) { | 1802 void AddToAccountingStats(intptr_t bytes) { |
| 1817 accounting_stats_.DeallocateBytes(bytes); | 1803 accounting_stats_.DeallocateBytes(bytes); |
| 1818 } | 1804 } |
| 1819 | 1805 |
| 1820 // Available bytes without growing. These are the bytes on the free list. | 1806 // Available bytes without growing. These are the bytes on the free list. |
| 1821 // The bytes in the linear allocation area are not included in this total | 1807 // The bytes in the linear allocation area are not included in this total |
| 1822 // because updating the stats would slow down allocation. New pages are | 1808 // because updating the stats would slow down allocation. New pages are |
| 1823 // immediately added to the free list so they show up here. | 1809 // immediately added to the free list so they show up here. |
| 1824 intptr_t Available() override { return free_list_.available(); } | 1810 intptr_t Available() override { return free_list_.available(); } |
| 1825 | 1811 |
| 1826 // Allocated bytes in this space. Garbage bytes that were not found due to | 1812 // Allocated bytes in this space. Garbage bytes that were not found due to |
| 1827 // concurrent sweeping are counted as being allocated! The bytes in the | 1813 // concurrent sweeping are counted as being allocated! The bytes in the |
| 1828 // current linear allocation area (between top and limit) are also counted | 1814 // current linear allocation area (between top and limit) are also counted |
| 1829 // here. | 1815 // here. |
| 1830 intptr_t Size() override { return accounting_stats_.Size(); } | 1816 intptr_t Size() override { return accounting_stats_.Size(); } |
| 1831 | 1817 |
| 1832 // As size, but the bytes in lazily swept pages are estimated and the bytes | 1818 // As size, but the bytes in lazily swept pages are estimated and the bytes |
| 1833 // in the current linear allocation area are not included. | 1819 // in the current linear allocation area are not included. |
| 1834 intptr_t SizeOfObjects() override; | 1820 intptr_t SizeOfObjects() override; |
| 1835 | 1821 |
| 1836 // Wasted bytes in this space. These are just the bytes that were thrown away | 1822 // Wasted bytes in this space. These are just the bytes that were thrown away |
| 1837 // due to being too small to use for allocation. They do not include the | 1823 // due to being too small to use for allocation. |
| 1838 // free bytes that were not found at all due to lazy sweeping. | 1824 virtual intptr_t Waste() { return free_list_.wasted_bytes(); } |
| 1839 virtual intptr_t Waste() { return accounting_stats_.Waste(); } | |
| 1840 | 1825 |
| 1841 // Returns the allocation pointer in this space. | 1826 // Returns the allocation pointer in this space. |
| 1842 Address top() { return allocation_info_.top(); } | 1827 Address top() { return allocation_info_.top(); } |
| 1843 Address limit() { return allocation_info_.limit(); } | 1828 Address limit() { return allocation_info_.limit(); } |
| 1844 | 1829 |
| 1845 // The allocation top address. | 1830 // The allocation top address. |
| 1846 Address* allocation_top_address() { return allocation_info_.top_address(); } | 1831 Address* allocation_top_address() { return allocation_info_.top_address(); } |
| 1847 | 1832 |
| 1848 // The allocation limit address. | 1833 // The allocation limit address. |
| 1849 Address* allocation_limit_address() { | 1834 Address* allocation_limit_address() { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1868 MUST_USE_RESULT inline AllocationResult AllocateRaw( | 1853 MUST_USE_RESULT inline AllocationResult AllocateRaw( |
| 1869 int size_in_bytes, AllocationAlignment alignment); | 1854 int size_in_bytes, AllocationAlignment alignment); |
| 1870 | 1855 |
| 1871 // Give a block of memory to the space's free list. It might be added to | 1856 // Give a block of memory to the space's free list. It might be added to |
| 1872 // the free list or accounted as waste. | 1857 // the free list or accounted as waste. |
| 1873 // If add_to_freelist is false then just accounting stats are updated and | 1858 // If add_to_freelist is false then just accounting stats are updated and |
| 1874 // no attempt to add area to free list is made. | 1859 // no attempt to add area to free list is made. |
| 1875 int Free(Address start, int size_in_bytes) { | 1860 int Free(Address start, int size_in_bytes) { |
| 1876 int wasted = free_list_.Free(start, size_in_bytes); | 1861 int wasted = free_list_.Free(start, size_in_bytes); |
| 1877 accounting_stats_.DeallocateBytes(size_in_bytes); | 1862 accounting_stats_.DeallocateBytes(size_in_bytes); |
| 1878 accounting_stats_.WasteBytes(wasted); | |
| 1879 return size_in_bytes - wasted; | 1863 return size_in_bytes - wasted; |
| 1880 } | 1864 } |
| 1881 | 1865 |
| 1882 void ResetFreeList() { free_list_.Reset(); } | 1866 void ResetFreeList() { free_list_.Reset(); } |
| 1883 | 1867 |
| 1884 // Set space allocation info. | 1868 // Set space allocation info. |
| 1885 void SetTopAndLimit(Address top, Address limit) { | 1869 void SetTopAndLimit(Address top, Address limit) { |
| 1886 DCHECK(top == limit || | 1870 DCHECK(top == limit || |
| 1887 Page::FromAddress(top) == Page::FromAddress(limit - 1)); | 1871 Page::FromAddress(top) == Page::FromAddress(limit - 1)); |
| 1888 MemoryChunk::UpdateHighWaterMark(allocation_info_.top()); | 1872 MemoryChunk::UpdateHighWaterMark(allocation_info_.top()); |
| (...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2970 count = 0; | 2954 count = 0; |
| 2971 } | 2955 } |
| 2972 // Must be small, since an iteration is used for lookup. | 2956 // Must be small, since an iteration is used for lookup. |
| 2973 static const int kMaxComments = 64; | 2957 static const int kMaxComments = 64; |
| 2974 }; | 2958 }; |
| 2975 #endif | 2959 #endif |
| 2976 } | 2960 } |
| 2977 } // namespace v8::internal | 2961 } // namespace v8::internal |
| 2978 | 2962 |
| 2979 #endif // V8_HEAP_SPACES_H_ | 2963 #endif // V8_HEAP_SPACES_H_ |
| OLD | NEW |