Commit 51334bb8 authored by Daniel Clifford's avatar Daniel Clifford Committed by Commit Bot

Add JSReceiver method for detecting complex elements

Change-Id: Id34d21437b3881d829526b89058f26741bee7acc
Reviewed-on: https://chromium-review.googlesource.com/695327Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Commit-Queue: Daniel Clifford <danno@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48277}
parent fa3b73ff
......@@ -19062,6 +19062,16 @@ bool JSReceiver::HasProxyInPrototype(Isolate* isolate) {
return false;
}
bool JSReceiver::HasComplexElements() {
if (IsJSProxy()) return true;
JSObject* this_object = JSObject::cast(this);
if (this_object->HasIndexedInterceptor()) {
return true;
}
if (!this_object->HasDictionaryElements()) return false;
return this_object->element_dictionary()->HasComplexElements();
}
MaybeHandle<Name> FunctionTemplateInfo::TryGetCachedPropertyName(
Isolate* isolate, Handle<Object> getter) {
if (getter->IsFunctionTemplateInfo()) {
......
......@@ -2190,6 +2190,8 @@ class JSReceiver: public HeapObject {
bool HasProxyInPrototype(Isolate* isolate);
bool HasComplexElements();
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(JSReceiver);
};
......
......@@ -354,15 +354,12 @@ RUNTIME_FUNCTION(Runtime_GetArrayKeys) {
ALL_PROPERTIES);
for (PrototypeIterator iter(isolate, array, kStartAtReceiver);
!iter.IsAtEnd(); iter.Advance()) {
if (PrototypeIterator::GetCurrent(iter)->IsJSProxy() ||
PrototypeIterator::GetCurrent<JSObject>(iter)
->HasIndexedInterceptor()) {
// Bail out if we find a proxy or interceptor, likely not worth
// collecting keys in that case.
Handle<JSReceiver> current(PrototypeIterator::GetCurrent<JSReceiver>(iter));
if (current->HasComplexElements()) {
return *isolate->factory()->NewNumberFromUint(length);
}
Handle<JSObject> current = PrototypeIterator::GetCurrent<JSObject>(iter);
accumulator.CollectOwnElementIndices(array, current);
accumulator.CollectOwnElementIndices(array,
Handle<JSObject>::cast(current));
}
// Erase any keys >= length.
Handle<FixedArray> keys =
......@@ -517,15 +514,7 @@ RUNTIME_FUNCTION(Runtime_HasComplexElements) {
CONVERT_ARG_HANDLE_CHECKED(JSObject, array, 0);
for (PrototypeIterator iter(isolate, array, kStartAtReceiver);
!iter.IsAtEnd(); iter.Advance()) {
if (PrototypeIterator::GetCurrent(iter)->IsJSProxy()) {
return isolate->heap()->true_value();
}
Handle<JSObject> current = PrototypeIterator::GetCurrent<JSObject>(iter);
if (current->HasIndexedInterceptor()) {
return isolate->heap()->true_value();
}
if (!current->HasDictionaryElements()) continue;
if (current->element_dictionary()->HasComplexElements()) {
if (PrototypeIterator::GetCurrent<JSReceiver>(iter)->HasComplexElements()) {
return isolate->heap()->true_value();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment