Index: src/objects.cc |
diff --git a/src/objects.cc b/src/objects.cc |
index 9e93b28127b69ba1520362623e8fa8ec394c57ac..721681bc4821314885e6e501cc2192f91bd733fc 100644 |
--- a/src/objects.cc |
+++ b/src/objects.cc |
@@ -8917,78 +8917,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()) { |
- // 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 |
@@ -9028,7 +8956,21 @@ 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->IsJSProxy()) { |
+ // We need to follow the spec and simulate a call to [[GetOwnProperty]]. |
+ return JSProxy::cast(pt)->GetElementAttributeWithHandler( |
+ receiver, index) != ABSENT; |
+ } |
+ if (pt->IsNull()) return false; |
+ return JSObject::cast(pt)->HasElementWithReceiver(*receiver_handle, index); |
} |
@@ -9138,28 +9080,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()) { |
@@ -9175,68 +9095,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. |