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 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
548 } | 548 } |
549 ASSERT(visitable_end == end_of_page); | 549 ASSERT(visitable_end == end_of_page); |
550 if (visitable_start != visitable_end) { | 550 if (visitable_start != visitable_end) { |
551 (this->*region_callback)(visitable_start, | 551 (this->*region_callback)(visitable_start, |
552 visitable_end, | 552 visitable_end, |
553 slot_callback); | 553 slot_callback); |
554 } | 554 } |
555 } | 555 } |
556 | 556 |
557 | 557 |
558 | 558 template<StoreBuffer::IterationMode mode> |
559 void StoreBuffer::IteratePointersToNewSpace(ObjectSlotCallback slot_callback) { | 559 void StoreBuffer::IteratePointersInStoreBuffer( |
560 // We do not sort or remove duplicated entries from the store buffer because | 560 ObjectSlotCallback slot_callback) { |
561 // we expect that callback will rebuild the store buffer thus removing | |
562 // all duplicates and pointers to old space. | |
563 bool some_pages_to_scan = PrepareForIteration(); | |
564 | |
565 Address* limit = old_top_; | 561 Address* limit = old_top_; |
566 old_top_ = old_start_; | 562 old_top_ = old_start_; |
567 { | 563 { |
568 DontMoveStoreBufferEntriesScope scope(this); | 564 DontMoveStoreBufferEntriesScope scope(this); |
569 for (Address* current = old_start_; current < limit; current++) { | 565 for (Address* current = old_start_; current < limit; current++) { |
570 #ifdef DEBUG | 566 #ifdef DEBUG |
571 Address* saved_top = old_top_; | 567 Address* saved_top = old_top_; |
572 #endif | 568 #endif |
573 Object** slot = reinterpret_cast<Object**>(*current); | 569 Object** slot = reinterpret_cast<Object**>(*current); |
570 | |
571 // TODO(gc): we want to skip slots on evacuation candidates | |
572 // but we can't simply figure that out from slot address | |
573 // because slot can belong to a large object. | |
Erik Corry
2011/06/20 20:41:26
Pity. I was looking forward to seeing how you wou
| |
574 | |
574 Object* object = *slot; | 575 Object* object = *slot; |
575 if (heap_->InFromSpace(object)) { | 576 if (heap_->InFromSpace(object)) { |
576 HeapObject* heap_object = reinterpret_cast<HeapObject*>(object); | 577 HeapObject* heap_object = reinterpret_cast<HeapObject*>(object); |
577 slot_callback(reinterpret_cast<HeapObject**>(slot), heap_object); | 578 slot_callback(reinterpret_cast<HeapObject**>(slot), heap_object); |
578 if (heap_->InNewSpace(*slot)) { | 579 if (heap_->InNewSpace(*slot)) { |
579 EnterDirectlyIntoStoreBuffer(reinterpret_cast<Address>(slot)); | 580 EnterDirectlyIntoStoreBuffer(reinterpret_cast<Address>(slot)); |
580 } | 581 } |
581 } | 582 } |
582 ASSERT(old_top_ == saved_top + 1 || old_top_ == saved_top); | 583 ASSERT(old_top_ == saved_top + 1 || old_top_ == saved_top); |
583 } | 584 } |
584 } | 585 } |
586 | |
Erik Corry
2011/06/20 20:41:26
Spurious blank line.
Vyacheslav Egorov (Chromium)
2011/06/21 11:44:48
Done.
| |
587 } | |
588 | |
589 | |
590 void StoreBuffer::IteratePointersToNewSpace(ObjectSlotCallback slot_callback, | |
591 IterationMode mode) { | |
592 // We do not sort or remove duplicated entries from the store buffer because | |
593 // we expect that callback will rebuild the store buffer thus removing | |
594 // all duplicates and pointers to old space. | |
595 bool some_pages_to_scan = PrepareForIteration(); | |
596 | |
597 if (mode == SKIP_SLOTS_IN_EVACUATION_CANDIDATES) { | |
598 IteratePointersInStoreBuffer<SKIP_SLOTS_IN_EVACUATION_CANDIDATES>( | |
599 slot_callback); | |
600 } else { | |
601 ASSERT(mode == VISIT_ALL_SLOTS); | |
602 IteratePointersInStoreBuffer<VISIT_ALL_SLOTS>(slot_callback); | |
603 } | |
604 | |
605 | |
585 // We are done scanning all the pointers that were in the store buffer, but | 606 // We are done scanning all the pointers that were in the store buffer, but |
586 // there may be some pages marked scan_on_scavenge that have pointers to new | 607 // there may be some pages marked scan_on_scavenge that have pointers to new |
587 // space that are not in the store buffer. We must scan them now. As we | 608 // space that are not in the store buffer. We must scan them now. As we |
588 // scan, the surviving pointers to new space will be added to the store | 609 // scan, the surviving pointers to new space will be added to the store |
589 // buffer. If there are still a lot of pointers to new space then we will | 610 // buffer. If there are still a lot of pointers to new space then we will |
590 // keep the scan_on_scavenge flag on the page and discard the pointers that | 611 // keep the scan_on_scavenge flag on the page and discard the pointers that |
591 // were added to the store buffer. If there are not many pointers to new | 612 // were added to the store buffer. If there are not many pointers to new |
592 // space left on the page we will keep the pointers in the store buffer and | 613 // space left on the page we will keep the pointers in the store buffer and |
593 // remove the flag from the page. | 614 // remove the flag from the page. |
594 if (some_pages_to_scan) { | 615 if (some_pages_to_scan) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
678 } | 699 } |
679 | 700 |
680 | 701 |
681 void StoreBuffer::CheckForFullBuffer() { | 702 void StoreBuffer::CheckForFullBuffer() { |
682 if (old_limit_ - old_top_ < kStoreBufferSize * 2) { | 703 if (old_limit_ - old_top_ < kStoreBufferSize * 2) { |
683 HandleFullness(); | 704 HandleFullness(); |
684 } | 705 } |
685 } | 706 } |
686 | 707 |
687 } } // namespace v8::internal | 708 } } // namespace v8::internal |
OLD | NEW |