Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index a27cc67ce3d6850053cfbb96d00ba3d29ebc33a4..a16ebebd966f8b0a159216b5f8e5cf960f505335 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -8921,78 +8921,6 @@ MaybeObject* JSObject::EnsureCanContainElements(Arguments* args, |
| } |
| -bool JSObject::HasElementPostInterceptor(JSReceiver* receiver, uint32_t index) { |
| - switch (GetElementsKind()) { |
| - case FAST_SMI_ONLY_ELEMENTS: |
| - case FAST_ELEMENTS: { |
| - uint32_t length = IsJSArray() ? |
| - static_cast<uint32_t> |
| - (Smi::cast(JSArray::cast(this)->length())->value()) : |
| - static_cast<uint32_t>(FixedArray::cast(elements())->length()); |
| - if ((index < length) && |
| - !FixedArray::cast(elements())->get(index)->IsTheHole()) { |
| - return true; |
| - } |
| - break; |
| - } |
| - case FAST_DOUBLE_ELEMENTS: { |
| - uint32_t length = IsJSArray() ? |
| - static_cast<uint32_t> |
| - (Smi::cast(JSArray::cast(this)->length())->value()) : |
| - static_cast<uint32_t>(FixedDoubleArray::cast(elements())->length()); |
| - if ((index < length) && |
| - !FixedDoubleArray::cast(elements())->is_the_hole(index)) { |
| - return true; |
| - } |
| - break; |
| - } |
| - case EXTERNAL_PIXEL_ELEMENTS: { |
| - ExternalPixelArray* pixels = ExternalPixelArray::cast(elements()); |
| - if (index < static_cast<uint32_t>(pixels->length())) { |
| - return true; |
| - } |
| - break; |
| - } |
| - case EXTERNAL_BYTE_ELEMENTS: |
| - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| - case EXTERNAL_SHORT_ELEMENTS: |
| - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| - case EXTERNAL_INT_ELEMENTS: |
| - case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| - case EXTERNAL_FLOAT_ELEMENTS: |
| - case EXTERNAL_DOUBLE_ELEMENTS: { |
| - ExternalArray* array = ExternalArray::cast(elements()); |
| - if (index < static_cast<uint32_t>(array->length())) { |
| - return true; |
| - } |
| - break; |
| - } |
| - case DICTIONARY_ELEMENTS: { |
| - if (element_dictionary()->FindEntry(index) |
| - != SeededNumberDictionary::kNotFound) { |
| - return true; |
| - } |
| - break; |
| - } |
| - case NON_STRICT_ARGUMENTS_ELEMENTS: |
| - UNREACHABLE(); |
| - break; |
| - } |
| - |
| - // Handle [] on String objects. |
| - if (this->IsStringObjectWithCharacterAt(index)) return true; |
| - |
| - Object* pt = GetPrototype(); |
| - if (pt->IsNull()) return false; |
| - if (pt->IsJSProxy()) { |
|
Jakob Kummerow
2012/03/05 10:54:11
where did this case go?
danno
2012/03/06 11:02:05
Done.
|
| - // We need to follow the spec and simulate a call to [[GetOwnProperty]]. |
| - return JSProxy::cast(pt)->GetElementAttributeWithHandler( |
| - receiver, index) != ABSENT; |
| - } |
| - return JSObject::cast(pt)->HasElementWithReceiver(receiver, index); |
| -} |
| - |
| - |
| bool JSObject::HasElementWithInterceptor(JSReceiver* receiver, uint32_t index) { |
| Isolate* isolate = GetIsolate(); |
| // Make sure that the top context does not change when doing |
| @@ -9032,7 +8960,16 @@ bool JSObject::HasElementWithInterceptor(JSReceiver* receiver, uint32_t index) { |
| } |
| if (!result.IsEmpty()) return true; |
| } |
| - return holder_handle->HasElementPostInterceptor(*receiver_handle, index); |
| + |
| + if (holder_handle->GetElementsAccessor()->HasElement( |
| + holder_handle->elements(), index, *holder_handle, *receiver_handle)) { |
| + return true; |
| + } |
| + |
| + if (holder_handle->IsStringObjectWithCharacterAt(index)) return true; |
| + Object* pt = holder_handle->GetPrototype(); |
| + if (pt->IsNull()) return false; |
| + return JSObject::cast(pt)->HasElementWithReceiver(*receiver_handle, index); |
| } |
| @@ -9142,28 +9079,6 @@ JSObject::LocalElementType JSObject::HasLocalElement(uint32_t index) { |
| } |
| -bool JSObject::HasElementInElements(FixedArray* elements, |
| - ElementsKind kind, |
| - uint32_t index) { |
| - ASSERT(kind == FAST_ELEMENTS || kind == DICTIONARY_ELEMENTS); |
| - if (kind == FAST_ELEMENTS) { |
| - int length = IsJSArray() |
| - ? Smi::cast(JSArray::cast(this)->length())->value() |
| - : elements->length(); |
| - if (index < static_cast<uint32_t>(length) && |
| - !elements->get(index)->IsTheHole()) { |
| - return true; |
| - } |
| - } else { |
| - if (SeededNumberDictionary::cast(elements)->FindEntry(index) != |
| - SeededNumberDictionary::kNotFound) { |
| - return true; |
| - } |
| - } |
| - return false; |
| -} |
| - |
| - |
| bool JSObject::HasElementWithReceiver(JSReceiver* receiver, uint32_t index) { |
| // Check access rights if needed. |
| if (IsAccessCheckNeeded()) { |
| @@ -9179,68 +9094,9 @@ bool JSObject::HasElementWithReceiver(JSReceiver* receiver, uint32_t index) { |
| return HasElementWithInterceptor(receiver, index); |
| } |
| - ElementsKind kind = GetElementsKind(); |
| - switch (kind) { |
| - case FAST_SMI_ONLY_ELEMENTS: |
| - case FAST_ELEMENTS: { |
| - uint32_t length = IsJSArray() ? |
| - static_cast<uint32_t> |
| - (Smi::cast(JSArray::cast(this)->length())->value()) : |
| - static_cast<uint32_t>(FixedArray::cast(elements())->length()); |
| - if ((index < length) && |
| - !FixedArray::cast(elements())->get(index)->IsTheHole()) return true; |
| - break; |
| - } |
| - case FAST_DOUBLE_ELEMENTS: { |
| - uint32_t length = IsJSArray() ? |
| - static_cast<uint32_t> |
| - (Smi::cast(JSArray::cast(this)->length())->value()) : |
| - static_cast<uint32_t>(FixedDoubleArray::cast(elements())->length()); |
| - if ((index < length) && |
| - !FixedDoubleArray::cast(elements())->is_the_hole(index)) return true; |
| - break; |
| - } |
| - case EXTERNAL_PIXEL_ELEMENTS: { |
| - ExternalPixelArray* pixels = ExternalPixelArray::cast(elements()); |
| - if (index < static_cast<uint32_t>(pixels->length())) { |
| - return true; |
| - } |
| - break; |
| - } |
| - case EXTERNAL_BYTE_ELEMENTS: |
| - case EXTERNAL_UNSIGNED_BYTE_ELEMENTS: |
| - case EXTERNAL_SHORT_ELEMENTS: |
| - case EXTERNAL_UNSIGNED_SHORT_ELEMENTS: |
| - case EXTERNAL_INT_ELEMENTS: |
| - case EXTERNAL_UNSIGNED_INT_ELEMENTS: |
| - case EXTERNAL_FLOAT_ELEMENTS: |
| - case EXTERNAL_DOUBLE_ELEMENTS: { |
| - ExternalArray* array = ExternalArray::cast(elements()); |
| - if (index < static_cast<uint32_t>(array->length())) { |
| - return true; |
| - } |
| - break; |
| - } |
| - case DICTIONARY_ELEMENTS: { |
| - if (element_dictionary()->FindEntry(index) |
| - != SeededNumberDictionary::kNotFound) { |
| - return true; |
| - } |
| - break; |
| - } |
| - case NON_STRICT_ARGUMENTS_ELEMENTS: { |
| - FixedArray* parameter_map = FixedArray::cast(elements()); |
| - uint32_t length = parameter_map->length(); |
| - Object* probe = |
| - (index < length - 2) ? parameter_map->get(index + 2) : NULL; |
| - if (probe != NULL && !probe->IsTheHole()) return true; |
| - |
| - // Not a mapped parameter, check the arguments. |
| - FixedArray* arguments = FixedArray::cast(parameter_map->get(1)); |
| - kind = arguments->IsDictionary() ? DICTIONARY_ELEMENTS : FAST_ELEMENTS; |
| - if (HasElementInElements(arguments, kind, index)) return true; |
| - break; |
| - } |
| + ElementsAccessor* accessor = GetElementsAccessor(); |
| + if (accessor->HasElement(elements(), index, this, receiver)) { |
| + return true; |
| } |
| // Handle [] on String objects. |