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 2014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2025 } | 2025 } |
2026 } | 2026 } |
2027 | 2027 |
2028 | 2028 |
2029 // Sweep the heap for overflowed objects, clear their overflow bits, and | 2029 // Sweep the heap for overflowed objects, clear their overflow bits, and |
2030 // push them on the marking stack. Stop early if the marking stack fills | 2030 // push them on the marking stack. Stop early if the marking stack fills |
2031 // before sweeping completes. If sweeping completes, there are no remaining | 2031 // before sweeping completes. If sweeping completes, there are no remaining |
2032 // overflowed objects in the heap so the overflow flag on the markings stack | 2032 // overflowed objects in the heap so the overflow flag on the markings stack |
2033 // is cleared. | 2033 // is cleared. |
2034 void MarkCompactCollector::RefillMarkingDeque() { | 2034 void MarkCompactCollector::RefillMarkingDeque() { |
2035 isolate()->CountUsage(v8::Isolate::UseCounterFeature::kMarkDequeOverflow); | |
2036 DCHECK(marking_deque_.overflowed()); | 2035 DCHECK(marking_deque_.overflowed()); |
2037 | 2036 |
2038 DiscoverGreyObjectsInNewSpace(heap(), &marking_deque_); | 2037 DiscoverGreyObjectsInNewSpace(heap(), &marking_deque_); |
2039 if (marking_deque_.IsFull()) return; | 2038 if (marking_deque_.IsFull()) return; |
2040 | 2039 |
2041 DiscoverGreyObjectsInSpace(heap(), &marking_deque_, | 2040 DiscoverGreyObjectsInSpace(heap(), &marking_deque_, |
2042 heap()->old_pointer_space()); | 2041 heap()->old_pointer_space()); |
2043 if (marking_deque_.IsFull()) return; | 2042 if (marking_deque_.IsFull()) return; |
2044 | 2043 |
2045 DiscoverGreyObjectsInSpace(heap(), &marking_deque_, heap()->old_data_space()); | 2044 DiscoverGreyObjectsInSpace(heap(), &marking_deque_, heap()->old_data_space()); |
(...skipping 2456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4502 &slots_buffer_allocator_, target_page->slots_buffer_address(), | 4501 &slots_buffer_allocator_, target_page->slots_buffer_address(), |
4503 SlotTypeForRMode(rmode), rinfo->pc(), SlotsBuffer::FAIL_ON_OVERFLOW); | 4502 SlotTypeForRMode(rmode), rinfo->pc(), SlotsBuffer::FAIL_ON_OVERFLOW); |
4504 } | 4503 } |
4505 if (!success) { | 4504 if (!success) { |
4506 EvictEvacuationCandidate(target_page); | 4505 EvictEvacuationCandidate(target_page); |
4507 } | 4506 } |
4508 } | 4507 } |
4509 } | 4508 } |
4510 | 4509 |
4511 | 4510 |
4512 void MarkCompactCollector::EvictEvacuationCandidate(Page* page) { | |
4513 if (FLAG_trace_fragmentation) { | |
4514 PrintF("Page %p is too popular. Disabling evacuation.\n", | |
4515 reinterpret_cast<void*>(page)); | |
4516 } | |
4517 | |
4518 isolate()->CountUsage(v8::Isolate::UseCounterFeature::kSlotsBufferOverflow); | |
4519 | |
4520 // TODO(gc) If all evacuation candidates are too popular we | |
4521 // should stop slots recording entirely. | |
4522 page->ClearEvacuationCandidate(); | |
4523 | |
4524 // We were not collecting slots on this page that point | |
4525 // to other evacuation candidates thus we have to | |
4526 // rescan the page after evacuation to discover and update all | |
4527 // pointers to evacuated objects. | |
4528 if (page->owner()->identity() == OLD_DATA_SPACE) { | |
4529 evacuation_candidates_.RemoveElement(page); | |
4530 } else { | |
4531 page->SetFlag(Page::RESCAN_ON_EVACUATION); | |
4532 } | |
4533 } | |
4534 | |
4535 | |
4536 void MarkCompactCollector::RecordCodeEntrySlot(Address slot, Code* target) { | 4511 void MarkCompactCollector::RecordCodeEntrySlot(Address slot, Code* target) { |
4537 Page* target_page = Page::FromAddress(reinterpret_cast<Address>(target)); | 4512 Page* target_page = Page::FromAddress(reinterpret_cast<Address>(target)); |
4538 if (target_page->IsEvacuationCandidate() && | 4513 if (target_page->IsEvacuationCandidate() && |
4539 !ShouldSkipEvacuationSlotRecording(reinterpret_cast<Object**>(slot))) { | 4514 !ShouldSkipEvacuationSlotRecording(reinterpret_cast<Object**>(slot))) { |
4540 if (!SlotsBuffer::AddTo(&slots_buffer_allocator_, | 4515 if (!SlotsBuffer::AddTo(&slots_buffer_allocator_, |
4541 target_page->slots_buffer_address(), | 4516 target_page->slots_buffer_address(), |
4542 SlotsBuffer::CODE_ENTRY_SLOT, slot, | 4517 SlotsBuffer::CODE_ENTRY_SLOT, slot, |
4543 SlotsBuffer::FAIL_ON_OVERFLOW)) { | 4518 SlotsBuffer::FAIL_ON_OVERFLOW)) { |
4544 EvictEvacuationCandidate(target_page); | 4519 EvictEvacuationCandidate(target_page); |
4545 } | 4520 } |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4621 SlotsBuffer* buffer = *buffer_address; | 4596 SlotsBuffer* buffer = *buffer_address; |
4622 while (buffer != NULL) { | 4597 while (buffer != NULL) { |
4623 SlotsBuffer* next_buffer = buffer->next(); | 4598 SlotsBuffer* next_buffer = buffer->next(); |
4624 DeallocateBuffer(buffer); | 4599 DeallocateBuffer(buffer); |
4625 buffer = next_buffer; | 4600 buffer = next_buffer; |
4626 } | 4601 } |
4627 *buffer_address = NULL; | 4602 *buffer_address = NULL; |
4628 } | 4603 } |
4629 } | 4604 } |
4630 } // namespace v8::internal | 4605 } // namespace v8::internal |
OLD | NEW |