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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 void StoreBuffer::GCEpilogue() { | 371 void StoreBuffer::GCEpilogue() { |
372 during_gc_ = false; | 372 during_gc_ = false; |
373 #ifdef VERIFY_HEAP | 373 #ifdef VERIFY_HEAP |
374 if (FLAG_verify_heap) { | 374 if (FLAG_verify_heap) { |
375 Verify(); | 375 Verify(); |
376 } | 376 } |
377 #endif | 377 #endif |
378 } | 378 } |
379 | 379 |
380 | 380 |
| 381 void StoreBuffer::ProcessOldToNewSlot(Address slot_address, |
| 382 ObjectSlotCallback slot_callback, |
| 383 bool clear_maps) { |
| 384 Object** slot = reinterpret_cast<Object**>(slot_address); |
| 385 Object* object = reinterpret_cast<Object*>( |
| 386 base::NoBarrier_Load(reinterpret_cast<base::AtomicWord*>(slot))); |
| 387 |
| 388 // If the object is not in from space, it must be a duplicate store buffer |
| 389 // entry and the slot was already updated. |
| 390 if (heap_->InFromSpace(object)) { |
| 391 HeapObject* heap_object = reinterpret_cast<HeapObject*>(object); |
| 392 DCHECK(heap_object->IsHeapObject()); |
| 393 // The new space object was not promoted if it still contains a map |
| 394 // pointer. Clear the map field now lazily (during full GC). |
| 395 if (clear_maps) ClearDeadObject(heap_object); |
| 396 slot_callback(reinterpret_cast<HeapObject**>(slot), heap_object); |
| 397 object = reinterpret_cast<Object*>( |
| 398 base::NoBarrier_Load(reinterpret_cast<base::AtomicWord*>(slot))); |
| 399 // If the object was in from space before and is after executing the |
| 400 // callback in to space, the object is still live. |
| 401 // Unfortunately, we do not know about the slot. It could be in a |
| 402 // just freed free space object. |
| 403 if (heap_->InToSpace(object)) { |
| 404 EnterDirectlyIntoStoreBuffer(reinterpret_cast<Address>(slot)); |
| 405 } |
| 406 } |
| 407 } |
| 408 |
| 409 |
381 void StoreBuffer::FindPointersToNewSpaceInRegion( | 410 void StoreBuffer::FindPointersToNewSpaceInRegion( |
382 Address start, Address end, ObjectSlotCallback slot_callback, | 411 Address start, Address end, ObjectSlotCallback slot_callback, |
383 bool clear_maps) { | 412 bool clear_maps) { |
384 for (Address slot_address = start; slot_address < end; | 413 for (Address slot_address = start; slot_address < end; |
385 slot_address += kPointerSize) { | 414 slot_address += kPointerSize) { |
386 Object** slot = reinterpret_cast<Object**>(slot_address); | 415 ProcessOldToNewSlot(slot_address, slot_callback, clear_maps); |
387 Object* object = reinterpret_cast<Object*>( | |
388 base::NoBarrier_Load(reinterpret_cast<base::AtomicWord*>(slot))); | |
389 if (heap_->InNewSpace(object)) { | |
390 HeapObject* heap_object = reinterpret_cast<HeapObject*>(object); | |
391 DCHECK(heap_object->IsHeapObject()); | |
392 // The new space object was not promoted if it still contains a map | |
393 // pointer. Clear the map field now lazily. | |
394 if (clear_maps) ClearDeadObject(heap_object); | |
395 slot_callback(reinterpret_cast<HeapObject**>(slot), heap_object); | |
396 object = reinterpret_cast<Object*>( | |
397 base::NoBarrier_Load(reinterpret_cast<base::AtomicWord*>(slot))); | |
398 if (heap_->InNewSpace(object)) { | |
399 EnterDirectlyIntoStoreBuffer(slot_address); | |
400 } | |
401 } | |
402 } | 416 } |
403 } | 417 } |
404 | 418 |
405 | 419 |
406 void StoreBuffer::IteratePointersInStoreBuffer(ObjectSlotCallback slot_callback, | 420 void StoreBuffer::IteratePointersInStoreBuffer(ObjectSlotCallback slot_callback, |
407 bool clear_maps) { | 421 bool clear_maps) { |
408 Address* limit = old_top_; | 422 Address* limit = old_top_; |
409 old_top_ = old_start_; | 423 old_top_ = old_start_; |
410 { | 424 { |
411 DontMoveStoreBufferEntriesScope scope(this); | 425 DontMoveStoreBufferEntriesScope scope(this); |
412 for (Address* current = old_start_; current < limit; current++) { | 426 for (Address* current = old_start_; current < limit; current++) { |
413 #ifdef DEBUG | 427 #ifdef DEBUG |
414 Address* saved_top = old_top_; | 428 Address* saved_top = old_top_; |
415 #endif | 429 #endif |
416 Object** slot = reinterpret_cast<Object**>(*current); | 430 ProcessOldToNewSlot(*current, slot_callback, clear_maps); |
417 Object* object = reinterpret_cast<Object*>( | |
418 base::NoBarrier_Load(reinterpret_cast<base::AtomicWord*>(slot))); | |
419 if (heap_->InFromSpace(object)) { | |
420 HeapObject* heap_object = reinterpret_cast<HeapObject*>(object); | |
421 // The new space object was not promoted if it still contains a map | |
422 // pointer. Clear the map field now lazily. | |
423 if (clear_maps) ClearDeadObject(heap_object); | |
424 slot_callback(reinterpret_cast<HeapObject**>(slot), heap_object); | |
425 object = reinterpret_cast<Object*>( | |
426 base::NoBarrier_Load(reinterpret_cast<base::AtomicWord*>(slot))); | |
427 if (heap_->InNewSpace(object)) { | |
428 EnterDirectlyIntoStoreBuffer(reinterpret_cast<Address>(slot)); | |
429 } | |
430 } | |
431 DCHECK(old_top_ == saved_top + 1 || old_top_ == saved_top); | 431 DCHECK(old_top_ == saved_top + 1 || old_top_ == saved_top); |
432 } | 432 } |
433 } | 433 } |
434 } | 434 } |
435 | 435 |
436 | 436 |
437 void StoreBuffer::IteratePointersToNewSpace(ObjectSlotCallback slot_callback) { | 437 void StoreBuffer::IteratePointersToNewSpace(ObjectSlotCallback slot_callback) { |
438 IteratePointersToNewSpace(slot_callback, false); | 438 IteratePointersToNewSpace(slot_callback, false); |
439 } | 439 } |
440 | 440 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 } | 612 } |
613 old_buffer_is_sorted_ = false; | 613 old_buffer_is_sorted_ = false; |
614 old_buffer_is_filtered_ = false; | 614 old_buffer_is_filtered_ = false; |
615 *old_top_++ = reinterpret_cast<Address>(int_addr << kPointerSizeLog2); | 615 *old_top_++ = reinterpret_cast<Address>(int_addr << kPointerSizeLog2); |
616 DCHECK(old_top_ <= old_limit_); | 616 DCHECK(old_top_ <= old_limit_); |
617 } | 617 } |
618 heap_->isolate()->counters()->store_buffer_compactions()->Increment(); | 618 heap_->isolate()->counters()->store_buffer_compactions()->Increment(); |
619 } | 619 } |
620 } | 620 } |
621 } // namespace v8::internal | 621 } // namespace v8::internal |
OLD | NEW |