Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(552)

Side by Side Diff: src/heap/slot-set.h

Issue 1701963003: Filter invalid slots after array trimming. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix compile Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/remembered-set.h ('k') | test/cctest/heap/heap-tester.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 int start_bucket, start_cell, start_bit; 67 int start_bucket, start_cell, start_bit;
68 SlotToIndices(start_offset, &start_bucket, &start_cell, &start_bit); 68 SlotToIndices(start_offset, &start_bucket, &start_cell, &start_bit);
69 int end_bucket, end_cell, end_bit; 69 int end_bucket, end_cell, end_bit;
70 SlotToIndices(end_offset, &end_bucket, &end_cell, &end_bit); 70 SlotToIndices(end_offset, &end_bucket, &end_cell, &end_bit);
71 uint32_t start_mask = (1u << start_bit) - 1; 71 uint32_t start_mask = (1u << start_bit) - 1;
72 uint32_t end_mask = ~((1u << end_bit) - 1); 72 uint32_t end_mask = ~((1u << end_bit) - 1);
73 if (start_bucket == end_bucket && start_cell == end_cell) { 73 if (start_bucket == end_bucket && start_cell == end_cell) {
74 MaskCell(start_bucket, start_cell, start_mask | end_mask); 74 MaskCell(start_bucket, start_cell, start_mask | end_mask);
75 return; 75 return;
76 } 76 }
77 MaskCell(start_bucket, start_cell, start_mask); 77 int current_bucket = start_bucket;
78 start_cell++; 78 int current_cell = start_cell;
79 if (bucket[start_bucket] != nullptr && start_bucket < end_bucket) { 79 MaskCell(current_bucket, current_cell, start_mask);
80 while (start_cell < kCellsPerBucket) { 80 current_cell++;
81 bucket[start_bucket][start_cell] = 0; 81 if (current_bucket < end_bucket) {
82 start_cell++; 82 if (bucket[current_bucket] != nullptr) {
83 while (current_cell < kCellsPerBucket) {
84 bucket[current_bucket][current_cell] = 0;
85 current_cell++;
86 }
83 } 87 }
88 // The rest of the current bucket is cleared.
89 // Move on to the next bucket.
90 current_bucket++;
91 current_cell = 0;
84 } 92 }
85 while (start_bucket < end_bucket) { 93 DCHECK(current_bucket == end_bucket ||
86 delete[] bucket[start_bucket]; 94 (current_bucket < end_bucket && current_cell == 0));
87 bucket[start_bucket] = nullptr; 95 while (current_bucket < end_bucket) {
88 start_bucket++; 96 ReleaseBucket(current_bucket);
97 current_bucket++;
89 } 98 }
90 if (start_bucket < kBuckets && bucket[start_bucket] != nullptr) { 99 // All buckets between start_bucket and end_bucket are cleared.
91 while (start_cell < end_cell) { 100 DCHECK(current_bucket == end_bucket && current_cell <= end_cell);
92 bucket[start_bucket][start_cell] = 0; 101 if (current_bucket == kBuckets || bucket[current_bucket] == nullptr) {
93 start_cell++; 102 return;
94 }
95 } 103 }
96 if (end_bucket < kBuckets) { 104 while (current_cell < end_cell) {
97 MaskCell(end_bucket, end_cell, end_mask); 105 bucket[current_bucket][current_cell] = 0;
106 current_cell++;
98 } 107 }
108 // All cells between start_cell and end_cell are cleared.
109 DCHECK(current_bucket == end_bucket && current_cell == end_cell);
110 MaskCell(end_bucket, end_cell, end_mask);
99 } 111 }
100 112
101 // The slot offset specifies a slot at address page_start_ + slot_offset. 113 // The slot offset specifies a slot at address page_start_ + slot_offset.
102 bool Lookup(int slot_offset) { 114 bool Lookup(int slot_offset) {
103 int bucket_index, cell_index, bit_index; 115 int bucket_index, cell_index, bit_index;
104 SlotToIndices(slot_offset, &bucket_index, &cell_index, &bit_index); 116 SlotToIndices(slot_offset, &bucket_index, &cell_index, &bit_index);
105 if (bucket[bucket_index] != nullptr) { 117 if (bucket[bucket_index] != nullptr) {
106 uint32_t cell = bucket[bucket_index][cell_index]; 118 uint32_t cell = bucket[bucket_index][cell_index];
107 return (cell & (1u << bit_index)) != 0; 119 return (cell & (1u << bit_index)) != 0;
108 } 120 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } 210 }
199 211
200 uint32_t* bucket[kBuckets]; 212 uint32_t* bucket[kBuckets];
201 Address page_start_; 213 Address page_start_;
202 }; 214 };
203 215
204 } // namespace internal 216 } // namespace internal
205 } // namespace v8 217 } // namespace v8
206 218
207 #endif // V8_SLOT_SET_H 219 #endif // V8_SLOT_SET_H
OLDNEW
« no previous file with comments | « src/heap/remembered-set.h ('k') | test/cctest/heap/heap-tester.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698