OLD | NEW |
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 "src/heap/store-buffer.h" | 5 #include "src/heap/store-buffer.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "src/counters.h" | 9 #include "src/counters.h" |
10 #include "src/heap/store-buffer-inl.h" | 10 #include "src/heap/store-buffer-inl.h" |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 hash_set_1_[hash1] = int_addr; | 571 hash_set_1_[hash1] = int_addr; |
572 hash_set_2_[hash2] = 0; | 572 hash_set_2_[hash2] = 0; |
573 } | 573 } |
574 old_buffer_is_sorted_ = false; | 574 old_buffer_is_sorted_ = false; |
575 old_buffer_is_filtered_ = false; | 575 old_buffer_is_filtered_ = false; |
576 *old_top_++ = reinterpret_cast<Address>(int_addr << kPointerSizeLog2); | 576 *old_top_++ = reinterpret_cast<Address>(int_addr << kPointerSizeLog2); |
577 DCHECK(old_top_ <= old_limit_); | 577 DCHECK(old_top_ <= old_limit_); |
578 } | 578 } |
579 heap_->isolate()->counters()->store_buffer_compactions()->Increment(); | 579 heap_->isolate()->counters()->store_buffer_compactions()->Increment(); |
580 } | 580 } |
| 581 |
| 582 |
| 583 void StoreBufferRebuilder::Callback(MemoryChunk* page, StoreBufferEvent event) { |
| 584 if (event == kStoreBufferStartScanningPagesEvent) { |
| 585 start_of_current_page_ = NULL; |
| 586 current_page_ = NULL; |
| 587 } else if (event == kStoreBufferScanningPageEvent) { |
| 588 if (current_page_ != NULL) { |
| 589 // If this page already overflowed the store buffer during this iteration. |
| 590 if (current_page_->scan_on_scavenge()) { |
| 591 // Then we should wipe out the entries that have been added for it. |
| 592 store_buffer_->SetTop(start_of_current_page_); |
| 593 } else if (store_buffer_->Top() - start_of_current_page_ >= |
| 594 (store_buffer_->Limit() - store_buffer_->Top()) >> 2) { |
| 595 // Did we find too many pointers in the previous page? The heuristic is |
| 596 // that no page can take more then 1/5 the remaining slots in the store |
| 597 // buffer. |
| 598 current_page_->set_scan_on_scavenge(true); |
| 599 store_buffer_->SetTop(start_of_current_page_); |
| 600 } else { |
| 601 // In this case the page we scanned took a reasonable number of slots in |
| 602 // the store buffer. It has now been rehabilitated and is no longer |
| 603 // marked scan_on_scavenge. |
| 604 DCHECK(!current_page_->scan_on_scavenge()); |
| 605 } |
| 606 } |
| 607 start_of_current_page_ = store_buffer_->Top(); |
| 608 current_page_ = page; |
| 609 } else if (event == kStoreBufferFullEvent) { |
| 610 // The current page overflowed the store buffer again. Wipe out its entries |
| 611 // in the store buffer and mark it scan-on-scavenge again. This may happen |
| 612 // several times while scanning. |
| 613 if (current_page_ == NULL) { |
| 614 // Store Buffer overflowed while scanning promoted objects. These are not |
| 615 // in any particular page, though they are likely to be clustered by the |
| 616 // allocation routines. |
| 617 store_buffer_->EnsureSpace(StoreBuffer::kStoreBufferSize / 2); |
| 618 } else { |
| 619 // Store Buffer overflowed while scanning a particular old space page for |
| 620 // pointers to new space. |
| 621 DCHECK(current_page_ == page); |
| 622 DCHECK(page != NULL); |
| 623 current_page_->set_scan_on_scavenge(true); |
| 624 DCHECK(start_of_current_page_ != store_buffer_->Top()); |
| 625 store_buffer_->SetTop(start_of_current_page_); |
| 626 } |
| 627 } else { |
| 628 UNREACHABLE(); |
| 629 } |
| 630 } |
| 631 |
581 } // namespace internal | 632 } // namespace internal |
582 } // namespace v8 | 633 } // namespace v8 |
OLD | NEW |