| OLD | NEW |
| 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/v8.h" | 5 #include "src/v8.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/messages.h" | 10 #include "src/messages.h" |
| (...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); | 787 CONVERT_ARG_HANDLE_CHECKED(Name, key, 1); |
| 788 | 788 |
| 789 Maybe<PropertyAttributes> maybe = | 789 Maybe<PropertyAttributes> maybe = |
| 790 JSReceiver::GetOwnPropertyAttributes(object, key); | 790 JSReceiver::GetOwnPropertyAttributes(object, key); |
| 791 if (!maybe.IsJust()) return isolate->heap()->exception(); | 791 if (!maybe.IsJust()) return isolate->heap()->exception(); |
| 792 if (maybe.FromJust() == ABSENT) maybe = Just(DONT_ENUM); | 792 if (maybe.FromJust() == ABSENT) maybe = Just(DONT_ENUM); |
| 793 return isolate->heap()->ToBoolean((maybe.FromJust() & DONT_ENUM) == 0); | 793 return isolate->heap()->ToBoolean((maybe.FromJust() & DONT_ENUM) == 0); |
| 794 } | 794 } |
| 795 | 795 |
| 796 | 796 |
| 797 RUNTIME_FUNCTION(Runtime_GetPropertyNames) { | 797 // Returns either a FixedArray or, if the given object has an enum cache that |
| 798 HandleScope scope(isolate); | 798 // contains all enumerable properties of the object and its prototypes have |
| 799 DCHECK(args.length() == 1); | 799 // none, the map of the object. This is used to speed up the check for |
| 800 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, object, 0); | 800 // deletions during a for-in. |
| 801 Handle<JSArray> result; | |
| 802 | |
| 803 isolate->counters()->for_in()->Increment(); | |
| 804 Handle<FixedArray> elements; | |
| 805 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | |
| 806 isolate, elements, | |
| 807 JSReceiver::GetKeys(object, JSReceiver::INCLUDE_PROTOS)); | |
| 808 return *isolate->factory()->NewJSArrayWithElements(elements); | |
| 809 } | |
| 810 | |
| 811 | |
| 812 // Returns either a FixedArray as Runtime_GetPropertyNames, | |
| 813 // or, if the given object has an enum cache that contains | |
| 814 // all enumerable properties of the object and its prototypes | |
| 815 // have none, the map of the object. This is used to speed up | |
| 816 // the check for deletions during a for-in. | |
| 817 RUNTIME_FUNCTION(Runtime_GetPropertyNamesFast) { | 801 RUNTIME_FUNCTION(Runtime_GetPropertyNamesFast) { |
| 818 SealHandleScope shs(isolate); | 802 SealHandleScope shs(isolate); |
| 819 DCHECK(args.length() == 1); | 803 DCHECK(args.length() == 1); |
| 820 | 804 |
| 821 CONVERT_ARG_CHECKED(JSReceiver, raw_object, 0); | 805 CONVERT_ARG_CHECKED(JSReceiver, raw_object, 0); |
| 822 | 806 |
| 823 if (raw_object->IsSimpleEnum()) return raw_object->map(); | 807 if (raw_object->IsSimpleEnum()) return raw_object->map(); |
| 824 | 808 |
| 825 HandleScope scope(isolate); | 809 HandleScope scope(isolate); |
| 826 Handle<JSReceiver> object(raw_object); | 810 Handle<JSReceiver> object(raw_object); |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1461 Handle<JSReceiver> receiver; | 1445 Handle<JSReceiver> receiver; |
| 1462 if (JSReceiver::ToObject(isolate, object).ToHandle(&receiver)) { | 1446 if (JSReceiver::ToObject(isolate, object).ToHandle(&receiver)) { |
| 1463 return *receiver; | 1447 return *receiver; |
| 1464 } | 1448 } |
| 1465 THROW_NEW_ERROR_RETURN_FAILURE( | 1449 THROW_NEW_ERROR_RETURN_FAILURE( |
| 1466 isolate, NewTypeError(MessageTemplate::kUndefinedOrNullToObject)); | 1450 isolate, NewTypeError(MessageTemplate::kUndefinedOrNullToObject)); |
| 1467 } | 1451 } |
| 1468 | 1452 |
| 1469 } // namespace internal | 1453 } // namespace internal |
| 1470 } // namespace v8 | 1454 } // namespace v8 |
| OLD | NEW |