Chromium Code Reviews| Index: src/heap/heap.cc |
| diff --git a/src/heap/heap.cc b/src/heap/heap.cc |
| index 6b098a3f5bd187e3cec25be32bd55fe5df45e5aa..509fb7dacc299e50e102c99f63e2e7f9696277d7 100644 |
| --- a/src/heap/heap.cc |
| +++ b/src/heap/heap.cc |
| @@ -3822,17 +3822,20 @@ AllocationResult Heap::CopyFixedArrayWithMap(FixedArray* src, Map* map) { |
| if (!allocation.To(&obj)) return allocation; |
| } |
| obj->set_map_no_write_barrier(map); |
| - if (InNewSpace(obj)) { |
| + |
| + FixedArray* result = FixedArray::cast(obj); |
| + DisallowHeapAllocation no_gc; |
| + WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); |
| + |
| + // Eliminate the write barrier if possible. |
| + if (InNewSpace(obj) && (mode == SKIP_WRITE_BARRIER)) { |
|
Hannes Payer (out of office)
2016/07/28 15:30:53
You can skip the new space check, since GetWriteBa
Michael Lippautz
2016/07/28 15:32:26
Done.
|
| CopyBlock(obj->address() + kPointerSize, src->address() + kPointerSize, |
| FixedArray::SizeFor(len) - kPointerSize); |
| return obj; |
| } |
| - FixedArray* result = FixedArray::cast(obj); |
| - result->set_length(len); |
| - // Copy the content. |
| - DisallowHeapAllocation no_gc; |
| - WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); |
| + // Slow case: Just copy the content one-by-one. |
| + result->set_length(len); |
| for (int i = 0; i < len; i++) result->set(i, src->get(i), mode); |
| return result; |
| } |