Index: src/elements.cc |
diff --git a/src/elements.cc b/src/elements.cc |
index 2ec224c23efd64dc20742affd427db546a8e3092..5e79c86e134b8cf8ecc419ee7e210e052b311d6e 100644 |
--- a/src/elements.cc |
+++ b/src/elements.cc |
@@ -547,6 +547,16 @@ class ElementsAccessorBase : public ElementsAccessor { |
*holder, *backing_store, index, filter) != kMaxUInt32; |
} |
+ bool HasAccessors(JSObject* holder) final { |
+ return ElementsAccessorSubclass::HasAccessorsImpl(holder, |
+ holder->elements()); |
+ } |
+ |
+ static bool HasAccessorsImpl(JSObject* holder, |
+ FixedArrayBase* backing_store) { |
+ return false; |
+ } |
+ |
Handle<Object> Get(Handle<JSObject> holder, uint32_t entry) final { |
return ElementsAccessorSubclass::GetImpl(holder, entry); |
} |
@@ -1094,6 +1104,21 @@ class DictionaryElementsAccessor |
obj->set_elements(*new_elements); |
} |
+ static bool HasAccessorsImpl(JSObject* holder, |
+ FixedArrayBase* backing_store) { |
+ SeededNumberDictionary* dict = SeededNumberDictionary::cast(backing_store); |
+ if (!dict->requires_slow_elements()) return false; |
+ int capacity = dict->Capacity(); |
+ for (int i = 0; i < capacity; i++) { |
+ Object* key = dict->KeyAt(i); |
+ if (!dict->IsKey(key)) continue; |
+ DCHECK(!dict->IsDeleted(i)); |
+ PropertyDetails details = dict->DetailsAt(i); |
+ if (details.type() == ACCESSOR_CONSTANT) return true; |
+ } |
+ return false; |
+ } |
+ |
static Object* GetRaw(FixedArrayBase* store, uint32_t entry) { |
SeededNumberDictionary* backing_store = SeededNumberDictionary::cast(store); |
return backing_store->ValueAt(entry); |
@@ -1999,6 +2024,11 @@ class TypedElementsAccessor |
return index < AccessorClass::GetCapacityImpl(*holder, *backing_store); |
} |
+ static bool HasAccessorsImpl(JSObject* holder, |
+ FixedArrayBase* backing_store) { |
+ return false; |
+ } |
+ |
static void SetLengthImpl(Isolate* isolate, Handle<JSArray> array, |
uint32_t length, |
Handle<FixedArrayBase> backing_store) { |
@@ -2169,6 +2199,13 @@ class SloppyArgumentsElementsAccessor |
return ArgumentsAccessor::HasEntryImpl(arguments, entry - length); |
} |
+ static bool HasAccessorsImpl(JSObject* holder, |
+ FixedArrayBase* backing_store) { |
+ FixedArray* parameter_map = FixedArray::cast(backing_store); |
+ FixedArrayBase* arguments = FixedArrayBase::cast(parameter_map->get(1)); |
+ return ArgumentsAccessor::HasAccessorsImpl(holder, arguments); |
+ } |
+ |
static uint32_t GetIndexForEntryImpl(FixedArrayBase* parameters, |
uint32_t entry) { |
FixedArray* parameter_map = FixedArray::cast(parameters); |
@@ -2608,6 +2645,11 @@ class SlowStringWrapperElementsAccessor |
: StringWrapperElementsAccessor< |
SlowStringWrapperElementsAccessor, DictionaryElementsAccessor, |
ElementsKindTraits<SLOW_STRING_WRAPPER_ELEMENTS>>(name) {} |
+ |
+ static bool HasAccessorsImpl(JSObject* holder, |
+ FixedArrayBase* backing_store) { |
+ return DictionaryElementsAccessor::HasAccessorsImpl(holder, backing_store); |
+ } |
}; |
} // namespace |