| 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 3434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3445 // (3) the page was already concurrently swept. This case is an optimization | 3445 // (3) the page was already concurrently swept. This case is an optimization |
| 3446 // for concurrent sweeping. The WasSwept predicate for concurrently swept | 3446 // for concurrent sweeping. The WasSwept predicate for concurrently swept |
| 3447 // pages is set after sweeping all pages. | 3447 // pages is set after sweeping all pages. |
| 3448 return !InOldSpace(address) || page->WasSwept() || page->SweepingCompleted(); | 3448 return !InOldSpace(address) || page->WasSwept() || page->SweepingCompleted(); |
| 3449 } | 3449 } |
| 3450 | 3450 |
| 3451 | 3451 |
| 3452 void Heap::AdjustLiveBytes(Address address, int by, InvocationMode mode) { | 3452 void Heap::AdjustLiveBytes(Address address, int by, InvocationMode mode) { |
| 3453 if (incremental_marking()->IsMarking() && | 3453 if (incremental_marking()->IsMarking() && |
| 3454 Marking::IsBlack(Marking::MarkBitFrom(address))) { | 3454 Marking::IsBlack(Marking::MarkBitFrom(address))) { |
| 3455 if (mode == FROM_GC) { | 3455 if (mode == SEQUENTIAL_TO_SWEEPER) { |
| 3456 MemoryChunk::IncrementLiveBytesFromGC(address, by); | 3456 MemoryChunk::IncrementLiveBytesFromGC(address, by); |
| 3457 } else { | 3457 } else { |
| 3458 MemoryChunk::IncrementLiveBytesFromMutator(address, by); | 3458 MemoryChunk::IncrementLiveBytesFromMutator(address, by); |
| 3459 } | 3459 } |
| 3460 } | 3460 } |
| 3461 } | 3461 } |
| 3462 | 3462 |
| 3463 | 3463 |
| 3464 FixedArrayBase* Heap::LeftTrimFixedArray(FixedArrayBase* object, | 3464 FixedArrayBase* Heap::LeftTrimFixedArray(FixedArrayBase* object, |
| 3465 int elements_to_trim) { | 3465 int elements_to_trim) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 3495 DCHECK(CanMoveObjectStart(object)); | 3495 DCHECK(CanMoveObjectStart(object)); |
| 3496 Object** former_start = HeapObject::RawField(object, 0); | 3496 Object** former_start = HeapObject::RawField(object, 0); |
| 3497 int new_start_index = elements_to_trim * (element_size / kPointerSize); | 3497 int new_start_index = elements_to_trim * (element_size / kPointerSize); |
| 3498 former_start[new_start_index] = map; | 3498 former_start[new_start_index] = map; |
| 3499 former_start[new_start_index + 1] = Smi::FromInt(len - elements_to_trim); | 3499 former_start[new_start_index + 1] = Smi::FromInt(len - elements_to_trim); |
| 3500 FixedArrayBase* new_object = | 3500 FixedArrayBase* new_object = |
| 3501 FixedArrayBase::cast(HeapObject::FromAddress(new_start)); | 3501 FixedArrayBase::cast(HeapObject::FromAddress(new_start)); |
| 3502 | 3502 |
| 3503 // Maintain consistency of live bytes during incremental marking | 3503 // Maintain consistency of live bytes during incremental marking |
| 3504 marking()->TransferMark(object->address(), new_start); | 3504 marking()->TransferMark(object->address(), new_start); |
| 3505 AdjustLiveBytes(new_start, -bytes_to_trim, Heap::FROM_MUTATOR); | 3505 AdjustLiveBytes(new_start, -bytes_to_trim, Heap::CONCURRENT_TO_SWEEPER); |
| 3506 | 3506 |
| 3507 // Notify the heap profiler of change in object layout. | 3507 // Notify the heap profiler of change in object layout. |
| 3508 OnMoveEvent(new_object, object, new_object->Size()); | 3508 OnMoveEvent(new_object, object, new_object->Size()); |
| 3509 return new_object; | 3509 return new_object; |
| 3510 } | 3510 } |
| 3511 | 3511 |
| 3512 | 3512 |
| 3513 // Force instantiation of templatized method. | 3513 // Force instantiation of templatized method. |
| 3514 template | 3514 template void Heap::RightTrimFixedArray<Heap::SEQUENTIAL_TO_SWEEPER>( |
| 3515 void Heap::RightTrimFixedArray<Heap::FROM_GC>(FixedArrayBase*, int); | 3515 FixedArrayBase*, int); |
| 3516 template | 3516 template void Heap::RightTrimFixedArray<Heap::CONCURRENT_TO_SWEEPER>( |
| 3517 void Heap::RightTrimFixedArray<Heap::FROM_MUTATOR>(FixedArrayBase*, int); | 3517 FixedArrayBase*, int); |
| 3518 | 3518 |
| 3519 | 3519 |
| 3520 template<Heap::InvocationMode mode> | 3520 template<Heap::InvocationMode mode> |
| 3521 void Heap::RightTrimFixedArray(FixedArrayBase* object, int elements_to_trim) { | 3521 void Heap::RightTrimFixedArray(FixedArrayBase* object, int elements_to_trim) { |
| 3522 const int len = object->length(); | 3522 const int len = object->length(); |
| 3523 DCHECK(elements_to_trim < len); | 3523 DCHECK(elements_to_trim < len); |
| 3524 | 3524 |
| 3525 int bytes_to_trim; | 3525 int bytes_to_trim; |
| 3526 if (object->IsFixedTypedArrayBase()) { | 3526 if (object->IsFixedTypedArrayBase()) { |
| 3527 InstanceType type = object->map()->instance_type(); | 3527 InstanceType type = object->map()->instance_type(); |
| (...skipping 2781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6309 static_cast<int>(object_sizes_last_time_[index])); | 6309 static_cast<int>(object_sizes_last_time_[index])); |
| 6310 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6310 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 6311 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6311 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 6312 | 6312 |
| 6313 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6313 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 6314 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6314 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 6315 ClearObjectStats(); | 6315 ClearObjectStats(); |
| 6316 } | 6316 } |
| 6317 } | 6317 } |
| 6318 } // namespace v8::internal | 6318 } // namespace v8::internal |
| OLD | NEW |