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

Side by Side Diff: src/heap/store-buffer.cc

Issue 957273002: Remove slots that point to unboxed doubles from the StoreBuffer/SlotsBuffer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: StoreBuffer issue addressed Created 5 years, 9 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 #include <algorithm> 5 #include <algorithm>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/base/atomicops.h" 9 #include "src/base/atomicops.h"
10 #include "src/counters.h" 10 #include "src/counters.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } 240 }
241 } 241 }
242 old_top_ = new_top; 242 old_top_ = new_top;
243 243
244 // Filtering hash sets are inconsistent with the store buffer after this 244 // Filtering hash sets are inconsistent with the store buffer after this
245 // operation. 245 // operation.
246 ClearFilteringHashSets(); 246 ClearFilteringHashSets();
247 } 247 }
248 248
249 249
250 // Returns number of slots stored in the slots buffer.
Hannes Payer (out of office) 2015/03/03 09:48:53 store buffer
Igor Sheludko 2015/03/04 14:54:20 Done.
251 int StoreBuffer::SizeForTesting() {
Hannes Payer (out of office) 2015/03/03 09:48:53 Why is it called SizeForTesting? Why don't call it
Igor Sheludko 2015/03/04 14:54:19 Actually it doesn't make sense. Removed.
252 intptr_t size = old_top_ - old_start_;
253 size += reinterpret_cast<Address*>(heap_->store_buffer_top()) - start_;
254 DCHECK(size <= kStoreBufferSize);
255 return static_cast<int>(size / kPointerSize);
256 }
257
258
259 void StoreBuffer::RemoveSlots(Address start_address, Address end_address) {
Hannes Payer (out of office) 2015/03/03 09:48:53 How often do you think is this function called. If
Igor Sheludko 2015/03/04 14:54:20 Good point.
260 struct IsValueInRangePredicate {
261 Address start_address_;
262 Address end_address_;
263
264 IsValueInRangePredicate(Address start_address, Address end_address)
265 : start_address_(start_address), end_address_(end_address) {}
266
267 bool operator()(Address addr) {
268 return start_address_ <= addr && addr < end_address_;
269 }
270 };
271
272 IsValueInRangePredicate predicate(start_address, end_address);
273
274 {
275 Address* top = reinterpret_cast<Address*>(heap_->store_buffer_top());
276 Address* new_top = std::remove_if(start_, top, predicate);
277 heap_->public_set_store_buffer_top(new_top);
278 }
279
280 if (old_buffer_is_sorted_) {
281 Address* lower = std::lower_bound(old_start_, old_top_, start_address);
282 if (lower != old_top_) {
283 Address* upper = std::lower_bound(lower, old_top_, end_address);
284 // Remove [lower, upper) from the buffer.
285 if (upper == old_top_) {
286 old_top_ = lower;
287 } else {
288 Address* new_top = lower;
289 for (Address* p = upper; p < old_top_; p++) {
290 *new_top++ = *p;
291 }
292 old_top_ = new_top;
293 }
294 }
295 } else {
296 old_top_ = std::remove_if(old_start_, old_top_, predicate);
297 }
298 }
299
300
250 void StoreBuffer::SortUniq() { 301 void StoreBuffer::SortUniq() {
251 Compact(); 302 Compact();
252 if (old_buffer_is_sorted_) return; 303 if (old_buffer_is_sorted_) return;
253 std::sort(old_start_, old_top_); 304 std::sort(old_start_, old_top_);
254 Uniq(); 305 Uniq();
255 306
256 old_buffer_is_sorted_ = true; 307 old_buffer_is_sorted_ = true;
257 308
258 // Filtering hash sets are inconsistent with the store buffer after this 309 // Filtering hash sets are inconsistent with the store buffer after this
259 // operation. 310 // operation.
(...skipping 30 matching lines...) Expand all
290 ClearFilteringHashSets(); 341 ClearFilteringHashSets();
291 Uniq(); // Also removes things that no longer point to new space. 342 Uniq(); // Also removes things that no longer point to new space.
292 EnsureSpace(kStoreBufferSize / 2); 343 EnsureSpace(kStoreBufferSize / 2);
293 } 344 }
294 345
295 346
296 static Address* in_store_buffer_1_element_cache = NULL; 347 static Address* in_store_buffer_1_element_cache = NULL;
297 348
298 349
299 bool StoreBuffer::CellIsInStoreBuffer(Address cell_address) { 350 bool StoreBuffer::CellIsInStoreBuffer(Address cell_address) {
300 if (!FLAG_enable_slow_asserts) return true; 351 Address* top = reinterpret_cast<Address*>(heap_->store_buffer_top());
301 if (in_store_buffer_1_element_cache != NULL && 352 if (in_store_buffer_1_element_cache != NULL &&
302 *in_store_buffer_1_element_cache == cell_address) { 353 *in_store_buffer_1_element_cache == cell_address) {
303 return true; 354 // Check if the cache still points into the active part of the buffer.
355 if ((start_ <= in_store_buffer_1_element_cache &&
356 in_store_buffer_1_element_cache < top) ||
357 (old_start_ <= in_store_buffer_1_element_cache &&
358 in_store_buffer_1_element_cache < old_top_)) {
359 return true;
360 }
304 } 361 }
305 Address* top = reinterpret_cast<Address*>(heap_->store_buffer_top());
306 for (Address* current = top - 1; current >= start_; current--) { 362 for (Address* current = top - 1; current >= start_; current--) {
307 if (*current == cell_address) { 363 if (*current == cell_address) {
308 in_store_buffer_1_element_cache = current; 364 in_store_buffer_1_element_cache = current;
309 return true; 365 return true;
310 } 366 }
311 } 367 }
312 for (Address* current = old_top_ - 1; current >= old_start_; current--) { 368 for (Address* current = old_top_ - 1; current >= old_start_; current--) {
313 if (*current == cell_address) { 369 if (*current == cell_address) {
314 in_store_buffer_1_element_cache = current; 370 in_store_buffer_1_element_cache = current;
315 return true; 371 return true;
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 } 668 }
613 old_buffer_is_sorted_ = false; 669 old_buffer_is_sorted_ = false;
614 old_buffer_is_filtered_ = false; 670 old_buffer_is_filtered_ = false;
615 *old_top_++ = reinterpret_cast<Address>(int_addr << kPointerSizeLog2); 671 *old_top_++ = reinterpret_cast<Address>(int_addr << kPointerSizeLog2);
616 DCHECK(old_top_ <= old_limit_); 672 DCHECK(old_top_ <= old_limit_);
617 } 673 }
618 heap_->isolate()->counters()->store_buffer_compactions()->Increment(); 674 heap_->isolate()->counters()->store_buffer_compactions()->Increment();
619 } 675 }
620 } 676 }
621 } // namespace v8::internal 677 } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698