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