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