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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 if (cell) { | 74 if (cell) { |
75 uint32_t bit_mask = 1u << bit_index; | 75 uint32_t bit_mask = 1u << bit_index; |
76 if (cell & bit_mask) { | 76 if (cell & bit_mask) { |
77 current_bucket[cell_index].ClearBit(bit_index); | 77 current_bucket[cell_index].ClearBit(bit_index); |
78 } | 78 } |
79 } | 79 } |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 void PreFreeEmptyBucket(int bucket_index) { | 83 void PreFreeEmptyBucket(int bucket_index) { |
84 base::LockGuard<base::Mutex> guard(&to_be_freed_buckets_mutex_); | |
85 base::AtomicValue<uint32_t>* bucket_ptr = bucket[bucket_index].Value(); | 84 base::AtomicValue<uint32_t>* bucket_ptr = bucket[bucket_index].Value(); |
86 to_be_freed_buckets_.push(bucket_ptr); | 85 if (bucket_ptr != nullptr) { |
87 bucket[bucket_index].SetValue(nullptr); | 86 base::LockGuard<base::Mutex> guard(&to_be_freed_buckets_mutex_); |
| 87 to_be_freed_buckets_.push(bucket_ptr); |
| 88 bucket[bucket_index].SetValue(nullptr); |
| 89 } |
88 } | 90 } |
89 | 91 |
90 // The slot offsets specify a range of slots at addresses: | 92 // The slot offsets specify a range of slots at addresses: |
91 // [page_start_ + start_offset ... page_start_ + end_offset). | 93 // [page_start_ + start_offset ... page_start_ + end_offset). |
92 void RemoveRange(int start_offset, int end_offset, EmptyBucketMode mode) { | 94 void RemoveRange(int start_offset, int end_offset, EmptyBucketMode mode) { |
93 CHECK_LE(end_offset, 1 << kPageSizeBits); | 95 CHECK_LE(end_offset, 1 << kPageSizeBits); |
94 DCHECK_LE(start_offset, end_offset); | 96 DCHECK_LE(start_offset, end_offset); |
95 int start_bucket, start_cell, start_bit; | 97 int start_bucket, start_cell, start_bit; |
96 SlotToIndices(start_offset, &start_bucket, &start_cell, &start_bit); | 98 SlotToIndices(start_offset, &start_bucket, &start_cell, &start_bit); |
97 int end_bucket, end_cell, end_bit; | 99 int end_bucket, end_cell, end_bit; |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 Address page_start_; | 483 Address page_start_; |
482 base::AtomicValue<Chunk*> chunk_; | 484 base::AtomicValue<Chunk*> chunk_; |
483 base::Mutex to_be_freed_chunks_mutex_; | 485 base::Mutex to_be_freed_chunks_mutex_; |
484 std::stack<Chunk*> to_be_freed_chunks_; | 486 std::stack<Chunk*> to_be_freed_chunks_; |
485 }; | 487 }; |
486 | 488 |
487 } // namespace internal | 489 } // namespace internal |
488 } // namespace v8 | 490 } // namespace v8 |
489 | 491 |
490 #endif // V8_SLOT_SET_H | 492 #endif // V8_SLOT_SET_H |
OLD | NEW |