Index: src/builtins.cc |
diff --git a/src/builtins.cc b/src/builtins.cc |
index 35671d2c4c813c5adccd36ca989e9f101e6cb092..b7f30433d5f35a33128b1494639b82679c1174b9 100644 |
--- a/src/builtins.cc |
+++ b/src/builtins.cc |
@@ -1653,6 +1653,62 @@ BUILTIN(ObjectKeys) { |
} |
+BUILTIN(ObjectValues) { |
+ HandleScope scope(isolate); |
+ Handle<Object> object = args.atOrUndefined(isolate, 1); |
+ Handle<JSReceiver> receiver; |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, |
+ Object::ToObject(isolate, object)); |
+ Handle<FixedArray> keys; |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
+ isolate, keys, |
+ JSReceiver::GetKeys(receiver, JSReceiver::OWN_ONLY, ENUMERABLE_STRINGS, |
+ CONVERT_TO_STRING)); |
+ |
+ for (int i = 0; i < keys->length(); ++i) { |
+ auto key = Handle<Name>::cast(FixedArray::get(keys, i)); |
+ Handle<Object> value; |
+ |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
+ isolate, value, Object::GetPropertyOrElement(receiver, key, STRICT)); |
+ |
+ keys->set(i, *value); |
+ } |
+ |
+ return *isolate->factory()->NewJSArrayWithElements(keys); |
+} |
+ |
+ |
+BUILTIN(ObjectEntries) { |
+ HandleScope scope(isolate); |
+ Handle<Object> object = args.atOrUndefined(isolate, 1); |
+ Handle<JSReceiver> receiver; |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, receiver, |
+ Object::ToObject(isolate, object)); |
+ Handle<FixedArray> keys; |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
+ isolate, keys, |
+ JSReceiver::GetKeys(receiver, JSReceiver::OWN_ONLY, ENUMERABLE_STRINGS, |
+ CONVERT_TO_STRING)); |
+ |
+ for (int i = 0; i < keys->length(); ++i) { |
+ auto key = Handle<Name>::cast(FixedArray::get(keys, i)); |
+ 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); |
+} |
+ |
+ |
// ES6 section 19.1.2.15 Object.preventExtensions ( O ) |
BUILTIN(ObjectPreventExtensions) { |
HandleScope scope(isolate); |