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 2482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2493 | 2493 |
2494 static inline void EvacuateFixedTypedArray(Map* map, HeapObject** slot, | 2494 static inline void EvacuateFixedTypedArray(Map* map, HeapObject** slot, |
2495 HeapObject* object) { | 2495 HeapObject* object) { |
2496 int object_size = reinterpret_cast<FixedTypedArrayBase*>(object)->size(); | 2496 int object_size = reinterpret_cast<FixedTypedArrayBase*>(object)->size(); |
2497 EvacuateObject<DATA_OBJECT, kWordAligned>(map, slot, object, object_size); | 2497 EvacuateObject<DATA_OBJECT, kWordAligned>(map, slot, object, object_size); |
2498 | 2498 |
2499 MapWord map_word = object->map_word(); | 2499 MapWord map_word = object->map_word(); |
2500 DCHECK(map_word.IsForwardingAddress()); | 2500 DCHECK(map_word.IsForwardingAddress()); |
2501 FixedTypedArrayBase* target = | 2501 FixedTypedArrayBase* target = |
2502 reinterpret_cast<FixedTypedArrayBase*>(map_word.ToForwardingAddress()); | 2502 reinterpret_cast<FixedTypedArrayBase*>(map_word.ToForwardingAddress()); |
2503 if (target->base_pointer() != Smi::FromInt(0)) | 2503 target->set_base_pointer(target, SKIP_WRITE_BARRIER); |
2504 target->set_base_pointer(target, SKIP_WRITE_BARRIER); | |
2505 } | 2504 } |
2506 | 2505 |
2507 | 2506 |
2508 static inline void EvacuateFixedFloat64Array(Map* map, HeapObject** slot, | 2507 static inline void EvacuateFixedFloat64Array(Map* map, HeapObject** slot, |
2509 HeapObject* object) { | 2508 HeapObject* object) { |
2510 int object_size = reinterpret_cast<FixedFloat64Array*>(object)->size(); | 2509 int object_size = reinterpret_cast<FixedFloat64Array*>(object)->size(); |
2511 EvacuateObject<DATA_OBJECT, kDoubleAligned>(map, slot, object, object_size); | 2510 EvacuateObject<DATA_OBJECT, kDoubleAligned>(map, slot, object, object_size); |
2512 | 2511 |
2513 MapWord map_word = object->map_word(); | 2512 MapWord map_word = object->map_word(); |
2514 DCHECK(map_word.IsForwardingAddress()); | 2513 DCHECK(map_word.IsForwardingAddress()); |
2515 FixedTypedArrayBase* target = | 2514 FixedTypedArrayBase* target = |
2516 reinterpret_cast<FixedTypedArrayBase*>(map_word.ToForwardingAddress()); | 2515 reinterpret_cast<FixedTypedArrayBase*>(map_word.ToForwardingAddress()); |
2517 if (target->base_pointer() != Smi::FromInt(0)) | 2516 target->set_base_pointer(target, SKIP_WRITE_BARRIER); |
2518 target->set_base_pointer(target, SKIP_WRITE_BARRIER); | |
2519 } | 2517 } |
2520 | 2518 |
2521 | 2519 |
2522 static inline void EvacuateJSArrayBuffer(Map* map, HeapObject** slot, | 2520 static inline void EvacuateJSArrayBuffer(Map* map, HeapObject** slot, |
2523 HeapObject* object) { | 2521 HeapObject* object) { |
2524 ObjectEvacuationStrategy<POINTER_OBJECT>::Visit(map, slot, object); | 2522 ObjectEvacuationStrategy<POINTER_OBJECT>::Visit(map, slot, object); |
2525 | 2523 |
2526 Heap* heap = map->GetHeap(); | 2524 Heap* heap = map->GetHeap(); |
2527 MapWord map_word = object->map_word(); | 2525 MapWord map_word = object->map_word(); |
2528 DCHECK(map_word.IsForwardingAddress()); | 2526 DCHECK(map_word.IsForwardingAddress()); |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2999 ExternalOneByteString::kSize); | 2997 ExternalOneByteString::kSize); |
3000 if (!allocation.To(&obj)) return false; | 2998 if (!allocation.To(&obj)) return false; |
3001 set_native_source_string_map(Map::cast(obj)); | 2999 set_native_source_string_map(Map::cast(obj)); |
3002 } | 3000 } |
3003 | 3001 |
3004 ALLOCATE_VARSIZE_MAP(FIXED_DOUBLE_ARRAY_TYPE, fixed_double_array) | 3002 ALLOCATE_VARSIZE_MAP(FIXED_DOUBLE_ARRAY_TYPE, fixed_double_array) |
3005 ALLOCATE_VARSIZE_MAP(BYTE_ARRAY_TYPE, byte_array) | 3003 ALLOCATE_VARSIZE_MAP(BYTE_ARRAY_TYPE, byte_array) |
3006 ALLOCATE_VARSIZE_MAP(BYTECODE_ARRAY_TYPE, bytecode_array) | 3004 ALLOCATE_VARSIZE_MAP(BYTECODE_ARRAY_TYPE, bytecode_array) |
3007 ALLOCATE_VARSIZE_MAP(FREE_SPACE_TYPE, free_space) | 3005 ALLOCATE_VARSIZE_MAP(FREE_SPACE_TYPE, free_space) |
3008 | 3006 |
| 3007 #define ALLOCATE_EXTERNAL_ARRAY_MAP(Type, type, TYPE, ctype, size) \ |
| 3008 ALLOCATE_MAP(EXTERNAL_##TYPE##_ARRAY_TYPE, ExternalArray::kSize, \ |
| 3009 external_##type##_array) |
| 3010 |
| 3011 TYPED_ARRAYS(ALLOCATE_EXTERNAL_ARRAY_MAP) |
| 3012 #undef ALLOCATE_EXTERNAL_ARRAY_MAP |
| 3013 |
3009 #define ALLOCATE_FIXED_TYPED_ARRAY_MAP(Type, type, TYPE, ctype, size) \ | 3014 #define ALLOCATE_FIXED_TYPED_ARRAY_MAP(Type, type, TYPE, ctype, size) \ |
3010 ALLOCATE_VARSIZE_MAP(FIXED_##TYPE##_ARRAY_TYPE, fixed_##type##_array) | 3015 ALLOCATE_VARSIZE_MAP(FIXED_##TYPE##_ARRAY_TYPE, fixed_##type##_array) |
3011 | 3016 |
3012 TYPED_ARRAYS(ALLOCATE_FIXED_TYPED_ARRAY_MAP) | 3017 TYPED_ARRAYS(ALLOCATE_FIXED_TYPED_ARRAY_MAP) |
3013 #undef ALLOCATE_FIXED_TYPED_ARRAY_MAP | 3018 #undef ALLOCATE_FIXED_TYPED_ARRAY_MAP |
3014 | 3019 |
3015 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, sloppy_arguments_elements) | 3020 ALLOCATE_VARSIZE_MAP(FIXED_ARRAY_TYPE, sloppy_arguments_elements) |
3016 | 3021 |
3017 ALLOCATE_VARSIZE_MAP(CODE_TYPE, code) | 3022 ALLOCATE_VARSIZE_MAP(CODE_TYPE, code) |
3018 | 3023 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3064 | 3069 |
3065 BytecodeArray* bytecode_array; | 3070 BytecodeArray* bytecode_array; |
3066 AllocationResult allocation = | 3071 AllocationResult allocation = |
3067 AllocateBytecodeArray(0, nullptr, kPointerSize); | 3072 AllocateBytecodeArray(0, nullptr, kPointerSize); |
3068 if (!allocation.To(&bytecode_array)) { | 3073 if (!allocation.To(&bytecode_array)) { |
3069 return false; | 3074 return false; |
3070 } | 3075 } |
3071 set_empty_bytecode_array(bytecode_array); | 3076 set_empty_bytecode_array(bytecode_array); |
3072 } | 3077 } |
3073 | 3078 |
| 3079 #define ALLOCATE_EMPTY_EXTERNAL_ARRAY(Type, type, TYPE, ctype, size) \ |
| 3080 { \ |
| 3081 ExternalArray* obj; \ |
| 3082 if (!AllocateEmptyExternalArray(kExternal##Type##Array).To(&obj)) \ |
| 3083 return false; \ |
| 3084 set_empty_external_##type##_array(obj); \ |
| 3085 } |
| 3086 |
| 3087 TYPED_ARRAYS(ALLOCATE_EMPTY_EXTERNAL_ARRAY) |
| 3088 #undef ALLOCATE_EMPTY_EXTERNAL_ARRAY |
| 3089 |
3074 #define ALLOCATE_EMPTY_FIXED_TYPED_ARRAY(Type, type, TYPE, ctype, size) \ | 3090 #define ALLOCATE_EMPTY_FIXED_TYPED_ARRAY(Type, type, TYPE, ctype, size) \ |
3075 { \ | 3091 { \ |
3076 FixedTypedArrayBase* obj; \ | 3092 FixedTypedArrayBase* obj; \ |
3077 if (!AllocateEmptyFixedTypedArray(kExternal##Type##Array).To(&obj)) \ | 3093 if (!AllocateEmptyFixedTypedArray(kExternal##Type##Array).To(&obj)) \ |
3078 return false; \ | 3094 return false; \ |
3079 set_empty_fixed_##type##_array(obj); \ | 3095 set_empty_fixed_##type##_array(obj); \ |
3080 } | 3096 } |
3081 | 3097 |
3082 TYPED_ARRAYS(ALLOCATE_EMPTY_FIXED_TYPED_ARRAY) | 3098 TYPED_ARRAYS(ALLOCATE_EMPTY_FIXED_TYPED_ARRAY) |
3083 #undef ALLOCATE_EMPTY_FIXED_TYPED_ARRAY | 3099 #undef ALLOCATE_EMPTY_FIXED_TYPED_ARRAY |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3679 // releasing an evacuation candidate due to a slots buffer overflow | 3695 // releasing an evacuation candidate due to a slots buffer overflow |
3680 // results in lost pages. | 3696 // results in lost pages. |
3681 mark_compact_collector()->RecordSlot(slot, slot, *slot, | 3697 mark_compact_collector()->RecordSlot(slot, slot, *slot, |
3682 SlotsBuffer::IGNORE_OVERFLOW); | 3698 SlotsBuffer::IGNORE_OVERFLOW); |
3683 } | 3699 } |
3684 allocation_sites_scratchpad_length_++; | 3700 allocation_sites_scratchpad_length_++; |
3685 } | 3701 } |
3686 } | 3702 } |
3687 | 3703 |
3688 | 3704 |
| 3705 Map* Heap::MapForExternalArrayType(ExternalArrayType array_type) { |
| 3706 return Map::cast(roots_[RootIndexForExternalArrayType(array_type)]); |
| 3707 } |
| 3708 |
| 3709 |
| 3710 Heap::RootListIndex Heap::RootIndexForExternalArrayType( |
| 3711 ExternalArrayType array_type) { |
| 3712 switch (array_type) { |
| 3713 #define ARRAY_TYPE_TO_ROOT_INDEX(Type, type, TYPE, ctype, size) \ |
| 3714 case kExternal##Type##Array: \ |
| 3715 return kExternal##Type##ArrayMapRootIndex; |
| 3716 |
| 3717 TYPED_ARRAYS(ARRAY_TYPE_TO_ROOT_INDEX) |
| 3718 #undef ARRAY_TYPE_TO_ROOT_INDEX |
| 3719 |
| 3720 default: |
| 3721 UNREACHABLE(); |
| 3722 return kUndefinedValueRootIndex; |
| 3723 } |
| 3724 } |
| 3725 |
3689 | 3726 |
3690 Map* Heap::MapForFixedTypedArray(ExternalArrayType array_type) { | 3727 Map* Heap::MapForFixedTypedArray(ExternalArrayType array_type) { |
3691 return Map::cast(roots_[RootIndexForFixedTypedArray(array_type)]); | 3728 return Map::cast(roots_[RootIndexForFixedTypedArray(array_type)]); |
3692 } | 3729 } |
3693 | 3730 |
3694 | 3731 |
3695 Heap::RootListIndex Heap::RootIndexForFixedTypedArray( | 3732 Heap::RootListIndex Heap::RootIndexForFixedTypedArray( |
3696 ExternalArrayType array_type) { | 3733 ExternalArrayType array_type) { |
3697 switch (array_type) { | 3734 switch (array_type) { |
3698 #define ARRAY_TYPE_TO_ROOT_INDEX(Type, type, TYPE, ctype, size) \ | 3735 #define ARRAY_TYPE_TO_ROOT_INDEX(Type, type, TYPE, ctype, size) \ |
3699 case kExternal##Type##Array: \ | 3736 case kExternal##Type##Array: \ |
3700 return kFixed##Type##ArrayMapRootIndex; | 3737 return kFixed##Type##ArrayMapRootIndex; |
3701 | 3738 |
3702 TYPED_ARRAYS(ARRAY_TYPE_TO_ROOT_INDEX) | 3739 TYPED_ARRAYS(ARRAY_TYPE_TO_ROOT_INDEX) |
3703 #undef ARRAY_TYPE_TO_ROOT_INDEX | 3740 #undef ARRAY_TYPE_TO_ROOT_INDEX |
3704 | 3741 |
3705 default: | 3742 default: |
3706 UNREACHABLE(); | 3743 UNREACHABLE(); |
3707 return kUndefinedValueRootIndex; | 3744 return kUndefinedValueRootIndex; |
3708 } | 3745 } |
3709 } | 3746 } |
3710 | 3747 |
3711 | 3748 |
| 3749 Heap::RootListIndex Heap::RootIndexForEmptyExternalArray( |
| 3750 ElementsKind elementsKind) { |
| 3751 switch (elementsKind) { |
| 3752 #define ELEMENT_KIND_TO_ROOT_INDEX(Type, type, TYPE, ctype, size) \ |
| 3753 case EXTERNAL_##TYPE##_ELEMENTS: \ |
| 3754 return kEmptyExternal##Type##ArrayRootIndex; |
| 3755 |
| 3756 TYPED_ARRAYS(ELEMENT_KIND_TO_ROOT_INDEX) |
| 3757 #undef ELEMENT_KIND_TO_ROOT_INDEX |
| 3758 |
| 3759 default: |
| 3760 UNREACHABLE(); |
| 3761 return kUndefinedValueRootIndex; |
| 3762 } |
| 3763 } |
| 3764 |
| 3765 |
3712 Heap::RootListIndex Heap::RootIndexForEmptyFixedTypedArray( | 3766 Heap::RootListIndex Heap::RootIndexForEmptyFixedTypedArray( |
3713 ElementsKind elementsKind) { | 3767 ElementsKind elementsKind) { |
3714 switch (elementsKind) { | 3768 switch (elementsKind) { |
3715 #define ELEMENT_KIND_TO_ROOT_INDEX(Type, type, TYPE, ctype, size) \ | 3769 #define ELEMENT_KIND_TO_ROOT_INDEX(Type, type, TYPE, ctype, size) \ |
3716 case TYPE##_ELEMENTS: \ | 3770 case TYPE##_ELEMENTS: \ |
3717 return kEmptyFixed##Type##ArrayRootIndex; | 3771 return kEmptyFixed##Type##ArrayRootIndex; |
3718 | 3772 |
3719 TYPED_ARRAYS(ELEMENT_KIND_TO_ROOT_INDEX) | 3773 TYPED_ARRAYS(ELEMENT_KIND_TO_ROOT_INDEX) |
3720 #undef ELEMENT_KIND_TO_ROOT_INDEX | 3774 #undef ELEMENT_KIND_TO_ROOT_INDEX |
3721 default: | 3775 default: |
3722 UNREACHABLE(); | 3776 UNREACHABLE(); |
3723 return kUndefinedValueRootIndex; | 3777 return kUndefinedValueRootIndex; |
3724 } | 3778 } |
3725 } | 3779 } |
3726 | 3780 |
3727 | 3781 |
| 3782 ExternalArray* Heap::EmptyExternalArrayForMap(Map* map) { |
| 3783 return ExternalArray::cast( |
| 3784 roots_[RootIndexForEmptyExternalArray(map->elements_kind())]); |
| 3785 } |
| 3786 |
| 3787 |
3728 FixedTypedArrayBase* Heap::EmptyFixedTypedArrayForMap(Map* map) { | 3788 FixedTypedArrayBase* Heap::EmptyFixedTypedArrayForMap(Map* map) { |
3729 return FixedTypedArrayBase::cast( | 3789 return FixedTypedArrayBase::cast( |
3730 roots_[RootIndexForEmptyFixedTypedArray(map->elements_kind())]); | 3790 roots_[RootIndexForEmptyFixedTypedArray(map->elements_kind())]); |
3731 } | 3791 } |
3732 | 3792 |
3733 | 3793 |
3734 AllocationResult Heap::AllocateForeign(Address address, | 3794 AllocationResult Heap::AllocateForeign(Address address, |
3735 PretenureFlag pretenure) { | 3795 PretenureFlag pretenure) { |
3736 // Statically ensure that it is safe to allocate foreigns in paged spaces. | 3796 // Statically ensure that it is safe to allocate foreigns in paged spaces. |
3737 STATIC_ASSERT(Foreign::kSize <= Page::kMaxRegularHeapObjectSize); | 3797 STATIC_ASSERT(Foreign::kSize <= Page::kMaxRegularHeapObjectSize); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3938 | 3998 |
3939 // Notify the heap profiler of change in object layout. The array may not be | 3999 // Notify the heap profiler of change in object layout. The array may not be |
3940 // moved during GC, and size has to be adjusted nevertheless. | 4000 // moved during GC, and size has to be adjusted nevertheless. |
3941 HeapProfiler* profiler = isolate()->heap_profiler(); | 4001 HeapProfiler* profiler = isolate()->heap_profiler(); |
3942 if (profiler->is_tracking_allocations()) { | 4002 if (profiler->is_tracking_allocations()) { |
3943 profiler->UpdateObjectSizeEvent(object->address(), object->Size()); | 4003 profiler->UpdateObjectSizeEvent(object->address(), object->Size()); |
3944 } | 4004 } |
3945 } | 4005 } |
3946 | 4006 |
3947 | 4007 |
3948 AllocationResult Heap::AllocateFixedTypedArrayWithExternalPointer( | 4008 AllocationResult Heap::AllocateExternalArray(int length, |
3949 int length, ExternalArrayType array_type, void* external_pointer, | 4009 ExternalArrayType array_type, |
3950 PretenureFlag pretenure) { | 4010 void* external_pointer, |
3951 int size = FixedTypedArrayBase::kHeaderSize; | 4011 PretenureFlag pretenure) { |
| 4012 int size = ExternalArray::kSize; |
3952 AllocationSpace space = SelectSpace(size, pretenure); | 4013 AllocationSpace space = SelectSpace(size, pretenure); |
3953 HeapObject* result; | 4014 HeapObject* result; |
3954 { | 4015 { |
3955 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); | 4016 AllocationResult allocation = AllocateRaw(size, space, OLD_SPACE); |
3956 if (!allocation.To(&result)) return allocation; | 4017 if (!allocation.To(&result)) return allocation; |
3957 } | 4018 } |
3958 | 4019 |
3959 result->set_map_no_write_barrier(MapForFixedTypedArray(array_type)); | 4020 result->set_map_no_write_barrier(MapForExternalArrayType(array_type)); |
3960 FixedTypedArrayBase* elements = FixedTypedArrayBase::cast(result); | 4021 ExternalArray::cast(result)->set_length(length); |
3961 elements->set_base_pointer(Smi::FromInt(0), SKIP_WRITE_BARRIER); | 4022 ExternalArray::cast(result)->set_external_pointer(external_pointer); |
3962 elements->set_external_pointer(external_pointer, SKIP_WRITE_BARRIER); | 4023 return result; |
3963 elements->set_length(length); | |
3964 return elements; | |
3965 } | 4024 } |
3966 | 4025 |
3967 static void ForFixedTypedArray(ExternalArrayType array_type, int* element_size, | 4026 static void ForFixedTypedArray(ExternalArrayType array_type, int* element_size, |
3968 ElementsKind* element_kind) { | 4027 ElementsKind* element_kind) { |
3969 switch (array_type) { | 4028 switch (array_type) { |
3970 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ | 4029 #define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ |
3971 case kExternal##Type##Array: \ | 4030 case kExternal##Type##Array: \ |
3972 *element_size = size; \ | 4031 *element_size = size; \ |
3973 *element_kind = TYPE##_ELEMENTS; \ | 4032 *element_kind = TYPE##_ELEMENTS; \ |
3974 return; | 4033 return; |
(...skipping 19 matching lines...) Expand all Loading... |
3994 int size = OBJECT_POINTER_ALIGN(length * element_size + | 4053 int size = OBJECT_POINTER_ALIGN(length * element_size + |
3995 FixedTypedArrayBase::kDataOffset); | 4054 FixedTypedArrayBase::kDataOffset); |
3996 AllocationSpace space = SelectSpace(size, pretenure); | 4055 AllocationSpace space = SelectSpace(size, pretenure); |
3997 | 4056 |
3998 HeapObject* object; | 4057 HeapObject* object; |
3999 AllocationResult allocation = AllocateRaw( | 4058 AllocationResult allocation = AllocateRaw( |
4000 size, space, OLD_SPACE, | 4059 size, space, OLD_SPACE, |
4001 array_type == kExternalFloat64Array ? kDoubleAligned : kWordAligned); | 4060 array_type == kExternalFloat64Array ? kDoubleAligned : kWordAligned); |
4002 if (!allocation.To(&object)) return allocation; | 4061 if (!allocation.To(&object)) return allocation; |
4003 | 4062 |
4004 object->set_map_no_write_barrier(MapForFixedTypedArray(array_type)); | 4063 object->set_map(MapForFixedTypedArray(array_type)); |
4005 FixedTypedArrayBase* elements = FixedTypedArrayBase::cast(object); | 4064 FixedTypedArrayBase* elements = FixedTypedArrayBase::cast(object); |
4006 elements->set_base_pointer(elements, SKIP_WRITE_BARRIER); | 4065 elements->set_base_pointer(elements, SKIP_WRITE_BARRIER); |
4007 elements->set_external_pointer( | 4066 elements->set_external_pointer( |
4008 ExternalReference::fixed_typed_array_base_data_offset().address(), | 4067 ExternalReference::fixed_typed_array_base_data_offset().address(), |
4009 SKIP_WRITE_BARRIER); | 4068 SKIP_WRITE_BARRIER); |
4010 elements->set_length(length); | 4069 elements->set_length(length); |
4011 if (initialize) memset(elements->DataPtr(), 0, elements->DataSize()); | 4070 if (initialize) memset(elements->DataPtr(), 0, elements->DataSize()); |
4012 return elements; | 4071 return elements; |
4013 } | 4072 } |
4014 | 4073 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4209 | 4268 |
4210 // Allocate the JSObject. | 4269 // Allocate the JSObject. |
4211 int size = map->instance_size(); | 4270 int size = map->instance_size(); |
4212 AllocationSpace space = SelectSpace(size, pretenure); | 4271 AllocationSpace space = SelectSpace(size, pretenure); |
4213 JSObject* js_obj; | 4272 JSObject* js_obj; |
4214 AllocationResult allocation = Allocate(map, space, allocation_site); | 4273 AllocationResult allocation = Allocate(map, space, allocation_site); |
4215 if (!allocation.To(&js_obj)) return allocation; | 4274 if (!allocation.To(&js_obj)) return allocation; |
4216 | 4275 |
4217 // Initialize the JSObject. | 4276 // Initialize the JSObject. |
4218 InitializeJSObjectFromMap(js_obj, properties, map); | 4277 InitializeJSObjectFromMap(js_obj, properties, map); |
4219 DCHECK(js_obj->HasFastElements() || js_obj->HasFixedTypedArrayElements()); | 4278 DCHECK(js_obj->HasFastElements() || js_obj->HasExternalArrayElements() || |
| 4279 js_obj->HasFixedTypedArrayElements()); |
4220 return js_obj; | 4280 return js_obj; |
4221 } | 4281 } |
4222 | 4282 |
4223 | 4283 |
4224 AllocationResult Heap::AllocateJSObject(JSFunction* constructor, | 4284 AllocationResult Heap::AllocateJSObject(JSFunction* constructor, |
4225 PretenureFlag pretenure, | 4285 PretenureFlag pretenure, |
4226 AllocationSite* allocation_site) { | 4286 AllocationSite* allocation_site) { |
4227 DCHECK(constructor->has_initial_map()); | 4287 DCHECK(constructor->has_initial_map()); |
4228 | 4288 |
4229 // Allocate the object based on the constructors initial map. | 4289 // Allocate the object based on the constructors initial map. |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4501 AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); | 4561 AllocationResult allocation = AllocateRaw(size, OLD_SPACE, OLD_SPACE); |
4502 if (!allocation.To(&result)) return allocation; | 4562 if (!allocation.To(&result)) return allocation; |
4503 } | 4563 } |
4504 // Initialize the object. | 4564 // Initialize the object. |
4505 result->set_map_no_write_barrier(fixed_array_map()); | 4565 result->set_map_no_write_barrier(fixed_array_map()); |
4506 FixedArray::cast(result)->set_length(0); | 4566 FixedArray::cast(result)->set_length(0); |
4507 return result; | 4567 return result; |
4508 } | 4568 } |
4509 | 4569 |
4510 | 4570 |
| 4571 AllocationResult Heap::AllocateEmptyExternalArray( |
| 4572 ExternalArrayType array_type) { |
| 4573 return AllocateExternalArray(0, array_type, NULL, TENURED); |
| 4574 } |
| 4575 |
| 4576 |
4511 AllocationResult Heap::CopyAndTenureFixedCOWArray(FixedArray* src) { | 4577 AllocationResult Heap::CopyAndTenureFixedCOWArray(FixedArray* src) { |
4512 if (!InNewSpace(src)) { | 4578 if (!InNewSpace(src)) { |
4513 return src; | 4579 return src; |
4514 } | 4580 } |
4515 | 4581 |
4516 int len = src->length(); | 4582 int len = src->length(); |
4517 HeapObject* obj; | 4583 HeapObject* obj; |
4518 { | 4584 { |
4519 AllocationResult allocation = AllocateRawFixedArray(len, TENURED); | 4585 AllocationResult allocation = AllocateRawFixedArray(len, TENURED); |
4520 if (!allocation.To(&obj)) return allocation; | 4586 if (!allocation.To(&obj)) return allocation; |
(...skipping 2402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6923 *object_type = "CODE_TYPE"; \ | 6989 *object_type = "CODE_TYPE"; \ |
6924 *object_sub_type = "CODE_AGE/" #name; \ | 6990 *object_sub_type = "CODE_AGE/" #name; \ |
6925 return true; | 6991 return true; |
6926 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6992 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
6927 #undef COMPARE_AND_RETURN_NAME | 6993 #undef COMPARE_AND_RETURN_NAME |
6928 } | 6994 } |
6929 return false; | 6995 return false; |
6930 } | 6996 } |
6931 } // namespace internal | 6997 } // namespace internal |
6932 } // namespace v8 | 6998 } // namespace v8 |
OLD | NEW |