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/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 3479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3490 // for concurrent sweeping. The WasSwept predicate for concurrently swept | 3490 // for concurrent sweeping. The WasSwept predicate for concurrently swept |
3491 // pages is set after sweeping all pages. | 3491 // pages is set after sweeping all pages. |
3492 return (!is_in_old_pointer_space && !is_in_old_data_space) || | 3492 return (!is_in_old_pointer_space && !is_in_old_data_space) || |
3493 page->WasSwept() || page->SweepingCompleted(); | 3493 page->WasSwept() || page->SweepingCompleted(); |
3494 } | 3494 } |
3495 | 3495 |
3496 | 3496 |
3497 void Heap::AdjustLiveBytes(Address address, int by, InvocationMode mode) { | 3497 void Heap::AdjustLiveBytes(Address address, int by, InvocationMode mode) { |
3498 if (incremental_marking()->IsMarking() && | 3498 if (incremental_marking()->IsMarking() && |
3499 Marking::IsBlack(Marking::MarkBitFrom(address))) { | 3499 Marking::IsBlack(Marking::MarkBitFrom(address))) { |
3500 if (mode == FROM_GC) { | 3500 if (mode == SWEEPING_IS_OFF) { |
3501 MemoryChunk::IncrementLiveBytesFromGC(address, by); | 3501 MemoryChunk::IncrementLiveBytesFromGC(address, by); |
3502 } else { | 3502 } else { |
3503 MemoryChunk::IncrementLiveBytesFromMutator(address, by); | 3503 MemoryChunk::IncrementLiveBytesFromMutator(address, by); |
3504 } | 3504 } |
3505 } | 3505 } |
3506 } | 3506 } |
3507 | 3507 |
3508 | 3508 |
3509 FixedArrayBase* Heap::LeftTrimFixedArray(FixedArrayBase* object, | 3509 FixedArrayBase* Heap::LeftTrimFixedArray(FixedArrayBase* object, |
3510 int elements_to_trim) { | 3510 int elements_to_trim) { |
(...skipping 28 matching lines...) Expand all Loading... |
3539 DCHECK(CanMoveObjectStart(object)); | 3539 DCHECK(CanMoveObjectStart(object)); |
3540 Object** former_start = HeapObject::RawField(object, 0); | 3540 Object** former_start = HeapObject::RawField(object, 0); |
3541 int new_start_index = elements_to_trim * (element_size / kPointerSize); | 3541 int new_start_index = elements_to_trim * (element_size / kPointerSize); |
3542 former_start[new_start_index] = map; | 3542 former_start[new_start_index] = map; |
3543 former_start[new_start_index + 1] = Smi::FromInt(len - elements_to_trim); | 3543 former_start[new_start_index + 1] = Smi::FromInt(len - elements_to_trim); |
3544 FixedArrayBase* new_object = | 3544 FixedArrayBase* new_object = |
3545 FixedArrayBase::cast(HeapObject::FromAddress(new_start)); | 3545 FixedArrayBase::cast(HeapObject::FromAddress(new_start)); |
3546 | 3546 |
3547 // Maintain consistency of live bytes during incremental marking | 3547 // Maintain consistency of live bytes during incremental marking |
3548 marking()->TransferMark(object->address(), new_start); | 3548 marking()->TransferMark(object->address(), new_start); |
3549 AdjustLiveBytes(new_start, -bytes_to_trim, Heap::FROM_MUTATOR); | 3549 AdjustLiveBytes(new_start, -bytes_to_trim, Heap::SWEEPING_STARTED); |
3550 | 3550 |
3551 // Notify the heap profiler of change in object layout. | 3551 // Notify the heap profiler of change in object layout. |
3552 OnMoveEvent(new_object, object, new_object->Size()); | 3552 OnMoveEvent(new_object, object, new_object->Size()); |
3553 return new_object; | 3553 return new_object; |
3554 } | 3554 } |
3555 | 3555 |
3556 | 3556 |
3557 // Force instantiation of templatized method. | 3557 // Force instantiation of templatized method. |
3558 template | 3558 template void Heap::RightTrimFixedArray<Heap::SWEEPING_IS_OFF>(FixedArrayBase*, |
3559 void Heap::RightTrimFixedArray<Heap::FROM_GC>(FixedArrayBase*, int); | 3559 int); |
3560 template | 3560 template void Heap::RightTrimFixedArray<Heap::SWEEPING_STARTED>(FixedArrayBase*, |
3561 void Heap::RightTrimFixedArray<Heap::FROM_MUTATOR>(FixedArrayBase*, int); | 3561 int); |
3562 | 3562 |
3563 | 3563 |
3564 template<Heap::InvocationMode mode> | 3564 template<Heap::InvocationMode mode> |
3565 void Heap::RightTrimFixedArray(FixedArrayBase* object, int elements_to_trim) { | 3565 void Heap::RightTrimFixedArray(FixedArrayBase* object, int elements_to_trim) { |
3566 const int element_size = object->IsFixedArray() ? kPointerSize : kDoubleSize; | 3566 const int element_size = object->IsFixedArray() ? kPointerSize : kDoubleSize; |
3567 const int bytes_to_trim = elements_to_trim * element_size; | 3567 const int bytes_to_trim = elements_to_trim * element_size; |
3568 | 3568 |
3569 // For now this trick is only applied to objects in new and paged space. | 3569 // For now this trick is only applied to objects in new and paged space. |
3570 DCHECK(object->map() != fixed_cow_array_map()); | 3570 DCHECK(object->map() != fixed_cow_array_map()); |
3571 | 3571 |
(...skipping 2819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6391 static_cast<int>(object_sizes_last_time_[index])); | 6391 static_cast<int>(object_sizes_last_time_[index])); |
6392 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6392 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
6393 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6393 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
6394 | 6394 |
6395 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6395 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
6396 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6396 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
6397 ClearObjectStats(); | 6397 ClearObjectStats(); |
6398 } | 6398 } |
6399 } | 6399 } |
6400 } // namespace v8::internal | 6400 } // namespace v8::internal |
OLD | NEW |