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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 class Space; | 97 class Space; |
98 class FreeList; | 98 class FreeList; |
99 class MemoryChunk; | 99 class MemoryChunk; |
100 | 100 |
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) : cell_(cell), mask_(mask) {} | 105 inline MarkBit(CellType* cell, CellType mask) : cell_(cell), mask_(mask) {} |
106 | 106 |
107 inline CellType* cell() { return cell_; } | |
108 inline CellType mask() { return mask_; } | |
109 | |
110 #ifdef DEBUG | 107 #ifdef DEBUG |
111 bool operator==(const MarkBit& other) { | 108 bool operator==(const MarkBit& other) { |
112 return cell_ == other.cell_ && mask_ == other.mask_; | 109 return cell_ == other.cell_ && mask_ == other.mask_; |
113 } | 110 } |
114 #endif | 111 #endif |
115 | 112 |
116 inline void Set() { *cell_ |= mask_; } | 113 private: |
117 inline bool Get() { return (*cell_ & mask_) != 0; } | 114 inline CellType* cell() { return cell_; } |
118 inline void Clear() { *cell_ &= ~mask_; } | 115 inline CellType mask() { return mask_; } |
119 | |
120 | 116 |
121 inline MarkBit Next() { | 117 inline MarkBit Next() { |
122 CellType new_mask = mask_ << 1; | 118 CellType new_mask = mask_ << 1; |
123 if (new_mask == 0) { | 119 if (new_mask == 0) { |
124 return MarkBit(cell_ + 1, 1); | 120 return MarkBit(cell_ + 1, 1); |
125 } else { | 121 } else { |
126 return MarkBit(cell_, new_mask); | 122 return MarkBit(cell_, new_mask); |
127 } | 123 } |
128 } | 124 } |
129 | 125 |
130 private: | 126 inline void Set() { *cell_ |= mask_; } |
| 127 inline bool Get() { return (*cell_ & mask_) != 0; } |
| 128 inline void Clear() { *cell_ &= ~mask_; } |
| 129 |
131 CellType* cell_; | 130 CellType* cell_; |
132 CellType mask_; | 131 CellType mask_; |
| 132 |
| 133 friend class Marking; |
133 }; | 134 }; |
134 | 135 |
135 | 136 |
136 // Bitmap is a sequence of cells each containing fixed number of bits. | 137 // Bitmap is a sequence of cells each containing fixed number of bits. |
137 class Bitmap { | 138 class Bitmap { |
138 public: | 139 public: |
139 static const uint32_t kBitsPerCell = 32; | 140 static const uint32_t kBitsPerCell = 32; |
140 static const uint32_t kBitsPerCellLog2 = 5; | 141 static const uint32_t kBitsPerCellLog2 = 5; |
141 static const uint32_t kBitIndexMask = kBitsPerCell - 1; | 142 static const uint32_t kBitIndexMask = kBitsPerCell - 1; |
142 static const uint32_t kBytesPerCell = kBitsPerCell / kBitsPerByte; | 143 static const uint32_t kBytesPerCell = kBitsPerCell / kBitsPerByte; |
(...skipping 2717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2860 count = 0; | 2861 count = 0; |
2861 } | 2862 } |
2862 // Must be small, since an iteration is used for lookup. | 2863 // Must be small, since an iteration is used for lookup. |
2863 static const int kMaxComments = 64; | 2864 static const int kMaxComments = 64; |
2864 }; | 2865 }; |
2865 #endif | 2866 #endif |
2866 } | 2867 } |
2867 } // namespace v8::internal | 2868 } // namespace v8::internal |
2868 | 2869 |
2869 #endif // V8_HEAP_SPACES_H_ | 2870 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |