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

Side by Side Diff: src/runtime/runtime-object.cc

Issue 1438233002: [proxies] Teach ToPropertyDescriptor to deal with Proxies (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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
« src/property-descriptor.cc ('K') | « src/property-descriptor.cc ('k') | no next file » | 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"
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 244
245 245
246 // Returns an array with the property description: 246 // Returns an array with the property description:
247 // if args[1] is not a property on args[0] 247 // if args[1] is not a property on args[0]
248 // returns undefined 248 // returns undefined
249 // if args[1] is a data property on args[0] 249 // if args[1] is a data property on args[0]
250 // [false, value, Writeable, Enumerable, Configurable] 250 // [false, value, Writeable, Enumerable, Configurable]
251 // if args[1] is an accessor on args[0] 251 // if args[1] is an accessor on args[0]
252 // [true, GetFunction, SetFunction, Enumerable, Configurable] 252 // [true, GetFunction, SetFunction, Enumerable, Configurable]
253 RUNTIME_FUNCTION(Runtime_GetOwnProperty) { 253 RUNTIME_FUNCTION(Runtime_GetOwnProperty) {
254 // TODO(jkummerow): Support Proxies.
255 // TODO(jkummerow): Use JSReceiver::GetOwnPropertyDescriptor() and
256 // PropertyDescriptor::ToObject().
254 HandleScope scope(isolate); 257 HandleScope scope(isolate);
255 DCHECK(args.length() == 2); 258 DCHECK(args.length() == 2);
256 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0); 259 CONVERT_ARG_HANDLE_CHECKED(JSObject, obj, 0);
257 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1); 260 CONVERT_ARG_HANDLE_CHECKED(Name, name, 1);
258 Handle<Object> result; 261 Handle<Object> result;
259 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, 262 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result,
260 GetOwnProperty(isolate, obj, name)); 263 GetOwnProperty(isolate, obj, name));
261 return *result; 264 return *result;
262 } 265 }
263 266
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 652
650 uint32_t index; 653 uint32_t index;
651 const bool key_is_array_index = key->AsArrayIndex(&index); 654 const bool key_is_array_index = key->AsArrayIndex(&index);
652 655
653 // Only JS objects can have properties. 656 // Only JS objects can have properties.
654 if (object->IsJSObject()) { 657 if (object->IsJSObject()) {
655 Handle<JSObject> js_obj = Handle<JSObject>::cast(object); 658 Handle<JSObject> js_obj = Handle<JSObject>::cast(object);
656 // Fast case: either the key is a real named property or it is not 659 // Fast case: either the key is a real named property or it is not
657 // an array index and there are no interceptors or hidden 660 // an array index and there are no interceptors or hidden
658 // prototypes. 661 // prototypes.
662 // TODO(jkummerow): Make JSReceiver::HasOwnProperty fast enough to
663 // handle all cases directly (without this custom fast path).
659 Maybe<bool> maybe = Nothing<bool>(); 664 Maybe<bool> maybe = Nothing<bool>();
660 if (key_is_array_index) { 665 if (key_is_array_index) {
661 maybe = JSObject::HasOwnElement(js_obj, index); 666 maybe = JSObject::HasOwnElement(js_obj, index);
662 } else { 667 } else {
663 maybe = JSObject::HasRealNamedProperty(js_obj, key); 668 maybe = JSObject::HasRealNamedProperty(js_obj, key);
664 } 669 }
665 if (!maybe.IsJust()) return isolate->heap()->exception(); 670 if (!maybe.IsJust()) return isolate->heap()->exception();
666 DCHECK(!isolate->has_pending_exception()); 671 DCHECK(!isolate->has_pending_exception());
667 if (maybe.FromJust()) { 672 if (maybe.FromJust()) {
668 return isolate->heap()->true_value(); 673 return isolate->heap()->true_value();
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
750 // Test again, since cache may have been built by preceding call. 755 // Test again, since cache may have been built by preceding call.
751 if (object->IsSimpleEnum()) return object->map(); 756 if (object->IsSimpleEnum()) return object->map();
752 757
753 return *content; 758 return *content;
754 } 759 }
755 760
756 761
757 // Return the names of the own named properties. 762 // Return the names of the own named properties.
758 // args[0]: object 763 // args[0]: object
759 // args[1]: PropertyAttributes as int 764 // args[1]: PropertyAttributes as int
765 // TODO(cbruni/jkummerow): Use JSReceiver::GetKeys() internally, merge with
766 // Runtime_GetOwnElementNames.
760 RUNTIME_FUNCTION(Runtime_GetOwnPropertyNames) { 767 RUNTIME_FUNCTION(Runtime_GetOwnPropertyNames) {
761 HandleScope scope(isolate); 768 HandleScope scope(isolate);
762 DCHECK(args.length() == 2); 769 DCHECK(args.length() == 2);
763 if (!args[0]->IsJSObject()) { 770 if (!args[0]->IsJSObject()) {
764 return isolate->heap()->undefined_value(); 771 return isolate->heap()->undefined_value();
765 } 772 }
766 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0); 773 CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 0);
767 CONVERT_SMI_ARG_CHECKED(filter_value, 1); 774 CONVERT_SMI_ARG_CHECKED(filter_value, 1);
768 PropertyAttributes filter = static_cast<PropertyAttributes>(filter_value); 775 PropertyAttributes filter = static_cast<PropertyAttributes>(filter_value);
769 776
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after
1558 1565
1559 RUNTIME_FUNCTION(Runtime_ObjectDefineProperties) { 1566 RUNTIME_FUNCTION(Runtime_ObjectDefineProperties) {
1560 HandleScope scope(isolate); 1567 HandleScope scope(isolate);
1561 DCHECK(args.length() == 2); 1568 DCHECK(args.length() == 2);
1562 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0); 1569 CONVERT_ARG_HANDLE_CHECKED(Object, o, 0);
1563 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1); 1570 CONVERT_ARG_HANDLE_CHECKED(Object, properties, 1);
1564 return JSReceiver::DefineProperties(isolate, o, properties); 1571 return JSReceiver::DefineProperties(isolate, o, properties);
1565 } 1572 }
1566 } // namespace internal 1573 } // namespace internal
1567 } // namespace v8 1574 } // namespace v8
OLDNEW
« src/property-descriptor.cc ('K') | « src/property-descriptor.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698