Index: src/heap/heap.cc |
diff --git a/src/heap/heap.cc b/src/heap/heap.cc |
index 713cda82f57b786da7ac63195b81969cd715cbc9..b373bb5ef01f7453f575dc4c91805abd1c5dce9c 100644 |
--- a/src/heap/heap.cc |
+++ b/src/heap/heap.cc |
@@ -3781,18 +3781,41 @@ AllocationResult Heap::CopyFixedArrayAndGrow(FixedArray* src, int grow_by, |
AllocationResult allocation = AllocateRawFixedArray(new_len, pretenure); |
if (!allocation.To(&obj)) return allocation; |
} |
+ |
obj->set_map_no_write_barrier(fixed_array_map()); |
FixedArray* result = FixedArray::cast(obj); |
result->set_length(new_len); |
// Copy the content. |
DisallowHeapAllocation no_gc; |
- WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); |
+ WriteBarrierMode mode = obj->GetWriteBarrierMode(no_gc); |
for (int i = 0; i < old_len; i++) result->set(i, src->get(i), mode); |
MemsetPointer(result->data_start() + old_len, undefined_value(), grow_by); |
return result; |
} |
+AllocationResult Heap::CopyFixedArrayUpTo(FixedArray* src, int new_len, |
+ PretenureFlag pretenure) { |
+ if (new_len == 0) return empty_fixed_array(); |
+ |
+ DCHECK_LE(new_len, src->length()); |
+ |
+ HeapObject* obj = nullptr; |
+ { |
+ AllocationResult allocation = AllocateRawFixedArray(new_len, pretenure); |
+ if (!allocation.To(&obj)) return allocation; |
+ } |
+ obj->set_map_no_write_barrier(fixed_array_map()); |
+ |
+ FixedArray* result = FixedArray::cast(obj); |
+ result->set_length(new_len); |
+ |
+ // Copy the content. |
+ DisallowHeapAllocation no_gc; |
+ WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); |
+ for (int i = 0; i < new_len; i++) result->set(i, src->get(i), mode); |
+ return result; |
+} |
AllocationResult Heap::CopyFixedArrayWithMap(FixedArray* src, Map* map) { |
int len = src->length(); |
@@ -3801,13 +3824,12 @@ AllocationResult Heap::CopyFixedArrayWithMap(FixedArray* src, Map* map) { |
AllocationResult allocation = AllocateRawFixedArray(len, NOT_TENURED); |
if (!allocation.To(&obj)) return allocation; |
} |
+ obj->set_map_no_write_barrier(map); |
if (InNewSpace(obj)) { |
- obj->set_map_no_write_barrier(map); |
CopyBlock(obj->address() + kPointerSize, src->address() + kPointerSize, |
FixedArray::SizeFor(len) - kPointerSize); |
return obj; |
} |
- obj->set_map_no_write_barrier(map); |
FixedArray* result = FixedArray::cast(obj); |
result->set_length(len); |