Index: src/heap/heap.cc |
diff --git a/src/heap/heap.cc b/src/heap/heap.cc |
index 0432ee71fa0c329e6c1bf6e690883ab26f211a75..03af4c4e59a935d6cba4ec7b96dc395ab9a9da93 100644 |
--- a/src/heap/heap.cc |
+++ b/src/heap/heap.cc |
@@ -4426,7 +4426,7 @@ AllocationResult Heap::CopyAndTenureFixedCOWArray(FixedArray* src) { |
FixedArray* result = FixedArray::cast(obj); |
result->set_length(len); |
- // Copy the content |
+ // Copy the content. |
DisallowHeapAllocation no_gc; |
WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); |
for (int i = 0; i < len; i++) result->set(i, src->get(i), mode); |
@@ -4445,6 +4445,27 @@ AllocationResult Heap::AllocateEmptyFixedTypedArray( |
} |
+AllocationResult Heap::CopyFixedArrayAndGrow(FixedArray* src, int grow_by) { |
+ int old_len = src->length(); |
+ int new_len = old_len + grow_by; |
+ HeapObject* obj; |
+ { |
+ AllocationResult allocation = AllocateRawFixedArray(new_len, NOT_TENURED); |
+ 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 < old_len; i++) result->set(i, src->get(i), mode); |
+ MemsetPointer(result->data_start() + old_len, undefined_value(), grow_by); |
+ return result; |
+} |
+ |
+ |
AllocationResult Heap::CopyFixedArrayWithMap(FixedArray* src, Map* map) { |
int len = src->length(); |
HeapObject* obj; |
@@ -4462,7 +4483,7 @@ AllocationResult Heap::CopyFixedArrayWithMap(FixedArray* src, Map* map) { |
FixedArray* result = FixedArray::cast(obj); |
result->set_length(len); |
- // Copy the content |
+ // Copy the content. |
DisallowHeapAllocation no_gc; |
WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); |
for (int i = 0; i < len; i++) result->set(i, src->get(i), mode); |