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

Unified Diff: src/runtime/runtime-object.cc

Issue 1451703003: [proxies] Wire up Object.getOwnPropertyDescriptor (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: moved test file Created 5 years, 1 month 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/runtime/runtime.h ('k') | test/mjsunit/harmony/proxies-get-own-property-descriptor.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « src/runtime/runtime.h ('k') | test/mjsunit/harmony/proxies-get-own-property-descriptor.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698