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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, 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_; } | |
109 inline CellType mask() { return mask_; } | |
110 | |
111 #ifdef DEBUG | 108 #ifdef DEBUG |
112 bool operator==(const MarkBit& other) { | 109 bool operator==(const MarkBit& other) { |
113 return cell_ == other.cell_ && mask_ == other.mask_; | 110 return cell_ == other.cell_ && mask_ == other.mask_; |
114 } | 111 } |
115 #endif | 112 #endif |
116 | 113 |
117 inline void Set() { *cell_ |= mask_; } | 114 inline bool data_only() { return data_only_; } |
118 inline bool Get() { return (*cell_ & mask_) != 0; } | |
119 inline void Clear() { *cell_ &= ~mask_; } | |
120 | 115 |
121 inline bool data_only() { return data_only_; } | 116 private: |
| 117 inline CellType* cell() { return cell_; } |
| 118 inline CellType mask() { return mask_; } |
122 | 119 |
123 inline MarkBit Next() { | 120 inline MarkBit Next() { |
124 CellType new_mask = mask_ << 1; | 121 CellType new_mask = mask_ << 1; |
125 if (new_mask == 0) { | 122 if (new_mask == 0) { |
126 return MarkBit(cell_ + 1, 1, data_only_); | 123 return MarkBit(cell_ + 1, 1, data_only_); |
127 } else { | 124 } else { |
128 return MarkBit(cell_, new_mask, data_only_); | 125 return MarkBit(cell_, new_mask, data_only_); |
129 } | 126 } |
130 } | 127 } |
131 | 128 |
132 private: | 129 inline void Set() { *cell_ |= mask_; } |
| 130 inline bool Get() { return (*cell_ & mask_) != 0; } |
| 131 inline void Clear() { *cell_ &= ~mask_; } |
| 132 |
133 CellType* cell_; | 133 CellType* cell_; |
134 CellType mask_; | 134 CellType mask_; |
135 // This boolean indicates that the object is in a data-only space with no | 135 // This boolean indicates that the object is in a data-only space with no |
136 // pointers. This enables some optimizations when marking. | 136 // pointers. This enables some optimizations when marking. |
137 // It is expected that this field is inlined and turned into control flow | 137 // It is expected that this field is inlined and turned into control flow |
138 // at the place where the MarkBit object is created. | 138 // at the place where the MarkBit object is created. |
139 bool data_only_; | 139 bool data_only_; |
| 140 |
| 141 friend class Marking; |
140 }; | 142 }; |
141 | 143 |
142 | 144 |
143 // Bitmap is a sequence of cells each containing fixed number of bits. | 145 // Bitmap is a sequence of cells each containing fixed number of bits. |
144 class Bitmap { | 146 class Bitmap { |
145 public: | 147 public: |
146 static const uint32_t kBitsPerCell = 32; | 148 static const uint32_t kBitsPerCell = 32; |
147 static const uint32_t kBitsPerCellLog2 = 5; | 149 static const uint32_t kBitsPerCellLog2 = 5; |
148 static const uint32_t kBitIndexMask = kBitsPerCell - 1; | 150 static const uint32_t kBitIndexMask = kBitsPerCell - 1; |
149 static const uint32_t kBytesPerCell = kBitsPerCell / kBitsPerByte; | 151 static const uint32_t kBytesPerCell = kBitsPerCell / kBitsPerByte; |
(...skipping 2720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2870 count = 0; | 2872 count = 0; |
2871 } | 2873 } |
2872 // Must be small, since an iteration is used for lookup. | 2874 // Must be small, since an iteration is used for lookup. |
2873 static const int kMaxComments = 64; | 2875 static const int kMaxComments = 64; |
2874 }; | 2876 }; |
2875 #endif | 2877 #endif |
2876 } | 2878 } |
2877 } // namespace v8::internal | 2879 } // namespace v8::internal |
2878 | 2880 |
2879 #endif // V8_HEAP_SPACES_H_ | 2881 #endif // V8_HEAP_SPACES_H_ |
OLD | NEW |