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

Side by Side Diff: src/heap/heap.cc

Issue 1256203004: AdjustLiveBytes and friends takes a heap object pointer instead of an address. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/incremental-marking.cc » ('j') | 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/accessors.h" 7 #include "src/accessors.h"
8 #include "src/api.h" 8 #include "src/api.h"
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 2342 matching lines...) Expand 10 before | Expand all | Expand 10 after
2353 source->set_map_word(MapWord::FromForwardingAddress(target)); 2353 source->set_map_word(MapWord::FromForwardingAddress(target));
2354 2354
2355 if (logging_and_profiling_mode == LOGGING_AND_PROFILING_ENABLED) { 2355 if (logging_and_profiling_mode == LOGGING_AND_PROFILING_ENABLED) {
2356 // Update NewSpace stats if necessary. 2356 // Update NewSpace stats if necessary.
2357 RecordCopiedObject(heap, target); 2357 RecordCopiedObject(heap, target);
2358 heap->OnMoveEvent(target, source, size); 2358 heap->OnMoveEvent(target, source, size);
2359 } 2359 }
2360 2360
2361 if (marks_handling == TRANSFER_MARKS) { 2361 if (marks_handling == TRANSFER_MARKS) {
2362 if (Marking::TransferColor(source, target)) { 2362 if (Marking::TransferColor(source, target)) {
2363 MemoryChunk::IncrementLiveBytesFromGC(target->address(), size); 2363 MemoryChunk::IncrementLiveBytesFromGC(target, size);
2364 } 2364 }
2365 } 2365 }
2366 } 2366 }
2367 2367
2368 template <AllocationAlignment alignment> 2368 template <AllocationAlignment alignment>
2369 static inline bool SemiSpaceCopyObject(Map* map, HeapObject** slot, 2369 static inline bool SemiSpaceCopyObject(Map* map, HeapObject** slot,
2370 HeapObject* object, int object_size) { 2370 HeapObject* object, int object_size) {
2371 Heap* heap = map->GetHeap(); 2371 Heap* heap = map->GetHeap();
2372 2372
2373 DCHECK(heap->AllowedToBeMigrated(object, NEW_SPACE)); 2373 DCHECK(heap->AllowedToBeMigrated(object, NEW_SPACE));
(...skipping 1440 matching lines...) Expand 10 before | Expand all | Expand 10 after
3814 // We can move the object start if: 3814 // We can move the object start if:
3815 // (1) the object is not in old space, 3815 // (1) the object is not in old space,
3816 // (2) the page of the object was already swept, 3816 // (2) the page of the object was already swept,
3817 // (3) the page was already concurrently swept. This case is an optimization 3817 // (3) the page was already concurrently swept. This case is an optimization
3818 // for concurrent sweeping. The WasSwept predicate for concurrently swept 3818 // for concurrent sweeping. The WasSwept predicate for concurrently swept
3819 // pages is set after sweeping all pages. 3819 // pages is set after sweeping all pages.
3820 return !InOldSpace(address) || page->WasSwept() || page->SweepingCompleted(); 3820 return !InOldSpace(address) || page->WasSwept() || page->SweepingCompleted();
3821 } 3821 }
3822 3822
3823 3823
3824 void Heap::AdjustLiveBytes(Address address, int by, InvocationMode mode) { 3824 void Heap::AdjustLiveBytes(HeapObject* object, int by, InvocationMode mode) {
3825 if (incremental_marking()->IsMarking() && 3825 if (incremental_marking()->IsMarking() &&
3826 Marking::IsBlack(Marking::MarkBitFrom(address))) { 3826 Marking::IsBlack(Marking::MarkBitFrom(object->address()))) {
3827 if (mode == SEQUENTIAL_TO_SWEEPER) { 3827 if (mode == SEQUENTIAL_TO_SWEEPER) {
3828 MemoryChunk::IncrementLiveBytesFromGC(address, by); 3828 MemoryChunk::IncrementLiveBytesFromGC(object, by);
3829 } else { 3829 } else {
3830 MemoryChunk::IncrementLiveBytesFromMutator(address, by); 3830 MemoryChunk::IncrementLiveBytesFromMutator(object, by);
3831 } 3831 }
3832 } 3832 }
3833 } 3833 }
3834 3834
3835 3835
3836 FixedArrayBase* Heap::LeftTrimFixedArray(FixedArrayBase* object, 3836 FixedArrayBase* Heap::LeftTrimFixedArray(FixedArrayBase* object,
3837 int elements_to_trim) { 3837 int elements_to_trim) {
3838 DCHECK(!object->IsFixedTypedArrayBase()); 3838 DCHECK(!object->IsFixedTypedArrayBase());
3839 const int element_size = object->IsFixedArray() ? kPointerSize : kDoubleSize; 3839 const int element_size = object->IsFixedArray() ? kPointerSize : kDoubleSize;
3840 const int bytes_to_trim = elements_to_trim * element_size; 3840 const int bytes_to_trim = elements_to_trim * element_size;
(...skipping 26 matching lines...) Expand all
3867 DCHECK(CanMoveObjectStart(object)); 3867 DCHECK(CanMoveObjectStart(object));
3868 Object** former_start = HeapObject::RawField(object, 0); 3868 Object** former_start = HeapObject::RawField(object, 0);
3869 int new_start_index = elements_to_trim * (element_size / kPointerSize); 3869 int new_start_index = elements_to_trim * (element_size / kPointerSize);
3870 former_start[new_start_index] = map; 3870 former_start[new_start_index] = map;
3871 former_start[new_start_index + 1] = Smi::FromInt(len - elements_to_trim); 3871 former_start[new_start_index + 1] = Smi::FromInt(len - elements_to_trim);
3872 FixedArrayBase* new_object = 3872 FixedArrayBase* new_object =
3873 FixedArrayBase::cast(HeapObject::FromAddress(new_start)); 3873 FixedArrayBase::cast(HeapObject::FromAddress(new_start));
3874 3874
3875 // Maintain consistency of live bytes during incremental marking 3875 // Maintain consistency of live bytes during incremental marking
3876 marking()->TransferMark(object->address(), new_start); 3876 marking()->TransferMark(object->address(), new_start);
3877 AdjustLiveBytes(new_start, -bytes_to_trim, Heap::CONCURRENT_TO_SWEEPER); 3877 AdjustLiveBytes(new_object, -bytes_to_trim, Heap::CONCURRENT_TO_SWEEPER);
3878 3878
3879 // Notify the heap profiler of change in object layout. 3879 // Notify the heap profiler of change in object layout.
3880 OnMoveEvent(new_object, object, new_object->Size()); 3880 OnMoveEvent(new_object, object, new_object->Size());
3881 return new_object; 3881 return new_object;
3882 } 3882 }
3883 3883
3884 3884
3885 // Force instantiation of templatized method. 3885 // Force instantiation of templatized method.
3886 template void Heap::RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>( 3886 template void Heap::RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>(
3887 FixedArrayBase*, int); 3887 FixedArrayBase*, int);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3928 if (!lo_space()->Contains(object)) { 3928 if (!lo_space()->Contains(object)) {
3929 CreateFillerObjectAt(new_end, bytes_to_trim); 3929 CreateFillerObjectAt(new_end, bytes_to_trim);
3930 } 3930 }
3931 3931
3932 // Initialize header of the trimmed array. We are storing the new length 3932 // Initialize header of the trimmed array. We are storing the new length
3933 // using release store after creating a filler for the left-over space to 3933 // using release store after creating a filler for the left-over space to
3934 // avoid races with the sweeper thread. 3934 // avoid races with the sweeper thread.
3935 object->synchronized_set_length(len - elements_to_trim); 3935 object->synchronized_set_length(len - elements_to_trim);
3936 3936
3937 // Maintain consistency of live bytes during incremental marking 3937 // Maintain consistency of live bytes during incremental marking
3938 AdjustLiveBytes(object->address(), -bytes_to_trim, mode); 3938 AdjustLiveBytes(object, -bytes_to_trim, mode);
3939 3939
3940 // Notify the heap profiler of change in object layout. The array may not be 3940 // Notify the heap profiler of change in object layout. The array may not be
3941 // moved during GC, and size has to be adjusted nevertheless. 3941 // moved during GC, and size has to be adjusted nevertheless.
3942 HeapProfiler* profiler = isolate()->heap_profiler(); 3942 HeapProfiler* profiler = isolate()->heap_profiler();
3943 if (profiler->is_tracking_allocations()) { 3943 if (profiler->is_tracking_allocations()) {
3944 profiler->UpdateObjectSizeEvent(object->address(), object->Size()); 3944 profiler->UpdateObjectSizeEvent(object->address(), object->Size());
3945 } 3945 }
3946 } 3946 }
3947 3947
3948 3948
(...skipping 2975 matching lines...) Expand 10 before | Expand all | Expand 10 after
6924 *object_type = "CODE_TYPE"; \ 6924 *object_type = "CODE_TYPE"; \
6925 *object_sub_type = "CODE_AGE/" #name; \ 6925 *object_sub_type = "CODE_AGE/" #name; \
6926 return true; 6926 return true;
6927 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) 6927 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME)
6928 #undef COMPARE_AND_RETURN_NAME 6928 #undef COMPARE_AND_RETURN_NAME
6929 } 6929 }
6930 return false; 6930 return false;
6931 } 6931 }
6932 } // namespace internal 6932 } // namespace internal
6933 } // namespace v8 6933 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/heap/incremental-marking.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698