OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 1812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1823 | 1823 |
1824 MUST_USE_RESULT static Object* DefineProperty(Isolate* isolate, | 1824 MUST_USE_RESULT static Object* DefineProperty(Isolate* isolate, |
1825 Handle<Object> object, | 1825 Handle<Object> object, |
1826 Handle<Object> name, | 1826 Handle<Object> name, |
1827 Handle<Object> attributes); | 1827 Handle<Object> attributes); |
1828 MUST_USE_RESULT static Object* DefineProperties(Isolate* isolate, | 1828 MUST_USE_RESULT static Object* DefineProperties(Isolate* isolate, |
1829 Handle<Object> object, | 1829 Handle<Object> object, |
1830 Handle<Object> properties); | 1830 Handle<Object> properties); |
1831 | 1831 |
1832 // "virtual" dispatcher to the correct [[DefineOwnProperty]] implementation. | 1832 // "virtual" dispatcher to the correct [[DefineOwnProperty]] implementation. |
1833 static bool DefineOwnProperty(Isolate* isolate, Handle<JSReceiver> object, | 1833 MUST_USE_RESULT static Maybe<bool> DefineOwnProperty( |
1834 Handle<Object> key, PropertyDescriptor* desc, | 1834 Isolate* isolate, Handle<JSReceiver> object, Handle<Object> key, |
1835 ShouldThrow should_throw); | 1835 PropertyDescriptor* desc, ShouldThrow should_throw); |
1836 | 1836 |
1837 // ES6 7.3.4 (when passed DONT_THROW) | 1837 // ES6 7.3.4 (when passed DONT_THROW) |
1838 MUST_USE_RESULT static Maybe<bool> CreateDataProperty( | 1838 MUST_USE_RESULT static Maybe<bool> CreateDataProperty( |
1839 LookupIterator* it, Handle<Object> value, ShouldThrow should_throw); | 1839 LookupIterator* it, Handle<Object> value, ShouldThrow should_throw); |
1840 | 1840 |
1841 // ES6 9.1.6.1 | 1841 // ES6 9.1.6.1 |
1842 static bool OrdinaryDefineOwnProperty(Isolate* isolate, | 1842 MUST_USE_RESULT static Maybe<bool> OrdinaryDefineOwnProperty( |
1843 Handle<JSObject> object, | 1843 Isolate* isolate, Handle<JSObject> object, Handle<Object> key, |
1844 Handle<Object> key, | 1844 PropertyDescriptor* desc, ShouldThrow should_throw); |
1845 PropertyDescriptor* desc, | 1845 MUST_USE_RESULT static Maybe<bool> OrdinaryDefineOwnProperty( |
1846 ShouldThrow should_throw); | 1846 LookupIterator* it, PropertyDescriptor* desc, ShouldThrow should_throw); |
1847 static bool OrdinaryDefineOwnProperty(LookupIterator* it, | |
1848 PropertyDescriptor* desc, | |
1849 ShouldThrow should_throw); | |
1850 // ES6 9.1.6.2 | 1847 // ES6 9.1.6.2 |
1851 static bool IsCompatiblePropertyDescriptor(Isolate* isolate, bool extensible, | 1848 MUST_USE_RESULT static Maybe<bool> IsCompatiblePropertyDescriptor( |
1852 PropertyDescriptor* desc, | 1849 Isolate* isolate, bool extensible, PropertyDescriptor* desc, |
1853 PropertyDescriptor* current, | 1850 PropertyDescriptor* current, Handle<Name> property_name); |
1854 Handle<Name> property_name); | |
1855 // ES6 9.1.6.3 | 1851 // ES6 9.1.6.3 |
1856 // |it| can be NULL in cases where the ES spec passes |undefined| as the | 1852 // |it| can be NULL in cases where the ES spec passes |undefined| as the |
1857 // receiver. Exactly one of |it| and |property_name| must be provided. | 1853 // receiver. Exactly one of |it| and |property_name| must be provided. |
1858 static bool ValidateAndApplyPropertyDescriptor( | 1854 MUST_USE_RESULT static Maybe<bool> ValidateAndApplyPropertyDescriptor( |
1859 Isolate* isolate, LookupIterator* it, bool extensible, | 1855 Isolate* isolate, LookupIterator* it, bool extensible, |
1860 PropertyDescriptor* desc, PropertyDescriptor* current, | 1856 PropertyDescriptor* desc, PropertyDescriptor* current, |
1861 ShouldThrow should_throw, Handle<Name> property_name = Handle<Name>()); | 1857 ShouldThrow should_throw, Handle<Name> property_name = Handle<Name>()); |
1862 | 1858 |
1863 static bool GetOwnPropertyDescriptor(Isolate* isolate, | 1859 MUST_USE_RESULT static Maybe<bool> GetOwnPropertyDescriptor( |
1864 Handle<JSReceiver> object, | 1860 Isolate* isolate, Handle<JSReceiver> object, Handle<Object> key, |
1865 Handle<Object> key, | 1861 PropertyDescriptor* desc); |
1866 PropertyDescriptor* desc); | 1862 MUST_USE_RESULT static Maybe<bool> GetOwnPropertyDescriptor( |
1867 static bool GetOwnPropertyDescriptor(LookupIterator* it, | 1863 LookupIterator* it, PropertyDescriptor* desc); |
1868 PropertyDescriptor* desc); | |
1869 | 1864 |
1870 typedef PropertyAttributes IntegrityLevel; | 1865 typedef PropertyAttributes IntegrityLevel; |
1871 | 1866 |
1872 // ES6 7.3.14 (when passed DONT_THROW) | 1867 // ES6 7.3.14 (when passed DONT_THROW) |
1873 // 'level' must be SEALED or FROZEN. | 1868 // 'level' must be SEALED or FROZEN. |
1874 MUST_USE_RESULT static Maybe<bool> SetIntegrityLevel( | 1869 MUST_USE_RESULT static Maybe<bool> SetIntegrityLevel( |
1875 Handle<JSReceiver> object, IntegrityLevel lvl, ShouldThrow should_throw); | 1870 Handle<JSReceiver> object, IntegrityLevel lvl, ShouldThrow should_throw); |
1876 | 1871 |
1877 // ES6 7.3.15 | 1872 // ES6 7.3.15 |
1878 // 'level' must be SEALED or FROZEN. | 1873 // 'level' must be SEALED or FROZEN. |
(...skipping 7633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9512 bool from_javascript, | 9507 bool from_javascript, |
9513 ShouldThrow should_throw); | 9508 ShouldThrow should_throw); |
9514 // ES6 9.5.3 | 9509 // ES6 9.5.3 |
9515 MUST_USE_RESULT static Maybe<bool> IsExtensible(Handle<JSProxy> proxy); | 9510 MUST_USE_RESULT static Maybe<bool> IsExtensible(Handle<JSProxy> proxy); |
9516 | 9511 |
9517 // ES6 9.5.4 (when passed DONT_THROW) | 9512 // ES6 9.5.4 (when passed DONT_THROW) |
9518 MUST_USE_RESULT static Maybe<bool> PreventExtensions( | 9513 MUST_USE_RESULT static Maybe<bool> PreventExtensions( |
9519 Handle<JSProxy> proxy, ShouldThrow should_throw); | 9514 Handle<JSProxy> proxy, ShouldThrow should_throw); |
9520 | 9515 |
9521 // ES6 9.5.5 | 9516 // ES6 9.5.5 |
9522 static bool GetOwnPropertyDescriptor(Isolate* isolate, Handle<JSProxy> proxy, | 9517 MUST_USE_RESULT static Maybe<bool> GetOwnPropertyDescriptor( |
9523 Handle<Name> name, | 9518 Isolate* isolate, Handle<JSProxy> proxy, Handle<Name> name, |
9524 PropertyDescriptor* desc); | 9519 PropertyDescriptor* desc); |
9525 | 9520 |
9526 // ES6 9.5.6 | 9521 // ES6 9.5.6 |
9527 static bool DefineOwnProperty(Isolate* isolate, Handle<JSProxy> object, | 9522 MUST_USE_RESULT static Maybe<bool> DefineOwnProperty( |
9528 Handle<Object> key, PropertyDescriptor* desc, | 9523 Isolate* isolate, Handle<JSProxy> object, Handle<Object> key, |
9529 ShouldThrow should_throw); | 9524 PropertyDescriptor* desc, ShouldThrow should_throw); |
9530 | 9525 |
9531 // ES6 9.5.7 | 9526 // ES6 9.5.7 |
9532 MUST_USE_RESULT static Maybe<bool> HasProperty(Isolate* isolate, | 9527 MUST_USE_RESULT static Maybe<bool> HasProperty(Isolate* isolate, |
9533 Handle<JSProxy> proxy, | 9528 Handle<JSProxy> proxy, |
9534 Handle<Name> name); | 9529 Handle<Name> name); |
9535 | 9530 |
9536 // ES6 9.5.8 | 9531 // ES6 9.5.8 |
9537 MUST_USE_RESULT static MaybeHandle<Object> GetProperty( | 9532 MUST_USE_RESULT static MaybeHandle<Object> GetProperty( |
9538 Isolate* isolate, Handle<JSProxy> proxy, Handle<Name> name, | 9533 Isolate* isolate, Handle<JSProxy> proxy, Handle<Name> name, |
9539 Handle<Object> receiver, LanguageMode language_mode); | 9534 Handle<Object> receiver, LanguageMode language_mode); |
9540 | 9535 |
9541 // ES6 9.5.9 | 9536 // ES6 9.5.9 |
9542 MUST_USE_RESULT static Maybe<bool> SetProperty(Handle<JSProxy> proxy, | 9537 MUST_USE_RESULT static Maybe<bool> SetProperty(Handle<JSProxy> proxy, |
9543 Handle<Name> name, | 9538 Handle<Name> name, |
9544 Handle<Object> value, | 9539 Handle<Object> value, |
9545 Handle<Object> receiver, | 9540 Handle<Object> receiver, |
9546 LanguageMode language_mode); | 9541 LanguageMode language_mode); |
9547 | 9542 |
9548 // ES6 9.5.10 (when passed SLOPPY) | 9543 // ES6 9.5.10 (when passed SLOPPY) |
9549 MUST_USE_RESULT static Maybe<bool> DeletePropertyOrElement( | 9544 MUST_USE_RESULT static Maybe<bool> DeletePropertyOrElement( |
9550 Handle<JSProxy> proxy, Handle<Name> name, LanguageMode language_mode); | 9545 Handle<JSProxy> proxy, Handle<Name> name, LanguageMode language_mode); |
9551 | 9546 |
9552 // ES6 9.5.11 | 9547 // ES6 9.5.11 |
9553 static bool Enumerate(Isolate* isolate, Handle<JSReceiver> receiver, | 9548 MUST_USE_RESULT static Maybe<bool> Enumerate(Isolate* isolate, |
9554 Handle<JSProxy> proxy, KeyAccumulator* accumulator); | 9549 Handle<JSReceiver> receiver, |
| 9550 Handle<JSProxy> proxy, |
| 9551 KeyAccumulator* accumulator); |
9555 | 9552 |
9556 // ES6 9.5.12 | 9553 // ES6 9.5.12 |
9557 static bool OwnPropertyKeys(Isolate* isolate, Handle<JSReceiver> receiver, | 9554 MUST_USE_RESULT static Maybe<bool> OwnPropertyKeys( |
9558 Handle<JSProxy> proxy, PropertyFilter filter, | 9555 Isolate* isolate, Handle<JSReceiver> receiver, Handle<JSProxy> proxy, |
9559 KeyAccumulator* accumulator); | 9556 PropertyFilter filter, KeyAccumulator* accumulator); |
9560 | 9557 |
9561 MUST_USE_RESULT static Maybe<PropertyAttributes> GetPropertyAttributes( | 9558 MUST_USE_RESULT static Maybe<PropertyAttributes> GetPropertyAttributes( |
9562 LookupIterator* it); | 9559 LookupIterator* it); |
9563 | 9560 |
9564 // Dispatched behavior. | 9561 // Dispatched behavior. |
9565 DECLARE_PRINTER(JSProxy) | 9562 DECLARE_PRINTER(JSProxy) |
9566 DECLARE_VERIFIER(JSProxy) | 9563 DECLARE_VERIFIER(JSProxy) |
9567 | 9564 |
9568 // Layout description. We add padding so that a proxy has the same | 9565 // Layout description. We add padding so that a proxy has the same |
9569 // size as a virgin JSObject. This is essential for becoming a JSObject | 9566 // size as a virgin JSObject. This is essential for becoming a JSObject |
9570 // upon freeze. | 9567 // upon freeze. |
9571 static const int kTargetOffset = HeapObject::kHeaderSize; | 9568 static const int kTargetOffset = HeapObject::kHeaderSize; |
9572 static const int kHandlerOffset = kTargetOffset + kPointerSize; | 9569 static const int kHandlerOffset = kTargetOffset + kPointerSize; |
9573 static const int kHashOffset = kHandlerOffset + kPointerSize; | 9570 static const int kHashOffset = kHandlerOffset + kPointerSize; |
9574 static const int kSize = kHashOffset + kPointerSize; | 9571 static const int kSize = kHashOffset + kPointerSize; |
9575 | 9572 |
9576 typedef FixedBodyDescriptor<kTargetOffset, kSize, kSize> BodyDescriptor; | 9573 typedef FixedBodyDescriptor<kTargetOffset, kSize, kSize> BodyDescriptor; |
9577 | 9574 |
9578 MUST_USE_RESULT Object* GetIdentityHash(); | 9575 MUST_USE_RESULT Object* GetIdentityHash(); |
9579 | 9576 |
9580 static Handle<Smi> GetOrCreateIdentityHash(Handle<JSProxy> proxy); | 9577 static Handle<Smi> GetOrCreateIdentityHash(Handle<JSProxy> proxy); |
9581 | 9578 |
9582 private: | 9579 private: |
9583 friend class JSReceiver; | |
9584 | |
9585 MUST_USE_RESULT static MaybeHandle<Object> GetTrap(Handle<JSProxy> proxy, | |
9586 Handle<String> trap); | |
9587 | |
9588 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy); | 9580 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy); |
9589 }; | 9581 }; |
9590 | 9582 |
9591 | 9583 |
9592 class JSCollection : public JSObject { | 9584 class JSCollection : public JSObject { |
9593 public: | 9585 public: |
9594 // [table]: the backing hash table | 9586 // [table]: the backing hash table |
9595 DECL_ACCESSORS(table, Object) | 9587 DECL_ACCESSORS(table, Object) |
9596 | 9588 |
9597 static const int kTableOffset = JSObject::kHeaderSize; | 9589 static const int kTableOffset = JSObject::kHeaderSize; |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10056 | 10048 |
10057 static void SetLength(Handle<JSArray> array, uint32_t length); | 10049 static void SetLength(Handle<JSArray> array, uint32_t length); |
10058 // Same as above but will also queue splice records if |array| is observed. | 10050 // Same as above but will also queue splice records if |array| is observed. |
10059 static MaybeHandle<Object> ObservableSetLength(Handle<JSArray> array, | 10051 static MaybeHandle<Object> ObservableSetLength(Handle<JSArray> array, |
10060 uint32_t length); | 10052 uint32_t length); |
10061 | 10053 |
10062 // Set the content of the array to the content of storage. | 10054 // Set the content of the array to the content of storage. |
10063 static inline void SetContent(Handle<JSArray> array, | 10055 static inline void SetContent(Handle<JSArray> array, |
10064 Handle<FixedArrayBase> storage); | 10056 Handle<FixedArrayBase> storage); |
10065 | 10057 |
10066 static bool DefineOwnProperty(Isolate* isolate, Handle<JSArray> o, | 10058 // ES6 9.4.2.1 |
10067 Handle<Object> name, PropertyDescriptor* desc, | 10059 MUST_USE_RESULT static Maybe<bool> DefineOwnProperty( |
10068 ShouldThrow should_throw); | 10060 Isolate* isolate, Handle<JSArray> o, Handle<Object> name, |
| 10061 PropertyDescriptor* desc, ShouldThrow should_throw); |
10069 | 10062 |
10070 static bool AnythingToArrayLength(Isolate* isolate, | 10063 static bool AnythingToArrayLength(Isolate* isolate, |
10071 Handle<Object> length_object, | 10064 Handle<Object> length_object, |
10072 uint32_t* output); | 10065 uint32_t* output); |
10073 static bool ArraySetLength(Isolate* isolate, Handle<JSArray> a, | 10066 MUST_USE_RESULT static Maybe<bool> ArraySetLength(Isolate* isolate, |
10074 PropertyDescriptor* desc, | 10067 Handle<JSArray> a, |
10075 ShouldThrow should_throw); | 10068 PropertyDescriptor* desc, |
| 10069 ShouldThrow should_throw); |
10076 | 10070 |
10077 DECLARE_CAST(JSArray) | 10071 DECLARE_CAST(JSArray) |
10078 | 10072 |
10079 // Dispatched behavior. | 10073 // Dispatched behavior. |
10080 DECLARE_PRINTER(JSArray) | 10074 DECLARE_PRINTER(JSArray) |
10081 DECLARE_VERIFIER(JSArray) | 10075 DECLARE_VERIFIER(JSArray) |
10082 | 10076 |
10083 // Number of element slots to pre-allocate for an empty array. | 10077 // Number of element slots to pre-allocate for an empty array. |
10084 static const int kPreallocatedArrayElements = 4; | 10078 static const int kPreallocatedArrayElements = 4; |
10085 | 10079 |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10684 } | 10678 } |
10685 return value; | 10679 return value; |
10686 } | 10680 } |
10687 }; | 10681 }; |
10688 | 10682 |
10689 | 10683 |
10690 } // NOLINT, false-positive due to second-order macros. | 10684 } // NOLINT, false-positive due to second-order macros. |
10691 } // NOLINT, false-positive due to second-order macros. | 10685 } // NOLINT, false-positive due to second-order macros. |
10692 | 10686 |
10693 #endif // V8_OBJECTS_H_ | 10687 #endif // V8_OBJECTS_H_ |
OLD | NEW |