Chromium Code Reviews| Index: src/builtins.cc |
| diff --git a/src/builtins.cc b/src/builtins.cc |
| index e98fb47a74c4224a54cab9018997f58b74de43da..a40c1213e18e439344d226f2083e0856a72296cb 100644 |
| --- a/src/builtins.cc |
| +++ b/src/builtins.cc |
| @@ -1070,14 +1070,16 @@ void CollectElementIndices(Handle<JSObject> object, uint32_t range, |
| Handle<SeededNumberDictionary> dict( |
| SeededNumberDictionary::cast(object->elements())); |
| uint32_t capacity = dict->Capacity(); |
| + Handle<Object> undefined = isolate->factory()->undefined_value(); |
|
Yang
2016/04/01 13:29:52
Can we disallow allocation here and just use raw v
|
| + Handle<Object> the_hole = isolate->factory()->the_hole_value(); |
| FOR_WITH_HANDLE_SCOPE(isolate, uint32_t, j = 0, j, j < capacity, j++, { |
| - Handle<Object> k(dict->KeyAt(j), isolate); |
| - if (dict->IsKey(*k)) { |
| - DCHECK(k->IsNumber()); |
| - uint32_t index = static_cast<uint32_t>(k->Number()); |
| - if (index < range) { |
| - indices->Add(index); |
| - } |
| + Object* k = dict->KeyAt(j); |
| + if (k == *undefined) continue; |
| + if (k == *the_hole) continue; |
| + DCHECK(k->IsNumber()); |
| + uint32_t index = static_cast<uint32_t>(k->Number()); |
| + if (index < range) { |
| + indices->Add(index); |
| } |
| }); |
| break; |
| @@ -1410,6 +1412,7 @@ Object* Slow_ArrayConcat(Arguments* args, Handle<Object> species, |
| double_storage->set(j, obj->Number()); |
| j++; |
| } else { |
| + DisallowHeapAllocation no_gc; |
| JSArray* array = JSArray::cast(*obj); |
| uint32_t length = static_cast<uint32_t>(array->length()->Number()); |
| switch (array->GetElementsKind()) { |
| @@ -1437,10 +1440,11 @@ Object* Slow_ArrayConcat(Arguments* args, Handle<Object> species, |
| } |
| case FAST_HOLEY_SMI_ELEMENTS: |
| case FAST_SMI_ELEMENTS: { |
| + Object* the_hole = isolate->heap()->the_hole_value(); |
| FixedArray* elements(FixedArray::cast(array->elements())); |
| for (uint32_t i = 0; i < length; i++) { |
| Object* element = elements->get(i); |
| - if (element->IsTheHole()) { |
| + if (element == the_hole) { |
| failure = true; |
| break; |
| } |
| @@ -1530,11 +1534,10 @@ MaybeHandle<JSArray> Fast_ArrayConcat(Isolate* isolate, Arguments* args) { |
| for (int i = 0; i < n_arguments; i++) { |
| Object* arg = (*args)[i]; |
| if (!arg->IsJSArray()) return MaybeHandle<JSArray>(); |
| - if (!HasOnlySimpleReceiverElements(isolate, JSObject::cast(arg))) { |
| + if (!JSObject::cast(arg)->HasFastElements()) { |
| return MaybeHandle<JSArray>(); |
| } |
| - // TODO(cbruni): support fast concatenation of DICTIONARY_ELEMENTS. |
| - if (!JSObject::cast(arg)->HasFastElements()) { |
| + if (!HasOnlySimpleReceiverElements(isolate, JSObject::cast(arg))) { |
| return MaybeHandle<JSArray>(); |
| } |
| Handle<JSArray> array(JSArray::cast(arg), isolate); |