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

Side by Side Diff: src/heap/mark-compact-inl.h

Issue 2210493002: [heap] Jump over one word fillers in LiveObjectIterator (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: bail out for filler on last word Created 4 years, 4 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_MARK_COMPACT_INL_H_ 5 #ifndef V8_HEAP_MARK_COMPACT_INL_H_
6 #define V8_HEAP_MARK_COMPACT_INL_H_ 6 #define V8_HEAP_MARK_COMPACT_INL_H_
7 7
8 #include "src/heap/mark-compact.h" 8 #include "src/heap/mark-compact.h"
9 #include "src/heap/remembered-set.h" 9 #include "src/heap/remembered-set.h"
10 #include "src/isolate.h" 10 #include "src/isolate.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // Clear the first bit of the found object.. 141 // Clear the first bit of the found object..
142 current_cell_ &= ~(1u << trailing_zeros); 142 current_cell_ &= ~(1u << trailing_zeros);
143 143
144 uint32_t second_bit_index = 0; 144 uint32_t second_bit_index = 0;
145 if (trailing_zeros < Bitmap::kBitIndexMask) { 145 if (trailing_zeros < Bitmap::kBitIndexMask) {
146 second_bit_index = 1u << (trailing_zeros + 1); 146 second_bit_index = 1u << (trailing_zeros + 1);
147 } else { 147 } else {
148 second_bit_index = 0x1; 148 second_bit_index = 0x1;
149 // The overlapping case; there has to exist a cell after the current 149 // The overlapping case; there has to exist a cell after the current
150 // cell. 150 // cell.
151 DCHECK(!it_.Done()); 151 // However, if there is a black area at the end of the page, and the
152 // last word is a one word filler, we are not allowed to advance. In
153 // that case we can return immediately.
154 if (it_.Done()) {
155 DCHECK(HeapObject::FromAddress(addr)->map() ==
156 HeapObject::FromAddress(addr)
157 ->GetHeap()
158 ->one_pointer_filler_map());
159 return nullptr;
160 }
152 it_.Advance(); 161 it_.Advance();
153 cell_base_ = it_.CurrentCellBase(); 162 cell_base_ = it_.CurrentCellBase();
154 current_cell_ = *it_.CurrentCell(); 163 current_cell_ = *it_.CurrentCell();
155 } 164 }
156 165
157 if (current_cell_ & second_bit_index) { 166 if (current_cell_ & second_bit_index) {
158 // We found a black object. If the black object is within a black area, 167 // We found a black object. If the black object is within a black area,
159 // make sure that we skip all set bits in the black area until the 168 // make sure that we skip all set bits in the black area until the
160 // object ends. 169 // object ends.
161 HeapObject* black_object = HeapObject::FromAddress(addr); 170 HeapObject* black_object = HeapObject::FromAddress(addr);
162 Address end = addr + black_object->Size() - kPointerSize; 171 Address end = addr + black_object->Size() - kPointerSize;
163 DCHECK_EQ(chunk_, MemoryChunk::FromAddress(end)); 172 // One word filler objects do not borrow the second mark bit. We have
164 uint32_t end_mark_bit_index = chunk_->AddressToMarkbitIndex(end); 173 // to jump over the advancing and clearing part.
165 unsigned int end_cell_index = 174 // Note that we know that we are at a one word filler when
166 end_mark_bit_index >> Bitmap::kBitsPerCellLog2; 175 // object_start + object_size - kPointerSize == object_start.
167 MarkBit::CellType end_index_mask = 176 if (addr != end) {
168 1u << Bitmap::IndexInCell(end_mark_bit_index); 177 DCHECK_EQ(chunk_, MemoryChunk::FromAddress(end));
169 if (it_.Advance(end_cell_index)) { 178 uint32_t end_mark_bit_index = chunk_->AddressToMarkbitIndex(end);
170 cell_base_ = it_.CurrentCellBase(); 179 unsigned int end_cell_index =
171 current_cell_ = *it_.CurrentCell(); 180 end_mark_bit_index >> Bitmap::kBitsPerCellLog2;
181 MarkBit::CellType end_index_mask =
182 1u << Bitmap::IndexInCell(end_mark_bit_index);
183 if (it_.Advance(end_cell_index)) {
184 cell_base_ = it_.CurrentCellBase();
185 current_cell_ = *it_.CurrentCell();
186 }
187
188 // Clear all bits in current_cell, including the end index.
189 current_cell_ &= ~(end_index_mask + end_index_mask - 1);
172 } 190 }
173 191
174 // Clear all bits in current_cell, including the end index.
175 current_cell_ &= ~(end_index_mask + end_index_mask - 1);
176
177 if (T == kBlackObjects || T == kAllLiveObjects) { 192 if (T == kBlackObjects || T == kAllLiveObjects) {
178 object = black_object; 193 object = black_object;
179 } 194 }
180 } else if ((T == kGreyObjects || T == kAllLiveObjects)) { 195 } else if ((T == kGreyObjects || T == kAllLiveObjects)) {
181 object = HeapObject::FromAddress(addr); 196 object = HeapObject::FromAddress(addr);
182 } 197 }
183 198
184 // We found a live object. 199 // We found a live object.
185 if (object != nullptr) { 200 if (object != nullptr) {
186 if (object->IsFiller()) { 201 if (object->IsFiller()) {
(...skipping 15 matching lines...) Expand all
202 } 217 }
203 if (object != nullptr) return object; 218 if (object != nullptr) return object;
204 } 219 }
205 return nullptr; 220 return nullptr;
206 } 221 }
207 222
208 } // namespace internal 223 } // namespace internal
209 } // namespace v8 224 } // namespace v8
210 225
211 #endif // V8_HEAP_MARK_COMPACT_INL_H_ 226 #endif // V8_HEAP_MARK_COMPACT_INL_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698