Chromium Code Reviews| 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 1551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1562 | 1562 |
| 1563 | 1563 |
| 1564 // ----------------------------------------------------------------------------- | 1564 // ----------------------------------------------------------------------------- |
| 1565 // A space has a circular list of pages. The next page can be accessed via | 1565 // A space has a circular list of pages. The next page can be accessed via |
| 1566 // Page::next_page() call. | 1566 // Page::next_page() call. |
| 1567 | 1567 |
| 1568 // An abstraction of allocation and relocation pointers in a page-structured | 1568 // An abstraction of allocation and relocation pointers in a page-structured |
| 1569 // space. | 1569 // space. |
| 1570 class AllocationInfo { | 1570 class AllocationInfo { |
| 1571 public: | 1571 public: |
| 1572 AllocationInfo() : top_(nullptr), limit_(nullptr) {} | 1572 AllocationInfo() { Reset(nullptr, nullptr); } |
| 1573 AllocationInfo(Address top, Address limit) : top_(top), limit_(limit) {} | 1573 AllocationInfo(Address top, Address limit) { Reset(top, limit); } |
| 1574 | 1574 |
| 1575 void Reset(Address top, Address limit) { | 1575 void Reset(Address top, Address limit) { |
| 1576 set_top(top); | 1576 set_top(top); |
| 1577 set_limit(limit); | 1577 set_limit(limit); |
| 1578 } | 1578 } |
| 1579 | 1579 |
| 1580 INLINE(void set_top(Address top)) { | 1580 inline void set_top(Address top) { |
| 1581 SLOW_DCHECK(top == NULL || | 1581 SLOW_DCHECK((reinterpret_cast<intptr_t>(top) & kHeapObjectTagMask) == 0); |
| 1582 (reinterpret_cast<intptr_t>(top) & kHeapObjectTagMask) == 0); | 1582 top_ = reinterpret_cast<intptr_t>(top) + kHeapObjectTag; |
| 1583 top_ = top; | |
| 1584 } | 1583 } |
| 1585 | 1584 |
| 1586 INLINE(Address top()) const { | 1585 inline Address top() const { |
| 1587 SLOW_DCHECK(top_ == NULL || | 1586 SLOW_DCHECK((reinterpret_cast<intptr_t>(top_) & kHeapObjectTagMask) == |
| 1588 (reinterpret_cast<intptr_t>(top_) & kHeapObjectTagMask) == 0); | 1587 kHeapObjectTag); |
| 1589 return top_; | 1588 return reinterpret_cast<Address>(top_ - kHeapObjectTag); |
| 1590 } | 1589 } |
| 1591 | 1590 |
| 1592 Address* top_address() { return &top_; } | 1591 Address* top_address() { return reinterpret_cast<Address*>(&top_); } |
| 1593 | 1592 |
| 1594 INLINE(void set_limit(Address limit)) { | 1593 inline void set_limit(Address limit) { |
| 1595 limit_ = limit; | 1594 limit_ = reinterpret_cast<intptr_t>(limit); |
| 1596 } | 1595 } |
| 1597 | 1596 |
| 1598 INLINE(Address limit()) const { | 1597 inline Address limit() const { return reinterpret_cast<Address>(limit_); } |
| 1599 return limit_; | |
| 1600 } | |
| 1601 | 1598 |
| 1602 Address* limit_address() { return &limit_; } | 1599 Address* limit_address() { return reinterpret_cast<Address*>(&limit_); } |
| 1603 | |
| 1604 #ifdef DEBUG | |
| 1605 bool VerifyPagedAllocation() { | |
| 1606 return (Page::FromAllocationAreaAddress(top_) == | |
| 1607 Page::FromAllocationAreaAddress(limit_)) && | |
| 1608 (top_ <= limit_); | |
| 1609 } | |
| 1610 #endif | |
| 1611 | 1600 |
| 1612 private: | 1601 private: |
| 1613 // Current allocation top. | 1602 // Current tagged allocation top. |
| 1614 Address top_; | 1603 intptr_t top_; |
|
Michael Lippautz
2016/04/28 16:58:08
Pointer arithmetic out of object bounds is undefin
Hannes Payer (out of office)
2016/04/29 14:13:31
Oh boy!
| |
| 1615 // Current allocation limit. | 1604 // Current allocation limit. |
| 1616 Address limit_; | 1605 intptr_t limit_; |
| 1617 }; | 1606 }; |
| 1618 | 1607 |
| 1619 | 1608 |
| 1620 // An abstraction of the accounting statistics of a page-structured space. | 1609 // An abstraction of the accounting statistics of a page-structured space. |
| 1621 // | 1610 // |
| 1622 // The stats are only set by functions that ensure they stay balanced. These | 1611 // The stats are only set by functions that ensure they stay balanced. These |
| 1623 // functions increase or decrease one of the non-capacity stats in conjunction | 1612 // functions increase or decrease one of the non-capacity stats in conjunction |
| 1624 // with capacity, or else they always balance increases and decreases to the | 1613 // with capacity, or else they always balance increases and decreases to the |
| 1625 // non-capacity stats. | 1614 // non-capacity stats. |
| 1626 class AllocationStats BASE_EMBEDDED { | 1615 class AllocationStats BASE_EMBEDDED { |
| (...skipping 1411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3038 count = 0; | 3027 count = 0; |
| 3039 } | 3028 } |
| 3040 // Must be small, since an iteration is used for lookup. | 3029 // Must be small, since an iteration is used for lookup. |
| 3041 static const int kMaxComments = 64; | 3030 static const int kMaxComments = 64; |
| 3042 }; | 3031 }; |
| 3043 #endif | 3032 #endif |
| 3044 } // namespace internal | 3033 } // namespace internal |
| 3045 } // namespace v8 | 3034 } // namespace v8 |
| 3046 | 3035 |
| 3047 #endif // V8_HEAP_SPACES_H_ | 3036 #endif // V8_HEAP_SPACES_H_ |
| OLD | NEW |