| 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/base/atomicops.h" | 9 #include "src/base/atomicops.h" |
| 10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 class MarkBit { | 101 class MarkBit { |
| 102 public: | 102 public: |
| 103 typedef uint32_t CellType; | 103 typedef uint32_t CellType; |
| 104 | 104 |
| 105 inline MarkBit(CellType* cell, CellType mask, bool data_only) | 105 inline MarkBit(CellType* cell, CellType mask, bool data_only) |
| 106 : cell_(cell), mask_(mask), data_only_(data_only) {} | 106 : cell_(cell), mask_(mask), data_only_(data_only) {} |
| 107 | 107 |
| 108 inline CellType* cell() { return cell_; } | 108 inline CellType* cell() { return cell_; } |
| 109 inline CellType mask() { return mask_; } | 109 inline CellType mask() { return mask_; } |
| 110 | 110 |
| 111 #ifdef DEBUG | 111 #if DCHECK_IS_ON |
| 112 bool operator==(const MarkBit& other) { | 112 bool operator==(const MarkBit& other) { |
| 113 return cell_ == other.cell_ && mask_ == other.mask_; | 113 return cell_ == other.cell_ && mask_ == other.mask_; |
| 114 } | 114 } |
| 115 #endif | 115 #endif |
| 116 | 116 |
| 117 inline void Set() { *cell_ |= mask_; } | 117 inline void Set() { *cell_ |= mask_; } |
| 118 inline bool Get() { return (*cell_ & mask_) != 0; } | 118 inline bool Get() { return (*cell_ & mask_) != 0; } |
| 119 inline void Clear() { *cell_ &= ~mask_; } | 119 inline void Clear() { *cell_ &= ~mask_; } |
| 120 | 120 |
| 121 inline bool data_only() { return data_only_; } | 121 inline bool data_only() { return data_only_; } |
| (...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1484 void set_end(FreeListNode* end) { end_ = end; } | 1484 void set_end(FreeListNode* end) { end_ = end; } |
| 1485 | 1485 |
| 1486 int* GetAvailableAddress() { return &available_; } | 1486 int* GetAvailableAddress() { return &available_; } |
| 1487 int available() const { return available_; } | 1487 int available() const { return available_; } |
| 1488 void set_available(int available) { available_ = available; } | 1488 void set_available(int available) { available_ = available; } |
| 1489 | 1489 |
| 1490 base::Mutex* mutex() { return &mutex_; } | 1490 base::Mutex* mutex() { return &mutex_; } |
| 1491 | 1491 |
| 1492 bool IsEmpty() { return top() == 0; } | 1492 bool IsEmpty() { return top() == 0; } |
| 1493 | 1493 |
| 1494 #ifdef DEBUG | 1494 #if DCHECK_IS_ON |
| 1495 intptr_t SumFreeList(); | 1495 intptr_t SumFreeList(); |
| 1496 int FreeListLength(); | 1496 int FreeListLength(); |
| 1497 #endif | 1497 #endif |
| 1498 | 1498 |
| 1499 private: | 1499 private: |
| 1500 // top_ points to the top FreeListNode* in the free list category. | 1500 // top_ points to the top FreeListNode* in the free list category. |
| 1501 base::AtomicWord top_; | 1501 base::AtomicWord top_; |
| 1502 FreeListNode* end_; | 1502 FreeListNode* end_; |
| 1503 base::Mutex mutex_; | 1503 base::Mutex mutex_; |
| 1504 | 1504 |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1572 // is unitialized. A failure is returned if no block is available. The | 1572 // is unitialized. A failure is returned if no block is available. The |
| 1573 // number of bytes lost to fragmentation is returned in the output parameter | 1573 // number of bytes lost to fragmentation is returned in the output parameter |
| 1574 // 'wasted_bytes'. The size should be a non-zero multiple of the word size. | 1574 // 'wasted_bytes'. The size should be a non-zero multiple of the word size. |
| 1575 MUST_USE_RESULT HeapObject* Allocate(int size_in_bytes); | 1575 MUST_USE_RESULT HeapObject* Allocate(int size_in_bytes); |
| 1576 | 1576 |
| 1577 bool IsEmpty() { | 1577 bool IsEmpty() { |
| 1578 return small_list_.IsEmpty() && medium_list_.IsEmpty() && | 1578 return small_list_.IsEmpty() && medium_list_.IsEmpty() && |
| 1579 large_list_.IsEmpty() && huge_list_.IsEmpty(); | 1579 large_list_.IsEmpty() && huge_list_.IsEmpty(); |
| 1580 } | 1580 } |
| 1581 | 1581 |
| 1582 #ifdef DEBUG | 1582 #if DCHECK_IS_ON |
| 1583 void Zap(); | 1583 void Zap(); |
| 1584 intptr_t SumFreeLists(); | 1584 intptr_t SumFreeLists(); |
| 1585 bool IsVeryLong(); | 1585 bool IsVeryLong(); |
| 1586 #endif | 1586 #endif |
| 1587 | 1587 |
| 1588 // Used after booting the VM. | 1588 // Used after booting the VM. |
| 1589 void RepairLists(Heap* heap); | 1589 void RepairLists(Heap* heap); |
| 1590 | 1590 |
| 1591 intptr_t EvictFreeListItems(Page* p); | 1591 intptr_t EvictFreeListItems(Page* p); |
| 1592 bool ContainsPageFreeListItems(Page* p); | 1592 bool ContainsPageFreeListItems(Page* p); |
| (...skipping 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2917 count = 0; | 2917 count = 0; |
| 2918 } | 2918 } |
| 2919 // Must be small, since an iteration is used for lookup. | 2919 // Must be small, since an iteration is used for lookup. |
| 2920 static const int kMaxComments = 64; | 2920 static const int kMaxComments = 64; |
| 2921 }; | 2921 }; |
| 2922 #endif | 2922 #endif |
| 2923 } | 2923 } |
| 2924 } // namespace v8::internal | 2924 } // namespace v8::internal |
| 2925 | 2925 |
| 2926 #endif // V8_HEAP_SPACES_H_ | 2926 #endif // V8_HEAP_SPACES_H_ |
| OLD | NEW |