| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 0); | 77 0); |
| 78 | 78 |
| 79 virtual_memory_->Commit(reinterpret_cast<Address>(start_), | 79 virtual_memory_->Commit(reinterpret_cast<Address>(start_), |
| 80 kStoreBufferSize, | 80 kStoreBufferSize, |
| 81 false); // Not executable. | 81 false); // Not executable. |
| 82 heap_->public_set_store_buffer_top(start_); | 82 heap_->public_set_store_buffer_top(start_); |
| 83 | 83 |
| 84 hash_map_1_ = new uintptr_t[kHashMapLength]; | 84 hash_map_1_ = new uintptr_t[kHashMapLength]; |
| 85 hash_map_2_ = new uintptr_t[kHashMapLength]; | 85 hash_map_2_ = new uintptr_t[kHashMapLength]; |
| 86 | 86 |
| 87 heap_->AddGCPrologueCallback(&GCPrologue, kGCTypeAll); | |
| 88 heap_->AddGCEpilogueCallback(&GCEpilogue, kGCTypeAll); | |
| 89 | |
| 90 ZapHashTables(); | 87 ZapHashTables(); |
| 91 } | 88 } |
| 92 | 89 |
| 93 | 90 |
| 94 void StoreBuffer::TearDown() { | 91 void StoreBuffer::TearDown() { |
| 95 delete virtual_memory_; | 92 delete virtual_memory_; |
| 96 delete[] hash_map_1_; | 93 delete[] hash_map_1_; |
| 97 delete[] hash_map_2_; | 94 delete[] hash_map_2_; |
| 98 delete[] old_start_; | 95 delete[] old_start_; |
| 99 old_start_ = old_top_ = old_limit_ = NULL; | 96 old_start_ = old_top_ = old_limit_ = NULL; |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 151 |
| 155 | 152 |
| 156 void StoreBuffer::HandleFullness() { | 153 void StoreBuffer::HandleFullness() { |
| 157 if (old_buffer_is_filtered_) return; | 154 if (old_buffer_is_filtered_) return; |
| 158 ASSERT(may_move_store_buffer_entries_); | 155 ASSERT(may_move_store_buffer_entries_); |
| 159 Compact(); | 156 Compact(); |
| 160 | 157 |
| 161 old_buffer_is_filtered_ = true; | 158 old_buffer_is_filtered_ = true; |
| 162 bool page_has_scan_on_scavenge_flag = false; | 159 bool page_has_scan_on_scavenge_flag = false; |
| 163 | 160 |
| 164 PointerChunkIterator it; | 161 PointerChunkIterator it(heap_); |
| 165 MemoryChunk* chunk; | 162 MemoryChunk* chunk; |
| 166 while ((chunk = it.next()) != NULL) { | 163 while ((chunk = it.next()) != NULL) { |
| 167 if (chunk->scan_on_scavenge()) page_has_scan_on_scavenge_flag = true; | 164 if (chunk->scan_on_scavenge()) page_has_scan_on_scavenge_flag = true; |
| 168 } | 165 } |
| 169 | 166 |
| 170 if (page_has_scan_on_scavenge_flag) { | 167 if (page_has_scan_on_scavenge_flag) { |
| 171 Filter(MemoryChunk::SCAN_ON_SCAVENGE); | 168 Filter(MemoryChunk::SCAN_ON_SCAVENGE); |
| 172 } | 169 } |
| 173 | 170 |
| 174 // If filtering out the entries from scan_on_scavenge pages got us down to | 171 // If filtering out the entries from scan_on_scavenge pages got us down to |
| (...skipping 19 matching lines...) Expand all Loading... |
| 194 ASSERT(i != 0 || old_top_ == old_start_); | 191 ASSERT(i != 0 || old_top_ == old_start_); |
| 195 if (old_limit_ - old_top_ > old_top_ - old_start_) return; | 192 if (old_limit_ - old_top_ > old_top_ - old_start_) return; |
| 196 } | 193 } |
| 197 UNREACHABLE(); | 194 UNREACHABLE(); |
| 198 } | 195 } |
| 199 | 196 |
| 200 | 197 |
| 201 // Sample the store buffer to see if some pages are taking up a lot of space | 198 // Sample the store buffer to see if some pages are taking up a lot of space |
| 202 // in the store buffer. | 199 // in the store buffer. |
| 203 void StoreBuffer::ExemptPopularPages(int prime_sample_step, int threshold) { | 200 void StoreBuffer::ExemptPopularPages(int prime_sample_step, int threshold) { |
| 204 PointerChunkIterator it; | 201 PointerChunkIterator it(heap_); |
| 205 MemoryChunk* chunk; | 202 MemoryChunk* chunk; |
| 206 while ((chunk = it.next()) != NULL) { | 203 while ((chunk = it.next()) != NULL) { |
| 207 chunk->set_store_buffer_counter(0); | 204 chunk->set_store_buffer_counter(0); |
| 208 } | 205 } |
| 209 bool created_new_scan_on_scavenge_pages = false; | 206 bool created_new_scan_on_scavenge_pages = false; |
| 210 MemoryChunk* previous_chunk = NULL; | 207 MemoryChunk* previous_chunk = NULL; |
| 211 for (Address* p = old_start_; p < old_top_; p += prime_sample_step) { | 208 for (Address* p = old_start_; p < old_top_; p += prime_sample_step) { |
| 212 Address addr = *p; | 209 Address addr = *p; |
| 213 MemoryChunk* containing_chunk = NULL; | 210 MemoryChunk* containing_chunk = NULL; |
| 214 if (previous_chunk != NULL && previous_chunk->Contains(addr)) { | 211 if (previous_chunk != NULL && previous_chunk->Contains(addr)) { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 sizeof(*old_top_), | 257 sizeof(*old_top_), |
| 261 &CompareAddresses); | 258 &CompareAddresses); |
| 262 Uniq(); | 259 Uniq(); |
| 263 | 260 |
| 264 old_buffer_is_sorted_ = true; | 261 old_buffer_is_sorted_ = true; |
| 265 } | 262 } |
| 266 | 263 |
| 267 | 264 |
| 268 bool StoreBuffer::PrepareForIteration() { | 265 bool StoreBuffer::PrepareForIteration() { |
| 269 Compact(); | 266 Compact(); |
| 270 PointerChunkIterator it; | 267 PointerChunkIterator it(heap_); |
| 271 MemoryChunk* chunk; | 268 MemoryChunk* chunk; |
| 272 bool page_has_scan_on_scavenge_flag = false; | 269 bool page_has_scan_on_scavenge_flag = false; |
| 273 while ((chunk = it.next()) != NULL) { | 270 while ((chunk = it.next()) != NULL) { |
| 274 if (chunk->scan_on_scavenge()) page_has_scan_on_scavenge_flag = true; | 271 if (chunk->scan_on_scavenge()) page_has_scan_on_scavenge_flag = true; |
| 275 } | 272 } |
| 276 | 273 |
| 277 if (page_has_scan_on_scavenge_flag) { | 274 if (page_has_scan_on_scavenge_flag) { |
| 278 Filter(MemoryChunk::SCAN_ON_SCAVENGE); | 275 Filter(MemoryChunk::SCAN_ON_SCAVENGE); |
| 279 } | 276 } |
| 280 ZapHashTables(); | 277 ZapHashTables(); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 void StoreBuffer::ZapHashTables() { | 333 void StoreBuffer::ZapHashTables() { |
| 337 memset(reinterpret_cast<void*>(hash_map_1_), | 334 memset(reinterpret_cast<void*>(hash_map_1_), |
| 338 0, | 335 0, |
| 339 sizeof(uintptr_t) * kHashMapLength); | 336 sizeof(uintptr_t) * kHashMapLength); |
| 340 memset(reinterpret_cast<void*>(hash_map_2_), | 337 memset(reinterpret_cast<void*>(hash_map_2_), |
| 341 0, | 338 0, |
| 342 sizeof(uintptr_t) * kHashMapLength); | 339 sizeof(uintptr_t) * kHashMapLength); |
| 343 } | 340 } |
| 344 | 341 |
| 345 | 342 |
| 346 void StoreBuffer::GCPrologue(GCType type, GCCallbackFlags flags) { | 343 void StoreBuffer::GCPrologue() { |
| 347 // TODO(gc) ISOLATES MERGE | 344 ZapHashTables(); |
| 348 HEAP->store_buffer()->ZapHashTables(); | 345 during_gc_ = true; |
| 349 HEAP->store_buffer()->during_gc_ = true; | |
| 350 } | 346 } |
| 351 | 347 |
| 352 | 348 |
| 353 #ifdef DEBUG | 349 #ifdef DEBUG |
| 354 static void DummyScavengePointer(HeapObject** p, HeapObject* o) { | 350 static void DummyScavengePointer(HeapObject** p, HeapObject* o) { |
| 355 // Do nothing. | 351 // Do nothing. |
| 356 } | 352 } |
| 357 | 353 |
| 358 | 354 |
| 359 void StoreBuffer::VerifyPointers(PagedSpace* space, | 355 void StoreBuffer::VerifyPointers(PagedSpace* space, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 #ifdef DEBUG | 392 #ifdef DEBUG |
| 397 VerifyPointers(heap_->old_pointer_space(), | 393 VerifyPointers(heap_->old_pointer_space(), |
| 398 &StoreBuffer::FindPointersToNewSpaceInRegion); | 394 &StoreBuffer::FindPointersToNewSpaceInRegion); |
| 399 VerifyPointers(heap_->map_space(), | 395 VerifyPointers(heap_->map_space(), |
| 400 &StoreBuffer::FindPointersToNewSpaceInMapsRegion); | 396 &StoreBuffer::FindPointersToNewSpaceInMapsRegion); |
| 401 VerifyPointers(heap_->lo_space()); | 397 VerifyPointers(heap_->lo_space()); |
| 402 #endif | 398 #endif |
| 403 } | 399 } |
| 404 | 400 |
| 405 | 401 |
| 406 void StoreBuffer::GCEpilogue(GCType type, GCCallbackFlags flags) { | 402 void StoreBuffer::GCEpilogue() { |
| 407 // TODO(gc) ISOLATES MERGE | 403 during_gc_ = false; |
| 408 HEAP->store_buffer()->during_gc_ = false; | 404 Verify(); |
| 409 HEAP->store_buffer()->Verify(); | |
| 410 } | 405 } |
| 411 | 406 |
| 412 | 407 |
| 413 void StoreBuffer::FindPointersToNewSpaceInRegion( | 408 void StoreBuffer::FindPointersToNewSpaceInRegion( |
| 414 Address start, Address end, ObjectSlotCallback slot_callback) { | 409 Address start, Address end, ObjectSlotCallback slot_callback) { |
| 415 for (Address slot_address = start; | 410 for (Address slot_address = start; |
| 416 slot_address < end; | 411 slot_address < end; |
| 417 slot_address += kPointerSize) { | 412 slot_address += kPointerSize) { |
| 418 Object** slot = reinterpret_cast<Object**>(slot_address); | 413 Object** slot = reinterpret_cast<Object**>(slot_address); |
| 419 if (heap_->InNewSpace(*slot)) { | 414 if (heap_->InNewSpace(*slot)) { |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 // scan, the surviving pointers to new space will be added to the store | 592 // scan, the surviving pointers to new space will be added to the store |
| 598 // buffer. If there are still a lot of pointers to new space then we will | 593 // buffer. If there are still a lot of pointers to new space then we will |
| 599 // keep the scan_on_scavenge flag on the page and discard the pointers that | 594 // keep the scan_on_scavenge flag on the page and discard the pointers that |
| 600 // were added to the store buffer. If there are not many pointers to new | 595 // were added to the store buffer. If there are not many pointers to new |
| 601 // space left on the page we will keep the pointers in the store buffer and | 596 // space left on the page we will keep the pointers in the store buffer and |
| 602 // remove the flag from the page. | 597 // remove the flag from the page. |
| 603 if (some_pages_to_scan) { | 598 if (some_pages_to_scan) { |
| 604 if (callback_ != NULL) { | 599 if (callback_ != NULL) { |
| 605 (*callback_)(heap_, NULL, kStoreBufferStartScanningPagesEvent); | 600 (*callback_)(heap_, NULL, kStoreBufferStartScanningPagesEvent); |
| 606 } | 601 } |
| 607 PointerChunkIterator it; | 602 PointerChunkIterator it(heap_); |
| 608 MemoryChunk* chunk; | 603 MemoryChunk* chunk; |
| 609 while ((chunk = it.next()) != NULL) { | 604 while ((chunk = it.next()) != NULL) { |
| 610 if (chunk->scan_on_scavenge()) { | 605 if (chunk->scan_on_scavenge()) { |
| 611 chunk->set_scan_on_scavenge(false); | 606 chunk->set_scan_on_scavenge(false); |
| 612 if (callback_ != NULL) { | 607 if (callback_ != NULL) { |
| 613 (*callback_)(heap_, chunk, kStoreBufferScanningPageEvent); | 608 (*callback_)(heap_, chunk, kStoreBufferScanningPageEvent); |
| 614 } | 609 } |
| 615 if (chunk->owner() == heap_->lo_space()) { | 610 if (chunk->owner() == heap_->lo_space()) { |
| 616 LargePage* large_page = reinterpret_cast<LargePage*>(chunk); | 611 LargePage* large_page = reinterpret_cast<LargePage*>(chunk); |
| 617 HeapObject* array = large_page->GetObject(); | 612 HeapObject* array = large_page->GetObject(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 } | 685 } |
| 691 | 686 |
| 692 | 687 |
| 693 void StoreBuffer::CheckForFullBuffer() { | 688 void StoreBuffer::CheckForFullBuffer() { |
| 694 if (old_limit_ - old_top_ < kStoreBufferSize * 2) { | 689 if (old_limit_ - old_top_ < kStoreBufferSize * 2) { |
| 695 HandleFullness(); | 690 HandleFullness(); |
| 696 } | 691 } |
| 697 } | 692 } |
| 698 | 693 |
| 699 } } // namespace v8::internal | 694 } } // namespace v8::internal |
| OLD | NEW |