| 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 | 9 |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| (...skipping 1625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1636 | 1636 |
| 1637 | 1637 |
| 1638 // ----------------------------------------------------------------------------- | 1638 // ----------------------------------------------------------------------------- |
| 1639 // A space has a circular list of pages. The next page can be accessed via | 1639 // A space has a circular list of pages. The next page can be accessed via |
| 1640 // Page::next_page() call. | 1640 // Page::next_page() call. |
| 1641 | 1641 |
| 1642 // An abstraction of allocation and relocation pointers in a page-structured | 1642 // An abstraction of allocation and relocation pointers in a page-structured |
| 1643 // space. | 1643 // space. |
| 1644 class AllocationInfo { | 1644 class AllocationInfo { |
| 1645 public: | 1645 public: |
| 1646 AllocationInfo() : top_(nullptr), limit_(nullptr) {} | 1646 AllocationInfo() { Reset(nullptr, nullptr); } |
| 1647 AllocationInfo(Address top, Address limit) : top_(top), limit_(limit) {} | 1647 AllocationInfo(Address top, Address limit) { Reset(top, limit); } |
| 1648 | 1648 |
| 1649 void Reset(Address top, Address limit) { | 1649 void Reset(Address top, Address limit) { |
| 1650 set_top(top); | 1650 set_top(top); |
| 1651 set_limit(limit); | 1651 set_limit(limit); |
| 1652 } | 1652 } |
| 1653 | 1653 |
| 1654 INLINE(void set_top(Address top)) { | 1654 inline void set_top(Address top) { |
| 1655 SLOW_DCHECK(top == NULL || | 1655 SLOW_DCHECK((reinterpret_cast<intptr_t>(top) & kHeapObjectTagMask) == 0); |
| 1656 (reinterpret_cast<intptr_t>(top) & kHeapObjectTagMask) == 0); | 1656 top_ = reinterpret_cast<intptr_t>(top) + kHeapObjectTag; |
| 1657 top_ = top; | |
| 1658 } | 1657 } |
| 1659 | 1658 |
| 1660 INLINE(Address top()) const { | 1659 inline Address top() const { |
| 1661 SLOW_DCHECK(top_ == NULL || | 1660 SLOW_DCHECK((reinterpret_cast<intptr_t>(top_) & kHeapObjectTagMask) == |
| 1662 (reinterpret_cast<intptr_t>(top_) & kHeapObjectTagMask) == 0); | 1661 kHeapObjectTag); |
| 1663 return top_; | 1662 return reinterpret_cast<Address>(top_ - kHeapObjectTag); |
| 1664 } | 1663 } |
| 1665 | 1664 |
| 1666 Address* top_address() { return &top_; } | 1665 Address* top_address() { return reinterpret_cast<Address*>(&top_); } |
| 1667 | 1666 |
| 1668 INLINE(void set_limit(Address limit)) { | 1667 inline void set_limit(Address limit) { |
| 1669 limit_ = limit; | 1668 limit_ = reinterpret_cast<intptr_t>(limit); |
| 1670 } | 1669 } |
| 1671 | 1670 |
| 1672 INLINE(Address limit()) const { | 1671 inline Address limit() const { return reinterpret_cast<Address>(limit_); } |
| 1673 return limit_; | |
| 1674 } | |
| 1675 | 1672 |
| 1676 Address* limit_address() { return &limit_; } | 1673 Address* limit_address() { return reinterpret_cast<Address*>(&limit_); } |
| 1677 | |
| 1678 #ifdef DEBUG | |
| 1679 bool VerifyPagedAllocation() { | |
| 1680 return (Page::FromAllocationAreaAddress(top_) == | |
| 1681 Page::FromAllocationAreaAddress(limit_)) && | |
| 1682 (top_ <= limit_); | |
| 1683 } | |
| 1684 #endif | |
| 1685 | 1674 |
| 1686 private: | 1675 private: |
| 1687 // Current allocation top. | 1676 // Current tagged allocation top. |
| 1688 Address top_; | 1677 intptr_t top_; |
| 1689 // Current allocation limit. | 1678 // Current allocation limit. |
| 1690 Address limit_; | 1679 intptr_t limit_; |
| 1691 }; | 1680 }; |
| 1692 | 1681 |
| 1693 | 1682 |
| 1694 // An abstraction of the accounting statistics of a page-structured space. | 1683 // An abstraction of the accounting statistics of a page-structured space. |
| 1695 // | 1684 // |
| 1696 // The stats are only set by functions that ensure they stay balanced. These | 1685 // The stats are only set by functions that ensure they stay balanced. These |
| 1697 // functions increase or decrease one of the non-capacity stats in conjunction | 1686 // functions increase or decrease one of the non-capacity stats in conjunction |
| 1698 // with capacity, or else they always balance increases and decreases to the | 1687 // with capacity, or else they always balance increases and decreases to the |
| 1699 // non-capacity stats. | 1688 // non-capacity stats. |
| 1700 class AllocationStats BASE_EMBEDDED { | 1689 class AllocationStats BASE_EMBEDDED { |
| (...skipping 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3144 count = 0; | 3133 count = 0; |
| 3145 } | 3134 } |
| 3146 // Must be small, since an iteration is used for lookup. | 3135 // Must be small, since an iteration is used for lookup. |
| 3147 static const int kMaxComments = 64; | 3136 static const int kMaxComments = 64; |
| 3148 }; | 3137 }; |
| 3149 #endif | 3138 #endif |
| 3150 } // namespace internal | 3139 } // namespace internal |
| 3151 } // namespace v8 | 3140 } // namespace v8 |
| 3152 | 3141 |
| 3153 #endif // V8_HEAP_SPACES_H_ | 3142 #endif // V8_HEAP_SPACES_H_ |
| OLD | NEW |