| 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/heap/heap.h" | 5 #include "src/heap/heap.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/ast/scopeinfo.h" | 9 #include "src/ast/scopeinfo.h" |
| 10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
| (...skipping 3119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3130 DCHECK(elements_to_trim <= len); | 3130 DCHECK(elements_to_trim <= len); |
| 3131 | 3131 |
| 3132 // Calculate location of new array start. | 3132 // Calculate location of new array start. |
| 3133 Address new_start = object->address() + bytes_to_trim; | 3133 Address new_start = object->address() + bytes_to_trim; |
| 3134 | 3134 |
| 3135 // Technically in new space this write might be omitted (except for | 3135 // Technically in new space this write might be omitted (except for |
| 3136 // debug mode which iterates through the heap), but to play safer | 3136 // debug mode which iterates through the heap), but to play safer |
| 3137 // we still do it. | 3137 // we still do it. |
| 3138 CreateFillerObjectAt(object->address(), bytes_to_trim, | 3138 CreateFillerObjectAt(object->address(), bytes_to_trim, |
| 3139 ClearRecordedSlots::kYes); | 3139 ClearRecordedSlots::kYes); |
| 3140 | |
| 3141 // Initialize header of the trimmed array. Since left trimming is only | 3140 // Initialize header of the trimmed array. Since left trimming is only |
| 3142 // performed on pages which are not concurrently swept creating a filler | 3141 // performed on pages which are not concurrently swept creating a filler |
| 3143 // object does not require synchronization. | 3142 // object does not require synchronization. |
| 3144 DCHECK(CanMoveObjectStart(object)); | 3143 DCHECK(CanMoveObjectStart(object)); |
| 3145 Object** former_start = HeapObject::RawField(object, 0); | 3144 Object** former_start = HeapObject::RawField(object, 0); |
| 3146 int new_start_index = elements_to_trim * (element_size / kPointerSize); | 3145 int new_start_index = elements_to_trim * (element_size / kPointerSize); |
| 3147 former_start[new_start_index] = map; | 3146 former_start[new_start_index] = map; |
| 3148 former_start[new_start_index + 1] = Smi::FromInt(len - elements_to_trim); | 3147 former_start[new_start_index + 1] = Smi::FromInt(len - elements_to_trim); |
| 3149 FixedArrayBase* new_object = | 3148 FixedArrayBase* new_object = |
| 3150 FixedArrayBase::cast(HeapObject::FromAddress(new_start)); | 3149 FixedArrayBase::cast(HeapObject::FromAddress(new_start)); |
| 3151 | 3150 |
| 3151 // Remove recorded slots for the new map and length offset. |
| 3152 ClearRecordedSlot(new_object, HeapObject::RawField(object, 0)); |
| 3153 ClearRecordedSlot( |
| 3154 new_object, HeapObject::RawField(object, FixedArrayBase::kLengthOffset)); |
| 3155 |
| 3152 // Maintain consistency of live bytes during incremental marking | 3156 // Maintain consistency of live bytes during incremental marking |
| 3153 Marking::TransferMark(this, object->address(), new_start); | 3157 Marking::TransferMark(this, object->address(), new_start); |
| 3154 AdjustLiveBytes(new_object, -bytes_to_trim, Heap::CONCURRENT_TO_SWEEPER); | 3158 AdjustLiveBytes(new_object, -bytes_to_trim, Heap::CONCURRENT_TO_SWEEPER); |
| 3155 | 3159 |
| 3156 // Notify the heap profiler of change in object layout. | 3160 // Notify the heap profiler of change in object layout. |
| 3157 OnMoveEvent(new_object, object, new_object->Size()); | 3161 OnMoveEvent(new_object, object, new_object->Size()); |
| 3158 return new_object; | 3162 return new_object; |
| 3159 } | 3163 } |
| 3160 | 3164 |
| 3161 | 3165 |
| (...skipping 3268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6430 } | 6434 } |
| 6431 | 6435 |
| 6432 | 6436 |
| 6433 // static | 6437 // static |
| 6434 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6438 int Heap::GetStaticVisitorIdForMap(Map* map) { |
| 6435 return StaticVisitorBase::GetVisitorId(map); | 6439 return StaticVisitorBase::GetVisitorId(map); |
| 6436 } | 6440 } |
| 6437 | 6441 |
| 6438 } // namespace internal | 6442 } // namespace internal |
| 6439 } // namespace v8 | 6443 } // namespace v8 |
| OLD | NEW |