| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/base/atomicops.h" | 7 #include "src/base/atomicops.h" |
| 8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/compilation-cache.h" | 10 #include "src/compilation-cache.h" |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 | 767 |
| 768 int count = 0; | 768 int count = 0; |
| 769 int fragmentation = 0; | 769 int fragmentation = 0; |
| 770 int page_number = 0; | 770 int page_number = 0; |
| 771 int least_index = -1; | 771 int least_index = -1; |
| 772 | 772 |
| 773 PageIterator it(space); | 773 PageIterator it(space); |
| 774 while (it.has_next()) { | 774 while (it.has_next()) { |
| 775 Page* p = it.next(); | 775 Page* p = it.next(); |
| 776 if (p->NeverEvacuate()) continue; | 776 if (p->NeverEvacuate()) continue; |
| 777 if (p->IsFlagSet(Page::POPULAR_PAGE)) { |
| 778 // This page had slots buffer overflow on previous GC, skip it. |
| 779 p->ClearFlag(Page::POPULAR_PAGE); |
| 780 continue; |
| 781 } |
| 777 | 782 |
| 778 // Invariant: Evacuation candidates are just created when marking is | 783 // Invariant: Evacuation candidates are just created when marking is |
| 779 // started. At the end of a GC all evacuation candidates are cleared and | 784 // started. At the end of a GC all evacuation candidates are cleared and |
| 780 // their slot buffers are released. | 785 // their slot buffers are released. |
| 781 CHECK(!p->IsEvacuationCandidate()); | 786 CHECK(!p->IsEvacuationCandidate()); |
| 782 CHECK(p->slots_buffer() == NULL); | 787 CHECK(p->slots_buffer() == NULL); |
| 783 | 788 |
| 784 if (FLAG_stress_compaction) { | 789 if (FLAG_stress_compaction) { |
| 785 if (FLAG_manual_evacuation_candidates_selection) { | 790 if (FLAG_manual_evacuation_candidates_selection) { |
| 786 if (p->IsFlagSet(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING)) { | 791 if (p->IsFlagSet(MemoryChunk::FORCE_EVACUATION_CANDIDATE_FOR_TESTING)) { |
| (...skipping 3823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4610 success = SlotsBuffer::AddTo( | 4615 success = SlotsBuffer::AddTo( |
| 4611 &slots_buffer_allocator_, target_page->slots_buffer_address(), | 4616 &slots_buffer_allocator_, target_page->slots_buffer_address(), |
| 4612 SlotsBuffer::CODE_ENTRY_SLOT, rinfo->constant_pool_entry_address(), | 4617 SlotsBuffer::CODE_ENTRY_SLOT, rinfo->constant_pool_entry_address(), |
| 4613 SlotsBuffer::FAIL_ON_OVERFLOW); | 4618 SlotsBuffer::FAIL_ON_OVERFLOW); |
| 4614 } else { | 4619 } else { |
| 4615 success = SlotsBuffer::AddTo( | 4620 success = SlotsBuffer::AddTo( |
| 4616 &slots_buffer_allocator_, target_page->slots_buffer_address(), | 4621 &slots_buffer_allocator_, target_page->slots_buffer_address(), |
| 4617 SlotTypeForRMode(rmode), rinfo->pc(), SlotsBuffer::FAIL_ON_OVERFLOW); | 4622 SlotTypeForRMode(rmode), rinfo->pc(), SlotsBuffer::FAIL_ON_OVERFLOW); |
| 4618 } | 4623 } |
| 4619 if (!success) { | 4624 if (!success) { |
| 4620 EvictEvacuationCandidate(target_page); | 4625 EvictPopularEvacuationCandidate(target_page); |
| 4621 } | 4626 } |
| 4622 } | 4627 } |
| 4623 } | 4628 } |
| 4624 | 4629 |
| 4625 | 4630 |
| 4626 void MarkCompactCollector::EvictEvacuationCandidate(Page* page) { | 4631 void MarkCompactCollector::EvictPopularEvacuationCandidate(Page* page) { |
| 4627 if (FLAG_trace_fragmentation) { | 4632 if (FLAG_trace_fragmentation) { |
| 4628 PrintF("Page %p is too popular. Disabling evacuation.\n", | 4633 PrintF("Page %p is too popular. Disabling evacuation.\n", |
| 4629 reinterpret_cast<void*>(page)); | 4634 reinterpret_cast<void*>(page)); |
| 4630 } | 4635 } |
| 4631 | 4636 |
| 4632 isolate()->CountUsage(v8::Isolate::UseCounterFeature::kSlotsBufferOverflow); | 4637 isolate()->CountUsage(v8::Isolate::UseCounterFeature::kSlotsBufferOverflow); |
| 4633 | 4638 |
| 4634 // TODO(gc) If all evacuation candidates are too popular we | 4639 // TODO(gc) If all evacuation candidates are too popular we |
| 4635 // should stop slots recording entirely. | 4640 // should stop slots recording entirely. |
| 4636 page->ClearEvacuationCandidate(); | 4641 page->ClearEvacuationCandidate(); |
| 4637 | 4642 |
| 4643 DCHECK(!page->IsFlagSet(Page::POPULAR_PAGE)); |
| 4644 page->SetFlag(Page::POPULAR_PAGE); |
| 4645 |
| 4638 // We were not collecting slots on this page that point | 4646 // We were not collecting slots on this page that point |
| 4639 // to other evacuation candidates thus we have to | 4647 // to other evacuation candidates thus we have to |
| 4640 // rescan the page after evacuation to discover and update all | 4648 // rescan the page after evacuation to discover and update all |
| 4641 // pointers to evacuated objects. | 4649 // pointers to evacuated objects. |
| 4642 page->SetFlag(Page::RESCAN_ON_EVACUATION); | 4650 page->SetFlag(Page::RESCAN_ON_EVACUATION); |
| 4643 } | 4651 } |
| 4644 | 4652 |
| 4645 | 4653 |
| 4646 void MarkCompactCollector::RecordCodeEntrySlot(Address slot, Code* target) { | 4654 void MarkCompactCollector::RecordCodeEntrySlot(Address slot, Code* target) { |
| 4647 Page* target_page = Page::FromAddress(reinterpret_cast<Address>(target)); | 4655 Page* target_page = Page::FromAddress(reinterpret_cast<Address>(target)); |
| 4648 if (target_page->IsEvacuationCandidate() && | 4656 if (target_page->IsEvacuationCandidate() && |
| 4649 !ShouldSkipEvacuationSlotRecording(reinterpret_cast<Object**>(slot))) { | 4657 !ShouldSkipEvacuationSlotRecording(reinterpret_cast<Object**>(slot))) { |
| 4650 if (!SlotsBuffer::AddTo(&slots_buffer_allocator_, | 4658 if (!SlotsBuffer::AddTo(&slots_buffer_allocator_, |
| 4651 target_page->slots_buffer_address(), | 4659 target_page->slots_buffer_address(), |
| 4652 SlotsBuffer::CODE_ENTRY_SLOT, slot, | 4660 SlotsBuffer::CODE_ENTRY_SLOT, slot, |
| 4653 SlotsBuffer::FAIL_ON_OVERFLOW)) { | 4661 SlotsBuffer::FAIL_ON_OVERFLOW)) { |
| 4654 EvictEvacuationCandidate(target_page); | 4662 EvictPopularEvacuationCandidate(target_page); |
| 4655 } | 4663 } |
| 4656 } | 4664 } |
| 4657 } | 4665 } |
| 4658 | 4666 |
| 4659 | 4667 |
| 4660 void MarkCompactCollector::RecordCodeTargetPatch(Address pc, Code* target) { | 4668 void MarkCompactCollector::RecordCodeTargetPatch(Address pc, Code* target) { |
| 4661 DCHECK(heap()->gc_state() == Heap::MARK_COMPACT); | 4669 DCHECK(heap()->gc_state() == Heap::MARK_COMPACT); |
| 4662 if (is_compacting()) { | 4670 if (is_compacting()) { |
| 4663 Code* host = | 4671 Code* host = |
| 4664 isolate()->inner_pointer_to_code_cache()->GcSafeFindCodeForInnerPointer( | 4672 isolate()->inner_pointer_to_code_cache()->GcSafeFindCodeForInnerPointer( |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4731 SlotsBuffer* buffer = *buffer_address; | 4739 SlotsBuffer* buffer = *buffer_address; |
| 4732 while (buffer != NULL) { | 4740 while (buffer != NULL) { |
| 4733 SlotsBuffer* next_buffer = buffer->next(); | 4741 SlotsBuffer* next_buffer = buffer->next(); |
| 4734 DeallocateBuffer(buffer); | 4742 DeallocateBuffer(buffer); |
| 4735 buffer = next_buffer; | 4743 buffer = next_buffer; |
| 4736 } | 4744 } |
| 4737 *buffer_address = NULL; | 4745 *buffer_address = NULL; |
| 4738 } | 4746 } |
| 4739 } | 4747 } |
| 4740 } // namespace v8::internal | 4748 } // namespace v8::internal |
| OLD | NEW |