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

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

Issue 304223002: Special case ConstantPoolArray in MarkCompactCollector::MigrateObject. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix typo Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/mark-compact.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/code-stubs.h" 7 #include "src/code-stubs.h"
8 #include "src/compilation-cache.h" 8 #include "src/compilation-cache.h"
9 #include "src/cpu-profiler.h" 9 #include "src/cpu-profiler.h"
10 #include "src/deoptimizer.h" 10 #include "src/deoptimizer.h"
(...skipping 2767 matching lines...) Expand 10 before | Expand all | Expand 10 after
2778 } 2778 }
2779 } 2779 }
2780 } 2780 }
2781 weak_collection_obj = weak_collection->next(); 2781 weak_collection_obj = weak_collection->next();
2782 weak_collection->set_next(heap()->undefined_value()); 2782 weak_collection->set_next(heap()->undefined_value());
2783 } 2783 }
2784 heap()->set_encountered_weak_collections(Smi::FromInt(0)); 2784 heap()->set_encountered_weak_collections(Smi::FromInt(0));
2785 } 2785 }
2786 2786
2787 2787
2788 void MarkCompactCollector::RecordMigratedSlot(Object* value, Address slot) {
2789 if (heap_->InNewSpace(value)) {
2790 heap_->store_buffer()->Mark(slot);
2791 } else if (value->IsHeapObject() && IsOnEvacuationCandidate(value)) {
2792 SlotsBuffer::AddTo(&slots_buffer_allocator_,
2793 &migration_slots_buffer_,
2794 reinterpret_cast<Object**>(slot),
2795 SlotsBuffer::IGNORE_OVERFLOW);
2796 }
2797 }
2798
2799
2800
2788 // We scavange new space simultaneously with sweeping. This is done in two 2801 // We scavange new space simultaneously with sweeping. This is done in two
2789 // passes. 2802 // passes.
2790 // 2803 //
2791 // The first pass migrates all alive objects from one semispace to another or 2804 // The first pass migrates all alive objects from one semispace to another or
2792 // promotes them to old space. Forwarding address is written directly into 2805 // promotes them to old space. Forwarding address is written directly into
2793 // first word of object without any encoding. If object is dead we write 2806 // first word of object without any encoding. If object is dead we write
2794 // NULL as a forwarding address. 2807 // NULL as a forwarding address.
2795 // 2808 //
2796 // The second pass updates pointers to new space in all spaces. It is possible 2809 // The second pass updates pointers to new space in all spaces. It is possible
2797 // to encounter pointers to dead new space objects during traversal of pointers 2810 // to encounter pointers to dead new space objects during traversal of pointers
(...skipping 16 matching lines...) Expand all
2814 if (dest == OLD_POINTER_SPACE) { 2827 if (dest == OLD_POINTER_SPACE) {
2815 Address src_slot = src_addr; 2828 Address src_slot = src_addr;
2816 Address dst_slot = dst_addr; 2829 Address dst_slot = dst_addr;
2817 ASSERT(IsAligned(size, kPointerSize)); 2830 ASSERT(IsAligned(size, kPointerSize));
2818 2831
2819 for (int remaining = size / kPointerSize; remaining > 0; remaining--) { 2832 for (int remaining = size / kPointerSize; remaining > 0; remaining--) {
2820 Object* value = Memory::Object_at(src_slot); 2833 Object* value = Memory::Object_at(src_slot);
2821 2834
2822 Memory::Object_at(dst_slot) = value; 2835 Memory::Object_at(dst_slot) = value;
2823 2836
2824 if (heap_->InNewSpace(value)) { 2837 // We special case ConstantPoolArrays below since they could contain
2825 heap_->store_buffer()->Mark(dst_slot); 2838 // integers value entries which look like tagged pointers.
2826 } else if (value->IsHeapObject() && IsOnEvacuationCandidate(value)) { 2839 // TODO(mstarzinger): restructure this code to avoid this special-casing.
2827 SlotsBuffer::AddTo(&slots_buffer_allocator_, 2840 if (!src->IsConstantPoolArray()) {
2828 &migration_slots_buffer_, 2841 RecordMigratedSlot(value, dst_slot);
2829 reinterpret_cast<Object**>(dst_slot),
2830 SlotsBuffer::IGNORE_OVERFLOW);
2831 } 2842 }
2832 2843
2833 src_slot += kPointerSize; 2844 src_slot += kPointerSize;
2834 dst_slot += kPointerSize; 2845 dst_slot += kPointerSize;
2835 } 2846 }
2836 2847
2837 if (compacting_ && dst->IsJSFunction()) { 2848 if (compacting_ && dst->IsJSFunction()) {
2838 Address code_entry_slot = dst_addr + JSFunction::kCodeEntryOffset; 2849 Address code_entry_slot = dst_addr + JSFunction::kCodeEntryOffset;
2839 Address code_entry = Memory::Address_at(code_entry_slot); 2850 Address code_entry = Memory::Address_at(code_entry_slot);
2840 2851
2841 if (Page::FromAddress(code_entry)->IsEvacuationCandidate()) { 2852 if (Page::FromAddress(code_entry)->IsEvacuationCandidate()) {
2842 SlotsBuffer::AddTo(&slots_buffer_allocator_, 2853 SlotsBuffer::AddTo(&slots_buffer_allocator_,
2843 &migration_slots_buffer_, 2854 &migration_slots_buffer_,
2844 SlotsBuffer::CODE_ENTRY_SLOT, 2855 SlotsBuffer::CODE_ENTRY_SLOT,
2845 code_entry_slot, 2856 code_entry_slot,
2846 SlotsBuffer::IGNORE_OVERFLOW); 2857 SlotsBuffer::IGNORE_OVERFLOW);
2847 } 2858 }
2848 } else if (compacting_ && dst->IsConstantPoolArray()) { 2859 } else if (dst->IsConstantPoolArray()) {
Hannes Payer (out of office) 2014/06/04 10:54:16 You could keep compacting_ here, but it doesn't re
Hannes Payer (out of office) 2014/06/04 11:01:58 Not true, ignore this comment.
2849 ConstantPoolArray* array = ConstantPoolArray::cast(dst); 2860 ConstantPoolArray* array = ConstantPoolArray::cast(dst);
2850 ConstantPoolArray::Iterator code_iter(array, ConstantPoolArray::CODE_PTR); 2861 ConstantPoolArray::Iterator code_iter(array, ConstantPoolArray::CODE_PTR);
2851 while (!code_iter.is_finished()) { 2862 while (!code_iter.is_finished()) {
2852 Address code_entry_slot = 2863 Address code_entry_slot =
2853 dst_addr + array->OffsetOfElementAt(code_iter.next_index()); 2864 dst_addr + array->OffsetOfElementAt(code_iter.next_index());
2854 Address code_entry = Memory::Address_at(code_entry_slot); 2865 Address code_entry = Memory::Address_at(code_entry_slot);
2855 2866
2856 if (Page::FromAddress(code_entry)->IsEvacuationCandidate()) { 2867 if (Page::FromAddress(code_entry)->IsEvacuationCandidate()) {
2857 SlotsBuffer::AddTo(&slots_buffer_allocator_, 2868 SlotsBuffer::AddTo(&slots_buffer_allocator_,
2858 &migration_slots_buffer_, 2869 &migration_slots_buffer_,
2859 SlotsBuffer::CODE_ENTRY_SLOT, 2870 SlotsBuffer::CODE_ENTRY_SLOT,
2860 code_entry_slot, 2871 code_entry_slot,
2861 SlotsBuffer::IGNORE_OVERFLOW); 2872 SlotsBuffer::IGNORE_OVERFLOW);
2862 } 2873 }
2863 } 2874 }
2875 ConstantPoolArray::Iterator heap_iter(array, ConstantPoolArray::HEAP_PTR);
2876 while (!heap_iter.is_finished()) {
2877 Address heap_slot =
2878 dst_addr + array->OffsetOfElementAt(heap_iter.next_index());
2879 Object* value = Memory::Object_at(heap_slot);
2880 RecordMigratedSlot(value, heap_slot);
2881 }
2864 } 2882 }
2865 } else if (dest == CODE_SPACE) { 2883 } else if (dest == CODE_SPACE) {
2866 PROFILE(isolate(), CodeMoveEvent(src_addr, dst_addr)); 2884 PROFILE(isolate(), CodeMoveEvent(src_addr, dst_addr));
2867 heap()->MoveBlock(dst_addr, src_addr, size); 2885 heap()->MoveBlock(dst_addr, src_addr, size);
2868 SlotsBuffer::AddTo(&slots_buffer_allocator_, 2886 SlotsBuffer::AddTo(&slots_buffer_allocator_,
2869 &migration_slots_buffer_, 2887 &migration_slots_buffer_,
2870 SlotsBuffer::RELOCATED_CODE_OBJECT, 2888 SlotsBuffer::RELOCATED_CODE_OBJECT,
2871 dst_addr, 2889 dst_addr,
2872 SlotsBuffer::IGNORE_OVERFLOW); 2890 SlotsBuffer::IGNORE_OVERFLOW);
2873 Code::cast(dst)->Relocate(dst_addr - src_addr); 2891 Code::cast(dst)->Relocate(dst_addr - src_addr);
(...skipping 1590 matching lines...) Expand 10 before | Expand all | Expand 10 after
4464 while (buffer != NULL) { 4482 while (buffer != NULL) {
4465 SlotsBuffer* next_buffer = buffer->next(); 4483 SlotsBuffer* next_buffer = buffer->next();
4466 DeallocateBuffer(buffer); 4484 DeallocateBuffer(buffer);
4467 buffer = next_buffer; 4485 buffer = next_buffer;
4468 } 4486 }
4469 *buffer_address = NULL; 4487 *buffer_address = NULL;
4470 } 4488 }
4471 4489
4472 4490
4473 } } // namespace v8::internal 4491 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/mark-compact.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698