Index: src/runtime/runtime-object.cc |
diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc |
index 707b05e57b756ccffc0b9ba422b0f2c0b1fde14a..e0eb1061ad5875cd370cf8cc0cc875e9049bcd4f 100644 |
--- a/src/runtime/runtime-object.cc |
+++ b/src/runtime/runtime-object.cc |
@@ -9,6 +9,7 @@ |
#include "src/debug/debug.h" |
#include "src/isolate-inl.h" |
#include "src/messages.h" |
+#include "src/property-descriptor.h" |
#include "src/runtime/runtime.h" |
namespace v8 { |
@@ -253,10 +254,8 @@ MUST_USE_RESULT static MaybeHandle<Object> GetOwnProperty(Isolate* isolate, |
// [false, value, Writeable, Enumerable, Configurable] |
// if args[1] is an accessor on args[0] |
// [true, GetFunction, SetFunction, Enumerable, Configurable] |
-RUNTIME_FUNCTION(Runtime_GetOwnProperty) { |
- // TODO(jkummerow): Support Proxies. |
- // TODO(jkummerow): Use JSReceiver::GetOwnPropertyDescriptor() and |
- // PropertyDescriptor::ToObject(). |
+// TODO(jkummerow): Deprecated. Remove all callers and delete. |
+RUNTIME_FUNCTION(Runtime_GetOwnProperty_Legacy) { |
HandleScope scope(isolate); |
DCHECK(args.length() == 2); |
CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); |
@@ -268,6 +267,31 @@ RUNTIME_FUNCTION(Runtime_GetOwnProperty) { |
} |
+// ES6 19.1.2.6 |
+RUNTIME_FUNCTION(Runtime_GetOwnProperty) { |
+ HandleScope scope(isolate); |
+ DCHECK(args.length() == 2); |
+ CONVERT_ARG_HANDLE_CHECKED(Object, object, 0); |
+ CONVERT_ARG_HANDLE_CHECKED(Object, raw_name, 1); |
+ // 1. Let obj be ? ToObject(O). |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, object, |
+ Execution::ToObject(isolate, object)); |
+ // 2. Let key be ? ToPropertyKey(P). |
+ Handle<Name> key; |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, key, |
+ Object::ToName(isolate, raw_name)); |
+ |
+ // 3. Let desc be ? obj.[[GetOwnProperty]](key). |
+ PropertyDescriptor desc; |
+ bool found = JSReceiver::GetOwnPropertyDescriptor( |
+ isolate, Handle<JSReceiver>::cast(object), key, &desc); |
+ if (isolate->has_pending_exception()) return isolate->heap()->exception(); |
+ // 4. Return FromPropertyDescriptor(desc). |
+ if (!found) return isolate->heap()->undefined_value(); |
+ return *desc.ToObject(isolate); |
+} |
+ |
+ |
RUNTIME_FUNCTION(Runtime_PreventExtensions) { |
HandleScope scope(isolate); |
DCHECK(args.length() == 1); |