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 <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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 // Don't know the alignment requirements of the OS, but it is certainly not | 48 // Don't know the alignment requirements of the OS, but it is certainly not |
49 // less than 0xfff. | 49 // less than 0xfff. |
50 DCHECK((reinterpret_cast<uintptr_t>(old_start_) & 0xfff) == 0); | 50 DCHECK((reinterpret_cast<uintptr_t>(old_start_) & 0xfff) == 0); |
51 int initial_length = | 51 int initial_length = |
52 static_cast<int>(base::OS::CommitPageSize() / kPointerSize); | 52 static_cast<int>(base::OS::CommitPageSize() / kPointerSize); |
53 DCHECK(initial_length > 0); | 53 DCHECK(initial_length > 0); |
54 DCHECK(initial_length <= kOldStoreBufferLength); | 54 DCHECK(initial_length <= kOldStoreBufferLength); |
55 old_limit_ = old_start_ + initial_length; | 55 old_limit_ = old_start_ + initial_length; |
56 old_reserved_limit_ = old_start_ + kOldStoreBufferLength; | 56 old_reserved_limit_ = old_start_ + kOldStoreBufferLength; |
57 | 57 |
58 CHECK(old_virtual_memory_->Commit(reinterpret_cast<void*>(old_start_), | 58 if (!old_virtual_memory_->Commit(reinterpret_cast<void*>(old_start_), |
59 (old_limit_ - old_start_) * kPointerSize, | 59 (old_limit_ - old_start_) * kPointerSize, |
60 false)); | 60 false)) { |
| 61 V8::FatalProcessOutOfMemory("StoreBuffer::SetUp"); |
| 62 } |
61 | 63 |
62 DCHECK(reinterpret_cast<Address>(start_) >= virtual_memory_->address()); | 64 DCHECK(reinterpret_cast<Address>(start_) >= virtual_memory_->address()); |
63 DCHECK(reinterpret_cast<Address>(limit_) >= virtual_memory_->address()); | 65 DCHECK(reinterpret_cast<Address>(limit_) >= virtual_memory_->address()); |
64 Address* vm_limit = reinterpret_cast<Address*>( | 66 Address* vm_limit = reinterpret_cast<Address*>( |
65 reinterpret_cast<char*>(virtual_memory_->address()) + | 67 reinterpret_cast<char*>(virtual_memory_->address()) + |
66 virtual_memory_->size()); | 68 virtual_memory_->size()); |
67 DCHECK(start_ <= vm_limit); | 69 DCHECK(start_ <= vm_limit); |
68 DCHECK(limit_ <= vm_limit); | 70 DCHECK(limit_ <= vm_limit); |
69 USE(vm_limit); | 71 USE(vm_limit); |
70 DCHECK((reinterpret_cast<uintptr_t>(limit_) & kStoreBufferOverflowBit) != 0); | 72 DCHECK((reinterpret_cast<uintptr_t>(limit_) & kStoreBufferOverflowBit) != 0); |
71 DCHECK((reinterpret_cast<uintptr_t>(limit_ - 1) & kStoreBufferOverflowBit) == | 73 DCHECK((reinterpret_cast<uintptr_t>(limit_ - 1) & kStoreBufferOverflowBit) == |
72 0); | 74 0); |
73 | 75 |
74 CHECK(virtual_memory_->Commit(reinterpret_cast<Address>(start_), | 76 if (!virtual_memory_->Commit(reinterpret_cast<Address>(start_), |
75 kStoreBufferSize, | 77 kStoreBufferSize, |
76 false)); // Not executable. | 78 false)) { // Not executable. |
| 79 V8::FatalProcessOutOfMemory("StoreBuffer::SetUp"); |
| 80 } |
77 heap_->public_set_store_buffer_top(start_); | 81 heap_->public_set_store_buffer_top(start_); |
78 | 82 |
79 hash_set_1_ = new uintptr_t[kHashSetLength]; | 83 hash_set_1_ = new uintptr_t[kHashSetLength]; |
80 hash_set_2_ = new uintptr_t[kHashSetLength]; | 84 hash_set_2_ = new uintptr_t[kHashSetLength]; |
81 hash_sets_are_empty_ = false; | 85 hash_sets_are_empty_ = false; |
82 | 86 |
83 ClearFilteringHashSets(); | 87 ClearFilteringHashSets(); |
84 | 88 |
85 heap_->isolate()->set_store_buffer_hash_set_1_address(hash_set_1_); | 89 heap_->isolate()->set_store_buffer_hash_set_1_address(hash_set_1_); |
86 heap_->isolate()->set_store_buffer_hash_set_2_address(hash_set_2_); | 90 heap_->isolate()->set_store_buffer_hash_set_2_address(hash_set_2_); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 130 |
127 bool StoreBuffer::SpaceAvailable(intptr_t space_needed) { | 131 bool StoreBuffer::SpaceAvailable(intptr_t space_needed) { |
128 return old_limit_ - old_top_ >= space_needed; | 132 return old_limit_ - old_top_ >= space_needed; |
129 } | 133 } |
130 | 134 |
131 | 135 |
132 void StoreBuffer::EnsureSpace(intptr_t space_needed) { | 136 void StoreBuffer::EnsureSpace(intptr_t space_needed) { |
133 while (old_limit_ - old_top_ < space_needed && | 137 while (old_limit_ - old_top_ < space_needed && |
134 old_limit_ < old_reserved_limit_) { | 138 old_limit_ < old_reserved_limit_) { |
135 size_t grow = old_limit_ - old_start_; // Double size. | 139 size_t grow = old_limit_ - old_start_; // Double size. |
136 CHECK(old_virtual_memory_->Commit(reinterpret_cast<void*>(old_limit_), | 140 if (!old_virtual_memory_->Commit(reinterpret_cast<void*>(old_limit_), |
137 grow * kPointerSize, false)); | 141 grow * kPointerSize, false)) { |
| 142 V8::FatalProcessOutOfMemory("StoreBuffer::EnsureSpace"); |
| 143 } |
138 old_limit_ += grow; | 144 old_limit_ += grow; |
139 } | 145 } |
140 | 146 |
141 if (SpaceAvailable(space_needed)) return; | 147 if (SpaceAvailable(space_needed)) return; |
142 | 148 |
143 if (old_buffer_is_filtered_) return; | 149 if (old_buffer_is_filtered_) return; |
144 DCHECK(may_move_store_buffer_entries_); | 150 DCHECK(may_move_store_buffer_entries_); |
145 Compact(); | 151 Compact(); |
146 | 152 |
147 old_buffer_is_filtered_ = true; | 153 old_buffer_is_filtered_ = true; |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 } | 612 } |
607 old_buffer_is_sorted_ = false; | 613 old_buffer_is_sorted_ = false; |
608 old_buffer_is_filtered_ = false; | 614 old_buffer_is_filtered_ = false; |
609 *old_top_++ = reinterpret_cast<Address>(int_addr << kPointerSizeLog2); | 615 *old_top_++ = reinterpret_cast<Address>(int_addr << kPointerSizeLog2); |
610 DCHECK(old_top_ <= old_limit_); | 616 DCHECK(old_top_ <= old_limit_); |
611 } | 617 } |
612 heap_->isolate()->counters()->store_buffer_compactions()->Increment(); | 618 heap_->isolate()->counters()->store_buffer_compactions()->Increment(); |
613 } | 619 } |
614 } | 620 } |
615 } // namespace v8::internal | 621 } // namespace v8::internal |
OLD | NEW |