Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1404)

Unified Diff: src/elements.cc

Issue 1804963002: [builtins] Fix Array.prototype.concat bug (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: polishing corner cases and making tests work Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/elements.h ('k') | test/mjsunit/array-concat.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « src/elements.h ('k') | test/mjsunit/array-concat.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698