Chromium Code Reviews| 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 "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
| 10 #include "src/utils.h" | 10 #include "src/utils.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 // [page_start_ + start_offset ... page_start_ + end_offset). | 65 // [page_start_ + start_offset ... page_start_ + end_offset). |
| 66 void RemoveRange(int start_offset, int end_offset) { | 66 void RemoveRange(int start_offset, int end_offset) { |
| 67 CHECK_LE(end_offset, 1 << kPageSizeBits); | 67 CHECK_LE(end_offset, 1 << kPageSizeBits); |
| 68 DCHECK_LE(start_offset, end_offset); | 68 DCHECK_LE(start_offset, end_offset); |
| 69 int start_bucket, start_cell, start_bit; | 69 int start_bucket, start_cell, start_bit; |
| 70 SlotToIndices(start_offset, &start_bucket, &start_cell, &start_bit); | 70 SlotToIndices(start_offset, &start_bucket, &start_cell, &start_bit); |
| 71 int end_bucket, end_cell, end_bit; | 71 int end_bucket, end_cell, end_bit; |
| 72 SlotToIndices(end_offset, &end_bucket, &end_cell, &end_bit); | 72 SlotToIndices(end_offset, &end_bucket, &end_cell, &end_bit); |
| 73 uint32_t start_mask = (1u << start_bit) - 1; | 73 uint32_t start_mask = (1u << start_bit) - 1; |
| 74 uint32_t end_mask = ~((1u << end_bit) - 1); | 74 uint32_t end_mask = ~((1u << end_bit) - 1); |
| 75 if (start_bucket == end_bucket && start_cell == end_cell) { | 75 if (start_bucket == end_bucket && start_cell == end_cell && |
| 76 start_bucket < kBuckets) { | |
| 76 MaskCell(start_bucket, start_cell, start_mask | end_mask); | 77 MaskCell(start_bucket, start_cell, start_mask | end_mask); |
|
Michael Lippautz
2016/08/18 09:19:19
I would guess that the access in MaskCell is the p
| |
| 77 return; | 78 return; |
| 78 } | 79 } |
| 79 int current_bucket = start_bucket; | 80 int current_bucket = start_bucket; |
| 80 int current_cell = start_cell; | 81 int current_cell = start_cell; |
| 81 MaskCell(current_bucket, current_cell, start_mask); | 82 MaskCell(current_bucket, current_cell, start_mask); |
| 82 current_cell++; | 83 current_cell++; |
| 83 if (current_bucket < end_bucket) { | 84 if (current_bucket < end_bucket) { |
| 84 if (bucket[current_bucket] != nullptr) { | 85 if (bucket[current_bucket] != nullptr) { |
| 85 while (current_cell < kCellsPerBucket) { | 86 while (current_cell < kCellsPerBucket) { |
| 86 bucket[current_bucket][current_cell] = 0; | 87 bucket[current_bucket][current_cell] = 0; |
| 87 current_cell++; | 88 current_cell++; |
| 88 } | 89 } |
| 89 } | 90 } |
| 90 // The rest of the current bucket is cleared. | 91 // The rest of the current bucket is cleared. |
| 91 // Move on to the next bucket. | 92 // Move on to the next bucket. |
| 92 current_bucket++; | 93 current_bucket++; |
| 93 current_cell = 0; | 94 current_cell = 0; |
| 94 } | 95 } |
| 95 DCHECK(current_bucket == end_bucket || | 96 DCHECK(current_bucket == end_bucket || |
| 96 (current_bucket < end_bucket && current_cell == 0)); | 97 (current_bucket < end_bucket && current_cell == 0)); |
| 97 while (current_bucket < end_bucket) { | 98 while (current_bucket < end_bucket) { |
| 98 ReleaseBucket(current_bucket); | 99 ReleaseBucket(current_bucket); |
| 99 current_bucket++; | 100 current_bucket++; |
| 100 } | 101 } |
| 101 // All buckets between start_bucket and end_bucket are cleared. | 102 // All buckets between start_bucket and end_bucket are cleared. |
| 102 DCHECK(current_bucket == end_bucket && current_cell <= end_cell); | 103 DCHECK(current_bucket == end_bucket && current_cell <= end_cell); |
| 103 if (current_bucket == kBuckets || bucket[current_bucket] == nullptr) { | 104 if (current_bucket == kBuckets || (current_bucket < kBuckets && |
|
Michael Lippautz
2016/08/18 09:19:19
If you do above, then just add a comment that refe
| |
| 105 bucket[current_bucket] == nullptr)) { | |
| 104 return; | 106 return; |
| 105 } | 107 } |
| 106 while (current_cell < end_cell) { | 108 while (current_cell < end_cell) { |
| 107 bucket[current_bucket][current_cell] = 0; | 109 bucket[current_bucket][current_cell] = 0; |
| 108 current_cell++; | 110 current_cell++; |
| 109 } | 111 } |
| 110 // All cells between start_cell and end_cell are cleared. | 112 // All cells between start_cell and end_cell are cleared. |
| 111 DCHECK(current_bucket == end_bucket && current_cell == end_cell); | 113 DCHECK(current_bucket == end_bucket && current_cell == end_cell); |
| 112 MaskCell(end_bucket, end_cell, end_mask); | 114 if (end_bucket < kBuckets) { |
| 115 MaskCell(end_bucket, end_cell, end_mask); | |
| 116 } | |
| 113 } | 117 } |
| 114 | 118 |
| 115 // The slot offset specifies a slot at address page_start_ + slot_offset. | 119 // The slot offset specifies a slot at address page_start_ + slot_offset. |
| 116 bool Lookup(int slot_offset) { | 120 bool Lookup(int slot_offset) { |
| 117 int bucket_index, cell_index, bit_index; | 121 int bucket_index, cell_index, bit_index; |
| 118 SlotToIndices(slot_offset, &bucket_index, &cell_index, &bit_index); | 122 SlotToIndices(slot_offset, &bucket_index, &cell_index, &bit_index); |
| 119 if (bucket[bucket_index] != nullptr) { | 123 if (bucket[bucket_index] != nullptr) { |
| 120 uint32_t cell = bucket[bucket_index][cell_index]; | 124 uint32_t cell = bucket[bucket_index][cell_index]; |
| 121 return (cell & (1u << bit_index)) != 0; | 125 return (cell & (1u << bit_index)) != 0; |
| 122 } | 126 } |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 349 }; | 353 }; |
| 350 | 354 |
| 351 Address page_start_; | 355 Address page_start_; |
| 352 Chunk* chunk_; | 356 Chunk* chunk_; |
| 353 }; | 357 }; |
| 354 | 358 |
| 355 } // namespace internal | 359 } // namespace internal |
| 356 } // namespace v8 | 360 } // namespace v8 |
| 357 | 361 |
| 358 #endif // V8_SLOT_SET_H | 362 #endif // V8_SLOT_SET_H |
| OLD | NEW |