Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(680)

Side by Side Diff: src/heap/mark-compact.cc

Issue 1131783003: Embedded constant pools. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 2809 matching lines...) Expand 10 before | Expand all | Expand 10 after
2820 2820
2821 if (compacting_ && dst->IsJSFunction()) { 2821 if (compacting_ && dst->IsJSFunction()) {
2822 Address code_entry_slot = dst_addr + JSFunction::kCodeEntryOffset; 2822 Address code_entry_slot = dst_addr + JSFunction::kCodeEntryOffset;
2823 Address code_entry = Memory::Address_at(code_entry_slot); 2823 Address code_entry = Memory::Address_at(code_entry_slot);
2824 2824
2825 if (Page::FromAddress(code_entry)->IsEvacuationCandidate()) { 2825 if (Page::FromAddress(code_entry)->IsEvacuationCandidate()) {
2826 SlotsBuffer::AddTo(&slots_buffer_allocator_, &migration_slots_buffer_, 2826 SlotsBuffer::AddTo(&slots_buffer_allocator_, &migration_slots_buffer_,
2827 SlotsBuffer::CODE_ENTRY_SLOT, code_entry_slot, 2827 SlotsBuffer::CODE_ENTRY_SLOT, code_entry_slot,
2828 SlotsBuffer::IGNORE_OVERFLOW); 2828 SlotsBuffer::IGNORE_OVERFLOW);
2829 } 2829 }
2830 } else if (dst->IsConstantPoolArray()) {
2831 // We special case ConstantPoolArrays since they could contain integers
2832 // value entries which look like tagged pointers.
2833 // TODO(mstarzinger): restructure this code to avoid this special-casing.
2834 ConstantPoolArray* array = ConstantPoolArray::cast(dst);
2835 ConstantPoolArray::Iterator code_iter(array, ConstantPoolArray::CODE_PTR);
2836 while (!code_iter.is_finished()) {
2837 Address code_entry_slot =
2838 dst_addr + array->OffsetOfElementAt(code_iter.next_index());
2839 Address code_entry = Memory::Address_at(code_entry_slot);
2840
2841 if (Page::FromAddress(code_entry)->IsEvacuationCandidate()) {
2842 SlotsBuffer::AddTo(&slots_buffer_allocator_, &migration_slots_buffer_,
2843 SlotsBuffer::CODE_ENTRY_SLOT, code_entry_slot,
2844 SlotsBuffer::IGNORE_OVERFLOW);
2845 }
2846 }
2847 ConstantPoolArray::Iterator heap_iter(array, ConstantPoolArray::HEAP_PTR);
2848 while (!heap_iter.is_finished()) {
2849 Address heap_slot =
2850 dst_addr + array->OffsetOfElementAt(heap_iter.next_index());
2851 Object* value = Memory::Object_at(heap_slot);
2852 RecordMigratedSlot(value, heap_slot);
2853 }
2854 } 2830 }
2855 } else if (dest == CODE_SPACE) { 2831 } else if (dest == CODE_SPACE) {
2856 PROFILE(isolate(), CodeMoveEvent(src_addr, dst_addr)); 2832 PROFILE(isolate(), CodeMoveEvent(src_addr, dst_addr));
2857 heap()->MoveBlock(dst_addr, src_addr, size); 2833 heap()->MoveBlock(dst_addr, src_addr, size);
2858 SlotsBuffer::AddTo(&slots_buffer_allocator_, &migration_slots_buffer_, 2834 SlotsBuffer::AddTo(&slots_buffer_allocator_, &migration_slots_buffer_,
2859 SlotsBuffer::RELOCATED_CODE_OBJECT, dst_addr, 2835 SlotsBuffer::RELOCATED_CODE_OBJECT, dst_addr,
2860 SlotsBuffer::IGNORE_OVERFLOW); 2836 SlotsBuffer::IGNORE_OVERFLOW);
2861 Code::cast(dst)->Relocate(dst_addr - src_addr); 2837 Code::cast(dst)->Relocate(dst_addr - src_addr);
2862 } else { 2838 } else {
2863 DCHECK(dest == NEW_SPACE); 2839 DCHECK(dest == NEW_SPACE);
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
3460 case SlotsBuffer::JS_RETURN_SLOT: { 3436 case SlotsBuffer::JS_RETURN_SLOT: {
3461 RelocInfo rinfo(addr, RelocInfo::JS_RETURN, 0, NULL); 3437 RelocInfo rinfo(addr, RelocInfo::JS_RETURN, 0, NULL);
3462 if (rinfo.IsPatchedReturnSequence()) rinfo.Visit(isolate, v); 3438 if (rinfo.IsPatchedReturnSequence()) rinfo.Visit(isolate, v);
3463 break; 3439 break;
3464 } 3440 }
3465 case SlotsBuffer::EMBEDDED_OBJECT_SLOT: { 3441 case SlotsBuffer::EMBEDDED_OBJECT_SLOT: {
3466 RelocInfo rinfo(addr, RelocInfo::EMBEDDED_OBJECT, 0, NULL); 3442 RelocInfo rinfo(addr, RelocInfo::EMBEDDED_OBJECT, 0, NULL);
3467 rinfo.Visit(isolate, v); 3443 rinfo.Visit(isolate, v);
3468 break; 3444 break;
3469 } 3445 }
3446 case SlotsBuffer::OBJECT_SLOT: {
3447 v->VisitPointer(reinterpret_cast<Object**>(addr));
3448 break;
3449 }
3470 default: 3450 default:
3471 UNREACHABLE(); 3451 UNREACHABLE();
3472 break; 3452 break;
3473 } 3453 }
3474 } 3454 }
3475 3455
3476 3456
3477 enum SweepingMode { SWEEP_ONLY, SWEEP_AND_VISIT_LIVE_OBJECTS }; 3457 enum SweepingMode { SWEEP_ONLY, SWEEP_AND_VISIT_LIVE_OBJECTS };
3478 3458
3479 3459
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after
4629 return SlotsBuffer::NUMBER_OF_SLOT_TYPES; 4609 return SlotsBuffer::NUMBER_OF_SLOT_TYPES;
4630 } 4610 }
4631 4611
4632 4612
4633 void MarkCompactCollector::RecordRelocSlot(RelocInfo* rinfo, Object* target) { 4613 void MarkCompactCollector::RecordRelocSlot(RelocInfo* rinfo, Object* target) {
4634 Page* target_page = Page::FromAddress(reinterpret_cast<Address>(target)); 4614 Page* target_page = Page::FromAddress(reinterpret_cast<Address>(target));
4635 RelocInfo::Mode rmode = rinfo->rmode(); 4615 RelocInfo::Mode rmode = rinfo->rmode();
4636 if (target_page->IsEvacuationCandidate() && 4616 if (target_page->IsEvacuationCandidate() &&
4637 (rinfo->host() == NULL || 4617 (rinfo->host() == NULL ||
4638 !ShouldSkipEvacuationSlotRecording(rinfo->host()))) { 4618 !ShouldSkipEvacuationSlotRecording(rinfo->host()))) {
4619 Address addr = rinfo->pc();
4620 SlotsBuffer::SlotType slot_type = SlotTypeForRMode(rmode);
4621 if (rinfo->IsInConstantPool()) {
4622 addr = rinfo->constant_pool_entry_address();
4623 if (RelocInfo::IsCodeTarget(rmode)) {
4624 slot_type = SlotsBuffer::CODE_ENTRY_SLOT;
4625 } else {
4626 DCHECK(RelocInfo::IsEmbeddedObject(rmode));
4627 slot_type = SlotsBuffer::OBJECT_SLOT;
rmcilroy 2015/05/20 14:32:11 why are these changes to add OBJECT_SLOT to the ma
MTBrandyberry 2015/05/20 22:28:22 This is required. https://chromium.googlesource.c
rmcilroy 2015/06/01 09:52:08 ishell@: Could you have a quick look at this chang
Igor Sheludko 2015/06/01 10:42:30 Sgtm. Since we have a typed slot here the slots fi
4628 }
4629 }
4639 bool success = SlotsBuffer::AddTo( 4630 bool success = SlotsBuffer::AddTo(
4640 &slots_buffer_allocator_, target_page->slots_buffer_address(), 4631 &slots_buffer_allocator_, target_page->slots_buffer_address(),
4641 SlotTypeForRMode(rmode), rinfo->pc(), SlotsBuffer::FAIL_ON_OVERFLOW); 4632 slot_type, addr, SlotsBuffer::FAIL_ON_OVERFLOW);
4642 if (!success) { 4633 if (!success) {
4643 EvictPopularEvacuationCandidate(target_page); 4634 EvictPopularEvacuationCandidate(target_page);
4644 } 4635 }
4645 } 4636 }
4646 } 4637 }
4647 4638
4648 4639
4649 void MarkCompactCollector::EvictPopularEvacuationCandidate(Page* page) { 4640 void MarkCompactCollector::EvictPopularEvacuationCandidate(Page* page) {
4650 if (FLAG_trace_fragmentation) { 4641 if (FLAG_trace_fragmentation) {
4651 PrintF("Page %p is too popular. Disabling evacuation.\n", 4642 PrintF("Page %p is too popular. Disabling evacuation.\n",
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
4757 SlotsBuffer* buffer = *buffer_address; 4748 SlotsBuffer* buffer = *buffer_address;
4758 while (buffer != NULL) { 4749 while (buffer != NULL) {
4759 SlotsBuffer* next_buffer = buffer->next(); 4750 SlotsBuffer* next_buffer = buffer->next();
4760 DeallocateBuffer(buffer); 4751 DeallocateBuffer(buffer);
4761 buffer = next_buffer; 4752 buffer = next_buffer;
4762 } 4753 }
4763 *buffer_address = NULL; 4754 *buffer_address = NULL;
4764 } 4755 }
4765 } 4756 }
4766 } // namespace v8::internal 4757 } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698