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/counters.h" | 9 #include "src/counters.h" |
10 #include "src/heap/store-buffer-inl.h" | 10 #include "src/heap/store-buffer-inl.h" |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 } | 354 } |
355 } | 355 } |
356 } | 356 } |
357 | 357 |
358 | 358 |
359 void StoreBuffer::ClearInvalidStoreBufferEntries() { | 359 void StoreBuffer::ClearInvalidStoreBufferEntries() { |
360 Compact(); | 360 Compact(); |
361 Address* new_top = old_start_; | 361 Address* new_top = old_start_; |
362 for (Address* current = old_start_; current < old_top_; current++) { | 362 for (Address* current = old_start_; current < old_top_; current++) { |
363 Address addr = *current; | 363 Address addr = *current; |
364 Object** slot = reinterpret_cast<Object**>(*current); | 364 Object** slot = reinterpret_cast<Object**>(addr); |
365 Object* object = *slot; | 365 Object* object = *slot; |
366 if (heap_->InNewSpace(object)) { | 366 if (heap_->InNewSpace(object) && object->IsHeapObject()) { |
367 if (heap_->mark_compact_collector()->IsSlotInLiveObject( | 367 // If the target object is not black, the source slot must be part |
368 reinterpret_cast<HeapObject**>(slot), | 368 // of a non-black (dead) object. |
369 reinterpret_cast<HeapObject*>(object))) { | 369 HeapObject* heap_object = HeapObject::cast(object); |
| 370 if (Marking::IsBlack(Marking::MarkBitFrom(heap_object)) && |
| 371 heap_->mark_compact_collector()->IsSlotInLiveObject(addr)) { |
370 *new_top++ = addr; | 372 *new_top++ = addr; |
371 } | 373 } |
372 } | 374 } |
373 } | 375 } |
374 old_top_ = new_top; | 376 old_top_ = new_top; |
375 ClearFilteringHashSets(); | 377 ClearFilteringHashSets(); |
376 | 378 |
377 // Don't scan on scavenge dead large objects. | 379 // Don't scan on scavenge dead large objects. |
378 LargeObjectIterator it(heap_->lo_space()); | 380 LargeObjectIterator it(heap_->lo_space()); |
379 for (HeapObject* object = it.Next(); object != NULL; object = it.Next()) { | 381 for (HeapObject* object = it.Next(); object != NULL; object = it.Next()) { |
380 MemoryChunk* chunk = MemoryChunk::FromAddress(object->address()); | 382 MemoryChunk* chunk = MemoryChunk::FromAddress(object->address()); |
381 if (chunk->scan_on_scavenge() && !Marking::MarkBitFrom(object).Get()) { | 383 if (chunk->scan_on_scavenge() && !Marking::MarkBitFrom(object).Get()) { |
382 chunk->set_scan_on_scavenge(false); | 384 chunk->set_scan_on_scavenge(false); |
383 } | 385 } |
384 } | 386 } |
385 } | 387 } |
386 | 388 |
387 | 389 |
388 void StoreBuffer::VerifyValidStoreBufferEntries() { | 390 void StoreBuffer::VerifyValidStoreBufferEntries() { |
389 for (Address* current = old_start_; current < old_top_; current++) { | 391 for (Address* current = old_start_; current < old_top_; current++) { |
390 Object** slot = reinterpret_cast<Object**>(*current); | 392 Object** slot = reinterpret_cast<Object**>(*current); |
391 Object* object = *slot; | 393 Object* object = *slot; |
| 394 CHECK(object->IsHeapObject()); |
392 CHECK(heap_->InNewSpace(object)); | 395 CHECK(heap_->InNewSpace(object)); |
393 heap_->mark_compact_collector()->VerifyIsSlotInLiveObject( | 396 heap_->mark_compact_collector()->VerifyIsSlotInLiveObject( |
394 reinterpret_cast<HeapObject**>(slot), | 397 reinterpret_cast<Address>(slot), HeapObject::cast(object)); |
395 reinterpret_cast<HeapObject*>(object)); | |
396 } | 398 } |
397 } | 399 } |
398 | 400 |
399 | 401 |
400 void StoreBuffer::IteratePointersToNewSpace(ObjectSlotCallback slot_callback) { | 402 void StoreBuffer::IteratePointersToNewSpace(ObjectSlotCallback slot_callback) { |
401 // We do not sort or remove duplicated entries from the store buffer because | 403 // We do not sort or remove duplicated entries from the store buffer because |
402 // we expect that callback will rebuild the store buffer thus removing | 404 // we expect that callback will rebuild the store buffer thus removing |
403 // all duplicates and pointers to old space. | 405 // all duplicates and pointers to old space. |
404 bool some_pages_to_scan = PrepareForIteration(); | 406 bool some_pages_to_scan = PrepareForIteration(); |
405 | 407 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 } | 564 } |
563 old_buffer_is_sorted_ = false; | 565 old_buffer_is_sorted_ = false; |
564 old_buffer_is_filtered_ = false; | 566 old_buffer_is_filtered_ = false; |
565 *old_top_++ = reinterpret_cast<Address>(int_addr << kPointerSizeLog2); | 567 *old_top_++ = reinterpret_cast<Address>(int_addr << kPointerSizeLog2); |
566 DCHECK(old_top_ <= old_limit_); | 568 DCHECK(old_top_ <= old_limit_); |
567 } | 569 } |
568 heap_->isolate()->counters()->store_buffer_compactions()->Increment(); | 570 heap_->isolate()->counters()->store_buffer_compactions()->Increment(); |
569 } | 571 } |
570 } | 572 } |
571 } // namespace v8::internal | 573 } // namespace v8::internal |
OLD | NEW |