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/v8.h" | 5 #include "src/v8.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/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
(...skipping 3712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3723 default: | 3723 default: |
3724 *element_size = 0; // Bogus | 3724 *element_size = 0; // Bogus |
3725 *element_kind = UINT8_ELEMENTS; // Bogus | 3725 *element_kind = UINT8_ELEMENTS; // Bogus |
3726 UNREACHABLE(); | 3726 UNREACHABLE(); |
3727 } | 3727 } |
3728 } | 3728 } |
3729 | 3729 |
3730 | 3730 |
3731 AllocationResult Heap::AllocateFixedTypedArray(int length, | 3731 AllocationResult Heap::AllocateFixedTypedArray(int length, |
3732 ExternalArrayType array_type, | 3732 ExternalArrayType array_type, |
| 3733 bool initialize, |
3733 PretenureFlag pretenure) { | 3734 PretenureFlag pretenure) { |
3734 int element_size; | 3735 int element_size; |
3735 ElementsKind elements_kind; | 3736 ElementsKind elements_kind; |
3736 ForFixedTypedArray(array_type, &element_size, &elements_kind); | 3737 ForFixedTypedArray(array_type, &element_size, &elements_kind); |
3737 int size = OBJECT_POINTER_ALIGN(length * element_size + | 3738 int size = OBJECT_POINTER_ALIGN(length * element_size + |
3738 FixedTypedArrayBase::kDataOffset); | 3739 FixedTypedArrayBase::kDataOffset); |
3739 AllocationSpace space = SelectSpace(size, pretenure); | 3740 AllocationSpace space = SelectSpace(size, pretenure); |
3740 | 3741 |
3741 HeapObject* object; | 3742 HeapObject* object; |
3742 AllocationResult allocation = AllocateRaw( | 3743 AllocationResult allocation = AllocateRaw( |
3743 size, space, OLD_SPACE, | 3744 size, space, OLD_SPACE, |
3744 array_type == kExternalFloat64Array ? kDoubleAligned : kWordAligned); | 3745 array_type == kExternalFloat64Array ? kDoubleAligned : kWordAligned); |
3745 if (!allocation.To(&object)) return allocation; | 3746 if (!allocation.To(&object)) return allocation; |
3746 | 3747 |
3747 object->set_map(MapForFixedTypedArray(array_type)); | 3748 object->set_map(MapForFixedTypedArray(array_type)); |
3748 FixedTypedArrayBase* elements = FixedTypedArrayBase::cast(object); | 3749 FixedTypedArrayBase* elements = FixedTypedArrayBase::cast(object); |
3749 elements->set_length(length); | 3750 elements->set_length(length); |
3750 memset(elements->DataPtr(), 0, elements->DataSize()); | 3751 if (initialize) memset(elements->DataPtr(), 0, elements->DataSize()); |
3751 return elements; | 3752 return elements; |
3752 } | 3753 } |
3753 | 3754 |
3754 | 3755 |
3755 AllocationResult Heap::AllocateCode(int object_size, bool immovable) { | 3756 AllocationResult Heap::AllocateCode(int object_size, bool immovable) { |
3756 DCHECK(IsAligned(static_cast<intptr_t>(object_size), kCodeAlignment)); | 3757 DCHECK(IsAligned(static_cast<intptr_t>(object_size), kCodeAlignment)); |
3757 AllocationResult allocation = | 3758 AllocationResult allocation = |
3758 AllocateRaw(object_size, CODE_SPACE, CODE_SPACE); | 3759 AllocateRaw(object_size, CODE_SPACE, CODE_SPACE); |
3759 | 3760 |
3760 HeapObject* result; | 3761 HeapObject* result; |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4310 // TODO(mvstanton): The map is set twice because of protection against calling | 4311 // TODO(mvstanton): The map is set twice because of protection against calling |
4311 // set() on a COW FixedArray. Issue v8:3221 created to track this, and | 4312 // set() on a COW FixedArray. Issue v8:3221 created to track this, and |
4312 // we might then be able to remove this whole method. | 4313 // we might then be able to remove this whole method. |
4313 HeapObject::cast(obj)->set_map_no_write_barrier(fixed_cow_array_map()); | 4314 HeapObject::cast(obj)->set_map_no_write_barrier(fixed_cow_array_map()); |
4314 return result; | 4315 return result; |
4315 } | 4316 } |
4316 | 4317 |
4317 | 4318 |
4318 AllocationResult Heap::AllocateEmptyFixedTypedArray( | 4319 AllocationResult Heap::AllocateEmptyFixedTypedArray( |
4319 ExternalArrayType array_type) { | 4320 ExternalArrayType array_type) { |
4320 return AllocateFixedTypedArray(0, array_type, TENURED); | 4321 return AllocateFixedTypedArray(0, array_type, false, TENURED); |
4321 } | 4322 } |
4322 | 4323 |
4323 | 4324 |
4324 AllocationResult Heap::CopyFixedArrayWithMap(FixedArray* src, Map* map) { | 4325 AllocationResult Heap::CopyFixedArrayWithMap(FixedArray* src, Map* map) { |
4325 int len = src->length(); | 4326 int len = src->length(); |
4326 HeapObject* obj; | 4327 HeapObject* obj; |
4327 { | 4328 { |
4328 AllocationResult allocation = AllocateRawFixedArray(len, NOT_TENURED); | 4329 AllocationResult allocation = AllocateRawFixedArray(len, NOT_TENURED); |
4329 if (!allocation.To(&obj)) return allocation; | 4330 if (!allocation.To(&obj)) return allocation; |
4330 } | 4331 } |
(...skipping 2334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6665 *object_type = "CODE_TYPE"; \ | 6666 *object_type = "CODE_TYPE"; \ |
6666 *object_sub_type = "CODE_AGE/" #name; \ | 6667 *object_sub_type = "CODE_AGE/" #name; \ |
6667 return true; | 6668 return true; |
6668 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6669 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
6669 #undef COMPARE_AND_RETURN_NAME | 6670 #undef COMPARE_AND_RETURN_NAME |
6670 } | 6671 } |
6671 return false; | 6672 return false; |
6672 } | 6673 } |
6673 } | 6674 } |
6674 } // namespace v8::internal | 6675 } // namespace v8::internal |
OLD | NEW |