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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/runtime/runtime-utils.h" 5 #include "src/runtime/runtime-utils.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/bootstrapper.h" 8 #include "src/bootstrapper.h"
9 #include "src/debug/debug.h" 9 #include "src/debug/debug.h"
10 #include "src/isolate-inl.h" 10 #include "src/isolate-inl.h"
11 #include "src/messages.h" 11 #include "src/messages.h"
12 #include "src/property-descriptor.h"
12 #include "src/runtime/runtime.h" 13 #include "src/runtime/runtime.h"
13 14
14 namespace v8 { 15 namespace v8 {
15 namespace internal { 16 namespace internal {
16 17
17 18
18 MaybeHandle<Object> Runtime::GetObjectProperty(Isolate* isolate, 19 MaybeHandle<Object> Runtime::GetObjectProperty(Isolate* isolate,
19 Handle<Object> object, 20 Handle<Object> object,
20 Handle<Object> key, 21 Handle<Object> key,
21 LanguageMode language_mode) { 22 LanguageMode language_mode) {
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 } 247 }
247 248
248 249
249 // Returns an array with the property description: 250 // Returns an array with the property description:
250 // if args[1] is not a property on args[0] 251 // if args[1] is not a property on args[0]
251 // returns undefined 252 // returns undefined
252 // if args[1] is a data property on args[0] 253 // if args[1] is a data property on args[0]
253 // [false, value, Writeable, Enumerable, Configurable] 254 // [false, value, Writeable, Enumerable, Configurable]
254 // if args[1] is an accessor on args[0] 255 // if args[1] is an accessor on args[0]
255 // [true, GetFunction, SetFunction, Enumerable, Configurable] 256 // [true, GetFunction, SetFunction, Enumerable, Configurable]
256 RUNTIME_FUNCTION(Runtime_GetOwnProperty) { 257 // TODO(jkummerow): Deprecated. Remove all callers and delete.
257 // TODO(jkummerow): Support Proxies. 258 RUNTIME_FUNCTION(Runtime_GetOwnProperty_Legacy) {
258 // TODO(jkummerow): Use JSReceiver::GetOwnPropertyDescriptor() and
259 // PropertyDescriptor::ToObject().
260 HandleScope scope(isolate); 259 HandleScope scope(isolate);
261 DCHECK(args.length() == 2); 260 DCHECK(args.length() == 2);
262 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); 261 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
263 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); 262 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
264 Handle<Object> result; 263 Handle<Object> result;
265 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, 264 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
266 GetOwnProperty(isolate, obj, name)); 265 GetOwnProperty(isolate, obj, name));
267 return *result; 266 return *result;
268 } 267 }
269 268
270 269
270 // ES6 19.1.2.6
271 RUNTIME_FUNCTION(Runtime_GetOwnProperty) {
272 HandleScope scope(isolate);
273 DCHECK(args.length() == 2);
274 CONVERT_ARG_HANDLE_CHECKED(Object, object, 0);
275 CONVERT_ARG_HANDLE_CHECKED(Object, raw_name, 1);
276 // 1. Let obj be ? ToObject(O).
277 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, object,
278 Execution::ToObject(isolate, object));
279 // 2. Let key be ? ToPropertyKey(P).
280 Handle<Name> key;
281 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, key,
282 Object::ToName(isolate, raw_name));
283
284 // 3. Let desc be ? obj.[[GetOwnProperty]](key).
285 PropertyDescriptor desc;
286 bool found = JSReceiver::GetOwnPropertyDescriptor(
287 isolate, Handle<JSReceiver>::cast(object), key, &desc);
288 if (isolate->has_pending_exception()) return isolate->heap()->exception();
289 // 4. Return FromPropertyDescriptor(desc).
290 if (!found) return isolate->heap()->undefined_value();
291 return *desc.ToObject(isolate);
292 }
293
294
271 RUNTIME_FUNCTION(Runtime_PreventExtensions) { 295 RUNTIME_FUNCTION(Runtime_PreventExtensions) {
272 HandleScope scope(isolate); 296 HandleScope scope(isolate);
273 DCHECK(args.length() == 1); 297 DCHECK(args.length() == 1);
274 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0); 298 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, obj, 0);
275 if (JSReceiver::PreventExtensions(obj, Object::THROW_ON_ERROR).IsNothing()) 299 if (JSReceiver::PreventExtensions(obj, Object::THROW_ON_ERROR).IsNothing())
276 return isolate->heap()->exception(); 300 return isolate->heap()->exception();
277 return *obj; 301 return *obj;
278 } 302 }
279 303
280 304
(...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 1592
1569 RUNTIME_FUNCTION(Runtime_ObjectDefineProperties) { 1593 RUNTIME_FUNCTION(Runtime_ObjectDefineProperties) {
1570 HandleScope scope(isolate); 1594 HandleScope scope(isolate);
1571 DCHECK(args.length() == 2); 1595 DCHECK(args.length() == 2);
1572 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); 1596 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0);
1573 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); 1597 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1);
1574 return JSReceiver::DefineProperties(isolate, o, properties); 1598 return JSReceiver::DefineProperties(isolate, o, properties);
1575 } 1599 }
1576 } // namespace internal 1600 } // namespace internal
1577 } // namespace v8 1601 } // namespace v8
OLDNEW
« 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