OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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_SLOT_SET_H | 5 #ifndef V8_SLOT_SET_H |
6 #define V8_SLOT_SET_H | 6 #define V8_SLOT_SET_H |
7 | 7 |
8 #include <stack> | 8 #include <stack> |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 // | 161 // |
162 // Sample usage: | 162 // Sample usage: |
163 // Iterate([](Address slot_address) { | 163 // Iterate([](Address slot_address) { |
164 // if (good(slot_address)) return KEEP_SLOT; | 164 // if (good(slot_address)) return KEEP_SLOT; |
165 // else return REMOVE_SLOT; | 165 // else return REMOVE_SLOT; |
166 // }); | 166 // }); |
167 template <typename Callback> | 167 template <typename Callback> |
168 int Iterate(Callback callback, EmptyBucketMode mode) { | 168 int Iterate(Callback callback, EmptyBucketMode mode) { |
169 int new_count = 0; | 169 int new_count = 0; |
170 for (int bucket_index = 0; bucket_index < kBuckets; bucket_index++) { | 170 for (int bucket_index = 0; bucket_index < kBuckets; bucket_index++) { |
171 if (bucket[bucket_index].Value() != nullptr) { | 171 base::AtomicValue<uint32_t>* current_bucket = |
| 172 bucket[bucket_index].Value(); |
| 173 if (current_bucket != nullptr) { |
172 int in_bucket_count = 0; | 174 int in_bucket_count = 0; |
173 base::AtomicValue<uint32_t>* current_bucket = | |
174 bucket[bucket_index].Value(); | |
175 int cell_offset = bucket_index * kBitsPerBucket; | 175 int cell_offset = bucket_index * kBitsPerBucket; |
176 for (int i = 0; i < kCellsPerBucket; i++, cell_offset += kBitsPerCell) { | 176 for (int i = 0; i < kCellsPerBucket; i++, cell_offset += kBitsPerCell) { |
177 if (current_bucket[i].Value()) { | 177 if (current_bucket[i].Value()) { |
178 uint32_t cell = current_bucket[i].Value(); | 178 uint32_t cell = current_bucket[i].Value(); |
179 uint32_t old_cell = cell; | 179 uint32_t old_cell = cell; |
180 uint32_t new_cell = cell; | 180 uint32_t new_cell = cell; |
181 while (cell) { | 181 while (cell) { |
182 int bit_offset = base::bits::CountTrailingZeros32(cell); | 182 int bit_offset = base::bits::CountTrailingZeros32(cell); |
183 uint32_t bit_mask = 1u << bit_offset; | 183 uint32_t bit_mask = 1u << bit_offset; |
184 uint32_t slot = (cell_offset + bit_offset) << kPointerSizeLog2; | 184 uint32_t slot = (cell_offset + bit_offset) << kPointerSizeLog2; |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 Address page_start_; | 481 Address page_start_; |
482 base::AtomicValue<Chunk*> chunk_; | 482 base::AtomicValue<Chunk*> chunk_; |
483 base::Mutex to_be_freed_chunks_mutex_; | 483 base::Mutex to_be_freed_chunks_mutex_; |
484 std::stack<Chunk*> to_be_freed_chunks_; | 484 std::stack<Chunk*> to_be_freed_chunks_; |
485 }; | 485 }; |
486 | 486 |
487 } // namespace internal | 487 } // namespace internal |
488 } // namespace v8 | 488 } // namespace v8 |
489 | 489 |
490 #endif // V8_SLOT_SET_H | 490 #endif // V8_SLOT_SET_H |
OLD | NEW |