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/incremental-marking.h" | 10 #include "src/heap/incremental-marking.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 DCHECK(i != (kSampleFinenesses - 1) || old_top_ == old_start_); | 175 DCHECK(i != (kSampleFinenesses - 1) || old_top_ == old_start_); |
176 if (SpaceAvailable(space_needed)) return; | 176 if (SpaceAvailable(space_needed)) return; |
177 } | 177 } |
178 UNREACHABLE(); | 178 UNREACHABLE(); |
179 } | 179 } |
180 | 180 |
181 | 181 |
182 // Sample the store buffer to see if some pages are taking up a lot of space | 182 // Sample the store buffer to see if some pages are taking up a lot of space |
183 // in the store buffer. | 183 // in the store buffer. |
184 void StoreBuffer::ExemptPopularPages(int prime_sample_step, int threshold) { | 184 void StoreBuffer::ExemptPopularPages(int prime_sample_step, int threshold) { |
185 PointerChunkIterator it(heap_); | 185 HashMap store_buffer_counts(HashMap::PointersMatch, 16); |
186 MemoryChunk* chunk; | |
187 while ((chunk = it.next()) != NULL) { | |
188 chunk->set_store_buffer_counter(0); | |
189 } | |
190 bool created_new_scan_on_scavenge_pages = false; | 186 bool created_new_scan_on_scavenge_pages = false; |
191 MemoryChunk* previous_chunk = NULL; | 187 MemoryChunk* previous_chunk = NULL; |
192 for (Address* p = old_start_; p < old_top_; p += prime_sample_step) { | 188 for (Address* p = old_start_; p < old_top_; p += prime_sample_step) { |
193 Address addr = *p; | 189 Address addr = *p; |
194 MemoryChunk* containing_chunk = NULL; | 190 MemoryChunk* containing_chunk = NULL; |
195 if (previous_chunk != NULL && previous_chunk->Contains(addr)) { | 191 if (previous_chunk != NULL && previous_chunk->Contains(addr)) { |
196 containing_chunk = previous_chunk; | 192 containing_chunk = previous_chunk; |
197 } else { | 193 } else { |
198 containing_chunk = MemoryChunk::FromAnyPointerAddress(heap_, addr); | 194 containing_chunk = MemoryChunk::FromAnyPointerAddress(heap_, addr); |
199 } | 195 } |
200 int old_counter = containing_chunk->store_buffer_counter(); | 196 HashMap::Entry* e = store_buffer_counts.LookupOrInsert( |
| 197 containing_chunk, |
| 198 static_cast<uint32_t>(reinterpret_cast<uintptr_t>(containing_chunk) >> |
| 199 kPageSizeBits)); |
| 200 intptr_t old_counter = bit_cast<intptr_t>(e->value); |
201 if (old_counter >= threshold) { | 201 if (old_counter >= threshold) { |
202 containing_chunk->set_scan_on_scavenge(true); | 202 containing_chunk->set_scan_on_scavenge(true); |
203 created_new_scan_on_scavenge_pages = true; | 203 created_new_scan_on_scavenge_pages = true; |
204 } | 204 } |
205 containing_chunk->set_store_buffer_counter(old_counter + 1); | 205 (*bit_cast<intptr_t*>(&e->value))++; |
206 previous_chunk = containing_chunk; | 206 previous_chunk = containing_chunk; |
207 } | 207 } |
208 if (created_new_scan_on_scavenge_pages) { | 208 if (created_new_scan_on_scavenge_pages) { |
209 Filter(MemoryChunk::SCAN_ON_SCAVENGE); | 209 Filter(MemoryChunk::SCAN_ON_SCAVENGE); |
210 heap_->isolate()->CountUsage( | 210 heap_->isolate()->CountUsage( |
211 v8::Isolate::UseCounterFeature::kStoreBufferOverflow); | 211 v8::Isolate::UseCounterFeature::kStoreBufferOverflow); |
212 } | 212 } |
213 old_buffer_is_filtered_ = true; | 213 old_buffer_is_filtered_ = true; |
214 } | 214 } |
215 | 215 |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 DCHECK(start_of_current_page_ != store_buffer_->Top()); | 615 DCHECK(start_of_current_page_ != store_buffer_->Top()); |
616 store_buffer_->SetTop(start_of_current_page_); | 616 store_buffer_->SetTop(start_of_current_page_); |
617 } | 617 } |
618 } else { | 618 } else { |
619 UNREACHABLE(); | 619 UNREACHABLE(); |
620 } | 620 } |
621 } | 621 } |
622 | 622 |
623 } // namespace internal | 623 } // namespace internal |
624 } // namespace v8 | 624 } // namespace v8 |
OLD | NEW |