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

Unified Diff: src/objects.cc

Issue 1767113004: [esnext] handle elements in FastObjectValuesOrEntries() (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Make ElementsAccessor::GetCapacity() public, and use it 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.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index f41407f2864f4ef28206870ffc99c36ae86b827b..53720f6ed6567feb1423998d557f09387a0460b2 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -8710,17 +8710,23 @@ MUST_USE_RESULT Maybe<bool> FastGetOwnValuesOrEntries(
if (!map->OnlyHasSimpleProperties()) return Just(false);
Handle<JSObject> object(JSObject::cast(*receiver));
- if (object->elements() != isolate->heap()->empty_fixed_array()) {
- return Just(false);
- }
Handle<DescriptorArray> descriptors(map->instance_descriptors(), isolate);
int number_of_own_descriptors = map->NumberOfOwnDescriptors();
- Handle<FixedArray> values_or_entries =
- isolate->factory()->NewFixedArray(number_of_own_descriptors);
+ int number_of_own_elements =
+ object->GetElementsAccessor()->GetCapacity(*object, object->elements());
+ Handle<FixedArray> values_or_entries = isolate->factory()->NewFixedArray(
+ number_of_own_descriptors + number_of_own_elements);
int count = 0;
- bool stable = true;
+ if (object->elements() != isolate->heap()->empty_fixed_array()) {
+ MAYBE_RETURN(object->GetElementsAccessor()->CollectValuesOrEntries(
+ isolate, object, values_or_entries, get_entries, &count,
+ ENUMERABLE_STRINGS),
+ Nothing<bool>());
+ }
+
+ bool stable = object->map() == *map;
for (int index = 0; index < number_of_own_descriptors; index++) {
Handle<Name> next_key(descriptors->GetKey(index), isolate);
@@ -8759,12 +8765,7 @@ MUST_USE_RESULT Maybe<bool> FastGetOwnValuesOrEntries(
}
if (get_entries) {
- Handle<FixedArray> entry_storage =
- isolate->factory()->NewUninitializedFixedArray(2);
- entry_storage->set(0, *next_key);
- entry_storage->set(1, *prop_value);
- prop_value = isolate->factory()->NewJSArrayWithElements(entry_storage,
- FAST_ELEMENTS, 2);
+ prop_value = MakeEntryPair(isolate, next_key, prop_value);
}
values_or_entries->set(count, *prop_value);
« no previous file with comments | « src/elements.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698