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 3804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3815 } | 3815 } |
3816 | 3816 |
3817 AllocationResult Heap::CopyFixedArrayWithMap(FixedArray* src, Map* map) { | 3817 AllocationResult Heap::CopyFixedArrayWithMap(FixedArray* src, Map* map) { |
3818 int len = src->length(); | 3818 int len = src->length(); |
3819 HeapObject* obj = nullptr; | 3819 HeapObject* obj = nullptr; |
3820 { | 3820 { |
3821 AllocationResult allocation = AllocateRawFixedArray(len, NOT_TENURED); | 3821 AllocationResult allocation = AllocateRawFixedArray(len, NOT_TENURED); |
3822 if (!allocation.To(&obj)) return allocation; | 3822 if (!allocation.To(&obj)) return allocation; |
3823 } | 3823 } |
3824 obj->set_map_no_write_barrier(map); | 3824 obj->set_map_no_write_barrier(map); |
3825 if (InNewSpace(obj)) { | 3825 |
| 3826 FixedArray* result = FixedArray::cast(obj); |
| 3827 DisallowHeapAllocation no_gc; |
| 3828 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); |
| 3829 |
| 3830 // Eliminate the write barrier if possible. |
| 3831 if (mode == SKIP_WRITE_BARRIER) { |
3826 CopyBlock(obj->address() + kPointerSize, src->address() + kPointerSize, | 3832 CopyBlock(obj->address() + kPointerSize, src->address() + kPointerSize, |
3827 FixedArray::SizeFor(len) - kPointerSize); | 3833 FixedArray::SizeFor(len) - kPointerSize); |
3828 return obj; | 3834 return obj; |
3829 } | 3835 } |
3830 FixedArray* result = FixedArray::cast(obj); | 3836 |
| 3837 // Slow case: Just copy the content one-by-one. |
3831 result->set_length(len); | 3838 result->set_length(len); |
3832 | |
3833 // Copy the content. | |
3834 DisallowHeapAllocation no_gc; | |
3835 WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); | |
3836 for (int i = 0; i < len; i++) result->set(i, src->get(i), mode); | 3839 for (int i = 0; i < len; i++) result->set(i, src->get(i), mode); |
3837 return result; | 3840 return result; |
3838 } | 3841 } |
3839 | 3842 |
3840 | 3843 |
3841 AllocationResult Heap::CopyFixedDoubleArrayWithMap(FixedDoubleArray* src, | 3844 AllocationResult Heap::CopyFixedDoubleArrayWithMap(FixedDoubleArray* src, |
3842 Map* map) { | 3845 Map* map) { |
3843 int len = src->length(); | 3846 int len = src->length(); |
3844 HeapObject* obj = nullptr; | 3847 HeapObject* obj = nullptr; |
3845 { | 3848 { |
(...skipping 2586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6432 } | 6435 } |
6433 | 6436 |
6434 | 6437 |
6435 // static | 6438 // static |
6436 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6439 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6437 return StaticVisitorBase::GetVisitorId(map); | 6440 return StaticVisitorBase::GetVisitorId(map); |
6438 } | 6441 } |
6439 | 6442 |
6440 } // namespace internal | 6443 } // namespace internal |
6441 } // namespace v8 | 6444 } // namespace v8 |
OLD | NEW |