| Index: src/heap.cc
|
| diff --git a/src/heap.cc b/src/heap.cc
|
| index 42e56ca1eb9e2bb40498d9ea2d341c71a67f6b4e..e1731db553e3cfd540459214ab92f964e5bb280e 100644
|
| --- a/src/heap.cc
|
| +++ b/src/heap.cc
|
| @@ -2926,6 +2926,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;
|
| @@ -3724,12 +3734,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
|
| @@ -4000,6 +4032,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;
|
| }
|
|
|
| @@ -4376,7 +4409,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;
|
| }
|
|
|
| @@ -5083,6 +5117,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;
|
|
|