| Index: src/heap.cc
|
| diff --git a/src/heap.cc b/src/heap.cc
|
| index 4e0e8a67c2217213c0c0a28939d8d147f01fec47..aee1d533656ec0c78f2b387e6c0aa34cd399f5d3 100644
|
| --- a/src/heap.cc
|
| +++ b/src/heap.cc
|
| @@ -2925,6 +2925,16 @@ bool Heap::CreateInitialMaps() {
|
|
|
| TYPED_ARRAYS(ALLOCATE_EMPTY_EXTERNAL_ARRAY)
|
| #undef ALLOCATE_EMPTY_EXTERNAL_ARRAY
|
| +
|
| +#define ALLOCATE_EMPTY_FIXED_TYPED_ARRAY(Type, type, TYPE, ctype, size) \
|
| + { FixedTypedArrayBase* obj; \
|
| + if (!AllocateEmptyFixedTypedArray(kExternal##Type##Array)->To(&obj)) \
|
| + return false; \
|
| + set_empty_fixed_##type##_array(obj); \
|
| + }
|
| +
|
| + TYPED_ARRAYS(ALLOCATE_EMPTY_FIXED_TYPED_ARRAY)
|
| +#undef ALLOCATE_EMPTY_FIXED_TYPED_ARRAY
|
| }
|
| ASSERT(!InNewSpace(empty_fixed_array()));
|
| return true;
|
| @@ -3750,12 +3760,34 @@ Heap::RootListIndex Heap::RootIndexForEmptyExternalArray(
|
| }
|
|
|
|
|
| +Heap::RootListIndex Heap::RootIndexForEmptyFixedTypedArray(
|
| + ElementsKind elementsKind) {
|
| + switch (elementsKind) {
|
| +#define ELEMENT_KIND_TO_ROOT_INDEX(Type, type, TYPE, ctype, size) \
|
| + case TYPE##_ELEMENTS: \
|
| + return kEmptyFixed##Type##ArrayRootIndex;
|
| +
|
| + TYPED_ARRAYS(ELEMENT_KIND_TO_ROOT_INDEX)
|
| +#undef ELEMENT_KIND_TO_ROOT_INDEX
|
| + default:
|
| + UNREACHABLE();
|
| + return kUndefinedValueRootIndex;
|
| + }
|
| +}
|
| +
|
| +
|
| ExternalArray* Heap::EmptyExternalArrayForMap(Map* map) {
|
| return ExternalArray::cast(
|
| roots_[RootIndexForEmptyExternalArray(map->elements_kind())]);
|
| }
|
|
|
|
|
| +FixedTypedArrayBase* Heap::EmptyFixedTypedArrayForMap(Map* map) {
|
| + return FixedTypedArrayBase::cast(
|
| + roots_[RootIndexForEmptyFixedTypedArray(map->elements_kind())]);
|
| +}
|
| +
|
| +
|
| MaybeObject* Heap::NumberFromDouble(double value, PretenureFlag pretenure) {
|
| // We need to distinguish the minus zero value and this cannot be
|
| // done after conversion to int. Doing this by comparing bit
|
| @@ -4027,6 +4059,7 @@ MaybeObject* Heap::AllocateFixedTypedArray(int length,
|
| reinterpret_cast<FixedTypedArrayBase*>(object);
|
| elements->set_map(MapForFixedTypedArray(array_type));
|
| elements->set_length(length);
|
| + memset(elements->DataPtr(), 0, elements->DataSize());
|
| return elements;
|
| }
|
|
|
| @@ -4394,7 +4427,8 @@ MaybeObject* Heap::AllocateJSObjectFromMap(
|
| // Initialize the JSObject.
|
| InitializeJSObjectFromMap(JSObject::cast(obj), properties, map);
|
| ASSERT(JSObject::cast(obj)->HasFastElements() ||
|
| - JSObject::cast(obj)->HasExternalArrayElements());
|
| + JSObject::cast(obj)->HasExternalArrayElements() ||
|
| + JSObject::cast(obj)->HasFixedTypedArrayElements());
|
| return obj;
|
| }
|
|
|
| @@ -5038,6 +5072,11 @@ MaybeObject* Heap::AllocateEmptyExternalArray(ExternalArrayType array_type) {
|
| }
|
|
|
|
|
| +MaybeObject* Heap::AllocateEmptyFixedTypedArray(ExternalArrayType array_type) {
|
| + return AllocateFixedTypedArray(0, array_type, TENURED);
|
| +}
|
| +
|
| +
|
| MaybeObject* Heap::CopyFixedArrayWithMap(FixedArray* src, Map* map) {
|
| int len = src->length();
|
| Object* obj;
|
|
|