| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 USE(vm_limit); | 81 USE(vm_limit); |
| 82 DCHECK((reinterpret_cast<uintptr_t>(limit_) & kStoreBufferOverflowBit) != 0); | 82 DCHECK((reinterpret_cast<uintptr_t>(limit_) & kStoreBufferOverflowBit) != 0); |
| 83 DCHECK((reinterpret_cast<uintptr_t>(limit_ - 1) & kStoreBufferOverflowBit) == | 83 DCHECK((reinterpret_cast<uintptr_t>(limit_ - 1) & kStoreBufferOverflowBit) == |
| 84 0); | 84 0); |
| 85 | 85 |
| 86 if (!virtual_memory_->Commit(reinterpret_cast<Address>(start_), | 86 if (!virtual_memory_->Commit(reinterpret_cast<Address>(start_), |
| 87 kStoreBufferSize, | 87 kStoreBufferSize, |
| 88 false)) { // Not executable. | 88 false)) { // Not executable. |
| 89 V8::FatalProcessOutOfMemory("StoreBuffer::SetUp"); | 89 V8::FatalProcessOutOfMemory("StoreBuffer::SetUp"); |
| 90 } | 90 } |
| 91 heap_->public_set_store_buffer_top(start_); | 91 heap_->set_store_buffer_top(reinterpret_cast<Smi*>(start_)); |
| 92 | 92 |
| 93 hash_set_1_ = new uintptr_t[kHashSetLength]; | 93 hash_set_1_ = new uintptr_t[kHashSetLength]; |
| 94 hash_set_2_ = new uintptr_t[kHashSetLength]; | 94 hash_set_2_ = new uintptr_t[kHashSetLength]; |
| 95 hash_sets_are_empty_ = false; | 95 hash_sets_are_empty_ = false; |
| 96 | 96 |
| 97 ClearFilteringHashSets(); | 97 ClearFilteringHashSets(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 | 100 |
| 101 void StoreBuffer::TearDown() { | 101 void StoreBuffer::TearDown() { |
| 102 delete virtual_memory_; | 102 delete virtual_memory_; |
| 103 delete old_virtual_memory_; | 103 delete old_virtual_memory_; |
| 104 delete[] hash_set_1_; | 104 delete[] hash_set_1_; |
| 105 delete[] hash_set_2_; | 105 delete[] hash_set_2_; |
| 106 old_start_ = old_top_ = old_limit_ = old_reserved_limit_ = NULL; | 106 old_start_ = old_top_ = old_limit_ = old_reserved_limit_ = NULL; |
| 107 start_ = limit_ = NULL; | 107 start_ = limit_ = NULL; |
| 108 heap_->public_set_store_buffer_top(start_); | 108 heap_->set_store_buffer_top(reinterpret_cast<Smi*>(start_)); |
| 109 } | 109 } |
| 110 | 110 |
| 111 | 111 |
| 112 void StoreBuffer::StoreBufferOverflow(Isolate* isolate) { | 112 void StoreBuffer::StoreBufferOverflow(Isolate* isolate) { |
| 113 isolate->heap()->store_buffer()->Compact(); | 113 isolate->heap()->store_buffer()->Compact(); |
| 114 isolate->counters()->store_buffer_overflows()->Increment(); | 114 isolate->counters()->store_buffer_overflows()->Increment(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 | 117 |
| 118 bool StoreBuffer::SpaceAvailable(intptr_t space_needed) { | 118 bool StoreBuffer::SpaceAvailable(intptr_t space_needed) { |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 | 529 |
| 530 | 530 |
| 531 void StoreBuffer::Compact() { | 531 void StoreBuffer::Compact() { |
| 532 Address* top = reinterpret_cast<Address*>(heap_->store_buffer_top()); | 532 Address* top = reinterpret_cast<Address*>(heap_->store_buffer_top()); |
| 533 | 533 |
| 534 if (top == start_) return; | 534 if (top == start_) return; |
| 535 | 535 |
| 536 // There's no check of the limit in the loop below so we check here for | 536 // There's no check of the limit in the loop below so we check here for |
| 537 // the worst case (compaction doesn't eliminate any pointers). | 537 // the worst case (compaction doesn't eliminate any pointers). |
| 538 DCHECK(top <= limit_); | 538 DCHECK(top <= limit_); |
| 539 heap_->public_set_store_buffer_top(start_); | 539 heap_->set_store_buffer_top(reinterpret_cast<Smi*>(start_)); |
| 540 EnsureSpace(top - start_); | 540 EnsureSpace(top - start_); |
| 541 DCHECK(may_move_store_buffer_entries_); | 541 DCHECK(may_move_store_buffer_entries_); |
| 542 // Goes through the addresses in the store buffer attempting to remove | 542 // Goes through the addresses in the store buffer attempting to remove |
| 543 // duplicates. In the interest of speed this is a lossy operation. Some | 543 // duplicates. In the interest of speed this is a lossy operation. Some |
| 544 // duplicates will remain. We have two hash sets with different hash | 544 // duplicates will remain. We have two hash sets with different hash |
| 545 // functions to reduce the number of unnecessary clashes. | 545 // functions to reduce the number of unnecessary clashes. |
| 546 hash_sets_are_empty_ = false; // Hash sets are in use. | 546 hash_sets_are_empty_ = false; // Hash sets are in use. |
| 547 for (Address* current = start_; current < top; current++) { | 547 for (Address* current = start_; current < top; current++) { |
| 548 DCHECK(!heap_->code_space()->Contains(*current)); | 548 DCHECK(!heap_->code_space()->Contains(*current)); |
| 549 uintptr_t int_addr = reinterpret_cast<uintptr_t>(*current); | 549 uintptr_t int_addr = reinterpret_cast<uintptr_t>(*current); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 DCHECK(start_of_current_page_ != store_buffer_->Top()); | 624 DCHECK(start_of_current_page_ != store_buffer_->Top()); |
| 625 store_buffer_->SetTop(start_of_current_page_); | 625 store_buffer_->SetTop(start_of_current_page_); |
| 626 } | 626 } |
| 627 } else { | 627 } else { |
| 628 UNREACHABLE(); | 628 UNREACHABLE(); |
| 629 } | 629 } |
| 630 } | 630 } |
| 631 | 631 |
| 632 } // namespace internal | 632 } // namespace internal |
| 633 } // namespace v8 | 633 } // namespace v8 |
| OLD | NEW |