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

Unified Diff: src/builtins.cc

Issue 1675663002: Revert of [es7] refactor and fix Object.values() / Object.entries() (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 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 | « no previous file | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/builtins.cc
diff --git a/src/builtins.cc b/src/builtins.cc
index 6f1fc0732b566b556082c13f3dc63a97751780a8..9cc26db23b622e67c63ea7f144ea109f93a495de 100644
--- a/src/builtins.cc
+++ b/src/builtins.cc
@@ -1753,10 +1753,22 @@
Handle<JSReceiver> receiver;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver,
Object::ToObject(isolate, object));
- Handle<FixedArray> values;
+ Handle<FixedArray> keys;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, values, JSReceiver::GetOwnValues(receiver, ENUMERABLE_STRINGS));
- return *isolate->factory()->NewJSArrayWithElements(values);
+ isolate, keys, JSReceiver::GetKeys(receiver, OWN_ONLY, ENUMERABLE_STRINGS,
+ CONVERT_TO_STRING));
+
+ for (int i = 0; i < keys->length(); ++i) {
+ auto key = Handle<Name>::cast(FixedArray::get(*keys, i, isolate));
+ Handle<Object> value;
+
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, value, Object::GetPropertyOrElement(receiver, key, STRICT));
+
+ keys->set(i, *value);
+ }
+
+ return *isolate->factory()->NewJSArrayWithElements(keys);
}
@@ -1766,11 +1778,26 @@
Handle<JSReceiver> receiver;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver,
Object::ToObject(isolate, object));
- Handle<FixedArray> entries;
+ Handle<FixedArray> keys;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
- isolate, entries,
- JSReceiver::GetOwnEntries(receiver, ENUMERABLE_STRINGS));
- return *isolate->factory()->NewJSArrayWithElements(entries);
+ isolate, keys, JSReceiver::GetKeys(receiver, OWN_ONLY, ENUMERABLE_STRINGS,
+ CONVERT_TO_STRING));
+
+ for (int i = 0; i < keys->length(); ++i) {
+ auto key = Handle<Name>::cast(FixedArray::get(*keys, i, isolate));
+ Handle<Object> value;
+
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
+ isolate, value, Object::GetPropertyOrElement(receiver, key, STRICT));
+
+ auto entry_storage = isolate->factory()->NewUninitializedFixedArray(2);
+ entry_storage->set(0, *key);
+ entry_storage->set(1, *value);
+ auto entry = isolate->factory()->NewJSArrayWithElements(entry_storage);
+ keys->set(i, *entry);
+ }
+
+ return *isolate->factory()->NewJSArrayWithElements(keys);
}
« no previous file with comments | « no previous file | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698