Chromium Code Reviews| Index: src/heap/heap.cc |
| diff --git a/src/heap/heap.cc b/src/heap/heap.cc |
| index 073bffcf897ea39ee19f19651f7382920f1def04..c2d5ab128f282e12457c5883575e3318a2ad57d7 100644 |
| --- a/src/heap/heap.cc |
| +++ b/src/heap/heap.cc |
| @@ -2500,7 +2500,8 @@ class ScavengingVisitor : public StaticVisitorBase { |
| DCHECK(map_word.IsForwardingAddress()); |
| FixedTypedArrayBase* target = |
| reinterpret_cast<FixedTypedArrayBase*>(map_word.ToForwardingAddress()); |
| - target->set_base_pointer(target, SKIP_WRITE_BARRIER); |
| + if (target->base_pointer() != Smi::FromInt(0)) |
| + target->set_base_pointer(target, SKIP_WRITE_BARRIER); |
| } |
| @@ -2513,7 +2514,8 @@ class ScavengingVisitor : public StaticVisitorBase { |
| DCHECK(map_word.IsForwardingAddress()); |
| FixedTypedArrayBase* target = |
| reinterpret_cast<FixedTypedArrayBase*>(map_word.ToForwardingAddress()); |
| - target->set_base_pointer(target, SKIP_WRITE_BARRIER); |
| + if (target->base_pointer() != Smi::FromInt(0)) |
| + target->set_base_pointer(target, SKIP_WRITE_BARRIER); |
| } |
| @@ -3003,13 +3005,6 @@ bool Heap::CreateInitialMaps() { |
| ALLOCATE_VARSIZE_MAP(BYTE_ARRAY_TYPE, byte_array) |
| ALLOCATE_VARSIZE_MAP(FREE_SPACE_TYPE, free_space) |
| -#define ALLOCATE_EXTERNAL_ARRAY_MAP(Type, type, TYPE, ctype, size) \ |
| - ALLOCATE_MAP(EXTERNAL_##TYPE##_ARRAY_TYPE, ExternalArray::kSize, \ |
| - external_##type##_array) |
| - |
| - TYPED_ARRAYS(ALLOCATE_EXTERNAL_ARRAY_MAP) |
| -#undef ALLOCATE_EXTERNAL_ARRAY_MAP |
| - |
| #define ALLOCATE_FIXED_TYPED_ARRAY_MAP(Type, type, TYPE, ctype, size) \ |
| ALLOCATE_VARSIZE_MAP(FIXED_##TYPE##_ARRAY_TYPE, fixed_##type##_array) |
| @@ -3067,17 +3062,6 @@ bool Heap::CreateInitialMaps() { |
| set_empty_byte_array(byte_array); |
| } |
| -#define ALLOCATE_EMPTY_EXTERNAL_ARRAY(Type, type, TYPE, ctype, size) \ |
| - { \ |
| - ExternalArray* obj; \ |
| - if (!AllocateEmptyExternalArray(kExternal##Type##Array).To(&obj)) \ |
| - return false; \ |
| - set_empty_external_##type##_array(obj); \ |
| - } |
| - |
| - TYPED_ARRAYS(ALLOCATE_EMPTY_EXTERNAL_ARRAY) |
| -#undef ALLOCATE_EMPTY_EXTERNAL_ARRAY |
| - |
| #define ALLOCATE_EMPTY_FIXED_TYPED_ARRAY(Type, type, TYPE, ctype, size) \ |
| { \ |
| FixedTypedArrayBase* obj; \ |
| @@ -3690,27 +3674,6 @@ void Heap::AddAllocationSiteToScratchpad(AllocationSite* site, |
| } |
| -Map* Heap::MapForExternalArrayType(ExternalArrayType array_type) { |
| - return Map::cast(roots_[RootIndexForExternalArrayType(array_type)]); |
| -} |
| - |
| - |
| -Heap::RootListIndex Heap::RootIndexForExternalArrayType( |
| - ExternalArrayType array_type) { |
| - switch (array_type) { |
| -#define ARRAY_TYPE_TO_ROOT_INDEX(Type, type, TYPE, ctype, size) \ |
| - case kExternal##Type##Array: \ |
| - return kExternal##Type##ArrayMapRootIndex; |
| - |
| - TYPED_ARRAYS(ARRAY_TYPE_TO_ROOT_INDEX) |
| -#undef ARRAY_TYPE_TO_ROOT_INDEX |
| - |
| - default: |
| - UNREACHABLE(); |
| - return kUndefinedValueRootIndex; |
| - } |
| -} |
| - |
| Map* Heap::MapForFixedTypedArray(ExternalArrayType array_type) { |
| return Map::cast(roots_[RootIndexForFixedTypedArray(array_type)]); |
| @@ -3734,23 +3697,6 @@ Heap::RootListIndex Heap::RootIndexForFixedTypedArray( |
| } |
| -Heap::RootListIndex Heap::RootIndexForEmptyExternalArray( |
| - ElementsKind elementsKind) { |
| - switch (elementsKind) { |
| -#define ELEMENT_KIND_TO_ROOT_INDEX(Type, type, TYPE, ctype, size) \ |
| - case EXTERNAL_##TYPE##_ELEMENTS: \ |
| - return kEmptyExternal##Type##ArrayRootIndex; |
| - |
| - TYPED_ARRAYS(ELEMENT_KIND_TO_ROOT_INDEX) |
| -#undef ELEMENT_KIND_TO_ROOT_INDEX |
| - |
| - default: |
| - UNREACHABLE(); |
| - return kUndefinedValueRootIndex; |
| - } |
| -} |
| - |
| - |
| Heap::RootListIndex Heap::RootIndexForEmptyFixedTypedArray( |
| ElementsKind elementsKind) { |
| switch (elementsKind) { |
| @@ -3767,12 +3713,6 @@ Heap::RootListIndex Heap::RootIndexForEmptyFixedTypedArray( |
| } |
| -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())]); |
| @@ -3973,7 +3913,7 @@ AllocationResult Heap::AllocateExternalArray(int length, |
| ExternalArrayType array_type, |
| void* external_pointer, |
| PretenureFlag pretenure) { |
| - int size = ExternalArray::kSize; |
| + int size = FixedTypedArrayBase::kHeaderSize; |
|
Hannes Payer (out of office)
2015/07/24 13:40:59
Can we have a kSize?
jochen (gone - plz use gerrit)
2015/07/24 16:04:36
that's misleading, because a fixed array can be on
Hannes Payer (out of office)
2015/07/27 08:40:05
Both sides are misleading. I do not have a strong
jochen (gone - plz use gerrit)
2015/07/27 08:46:16
I'll keep kHeaderSize then :)
|
| AllocationSpace space = SelectSpace(size, pretenure); |
| HeapObject* result; |
| { |
| @@ -3981,10 +3921,12 @@ AllocationResult Heap::AllocateExternalArray(int length, |
| if (!allocation.To(&result)) return allocation; |
| } |
| - result->set_map_no_write_barrier(MapForExternalArrayType(array_type)); |
| - ExternalArray::cast(result)->set_length(length); |
| - ExternalArray::cast(result)->set_external_pointer(external_pointer); |
| - return result; |
| + result->set_map(MapForFixedTypedArray(array_type)); |
|
Hannes Payer (out of office)
2015/07/24 13:40:59
Why not set_map_no_write_barrier?
jochen (gone - plz use gerrit)
2015/07/24 16:04:36
copied from AllocateFixedTypedArray below
Hannes Payer (out of office)
2015/07/27 08:40:05
This is part of the roots_ array. No need for a wr
jochen (gone - plz use gerrit)
2015/07/27 08:46:16
fixed both
|
| + FixedTypedArrayBase* elements = FixedTypedArrayBase::cast(result); |
| + elements->set_base_pointer(Smi::FromInt(0), SKIP_WRITE_BARRIER); |
| + elements->set_external_pointer(external_pointer, SKIP_WRITE_BARRIER); |
| + elements->set_length(length); |
| + return elements; |
| } |
| static void ForFixedTypedArray(ExternalArrayType array_type, int* element_size, |
| @@ -4239,8 +4181,7 @@ AllocationResult Heap::AllocateJSObjectFromMap( |
| // Initialize the JSObject. |
| InitializeJSObjectFromMap(js_obj, properties, map); |
| - DCHECK(js_obj->HasFastElements() || js_obj->HasExternalArrayElements() || |
| - js_obj->HasFixedTypedArrayElements()); |
| + DCHECK(js_obj->HasFastElements() || js_obj->HasFixedTypedArrayElements()); |
| return js_obj; |
| } |
| @@ -4532,12 +4473,6 @@ AllocationResult Heap::AllocateEmptyFixedArray() { |
| } |
| -AllocationResult Heap::AllocateEmptyExternalArray( |
| - ExternalArrayType array_type) { |
| - return AllocateExternalArray(0, array_type, NULL, TENURED); |
| -} |
| - |
| - |
| AllocationResult Heap::CopyAndTenureFixedCOWArray(FixedArray* src) { |
| if (!InNewSpace(src)) { |
| return src; |