| 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 841 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 852 class FixedArrayBase; | 852 class FixedArrayBase; |
| 853 class FunctionLiteral; | 853 class FunctionLiteral; |
| 854 class GlobalObject; | 854 class GlobalObject; |
| 855 class JSBuiltinsObject; | 855 class JSBuiltinsObject; |
| 856 class LayoutDescriptor; | 856 class LayoutDescriptor; |
| 857 class LiteralsArray; | 857 class LiteralsArray; |
| 858 class LookupIterator; | 858 class LookupIterator; |
| 859 class ObjectHashTable; | 859 class ObjectHashTable; |
| 860 class ObjectVisitor; | 860 class ObjectVisitor; |
| 861 class PropertyCell; | 861 class PropertyCell; |
| 862 class PropertyDescriptor; |
| 862 class SafepointEntry; | 863 class SafepointEntry; |
| 863 class SharedFunctionInfo; | 864 class SharedFunctionInfo; |
| 864 class StringStream; | 865 class StringStream; |
| 865 class TypeFeedbackInfo; | 866 class TypeFeedbackInfo; |
| 866 class TypeFeedbackVector; | 867 class TypeFeedbackVector; |
| 867 class WeakCell; | 868 class WeakCell; |
| 868 | 869 |
| 869 // We cannot just say "class HeapType;" if it is created from a template... =8-? | 870 // We cannot just say "class HeapType;" if it is created from a template... =8-? |
| 870 template<class> class TypeImpl; | 871 template<class> class TypeImpl; |
| 871 struct HeapTypeConfig; | 872 struct HeapTypeConfig; |
| (...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1773 // Indicator for one component of an AccessorPair. | 1774 // Indicator for one component of an AccessorPair. |
| 1774 enum AccessorComponent { | 1775 enum AccessorComponent { |
| 1775 ACCESSOR_GETTER, | 1776 ACCESSOR_GETTER, |
| 1776 ACCESSOR_SETTER | 1777 ACCESSOR_SETTER |
| 1777 }; | 1778 }; |
| 1778 | 1779 |
| 1779 | 1780 |
| 1780 enum KeyFilter { SKIP_SYMBOLS, INCLUDE_SYMBOLS }; | 1781 enum KeyFilter { SKIP_SYMBOLS, INCLUDE_SYMBOLS }; |
| 1781 | 1782 |
| 1782 | 1783 |
| 1784 enum ShouldThrow { THROW_ON_ERROR, DONT_THROW }; |
| 1785 |
| 1786 |
| 1783 // JSReceiver includes types on which properties can be defined, i.e., | 1787 // JSReceiver includes types on which properties can be defined, i.e., |
| 1784 // JSObject and JSProxy. | 1788 // JSObject and JSProxy. |
| 1785 class JSReceiver: public HeapObject { | 1789 class JSReceiver: public HeapObject { |
| 1786 public: | 1790 public: |
| 1787 DECLARE_CAST(JSReceiver) | 1791 DECLARE_CAST(JSReceiver) |
| 1788 | 1792 |
| 1789 // ES6 section 7.1.1 ToPrimitive | 1793 // ES6 section 7.1.1 ToPrimitive |
| 1790 MUST_USE_RESULT static MaybeHandle<Object> ToPrimitive( | 1794 MUST_USE_RESULT static MaybeHandle<Object> ToPrimitive( |
| 1791 Handle<JSReceiver> receiver, | 1795 Handle<JSReceiver> receiver, |
| 1792 ToPrimitiveHint hint = ToPrimitiveHint::kDefault); | 1796 ToPrimitiveHint hint = ToPrimitiveHint::kDefault); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1809 LanguageMode language_mode = SLOPPY); | 1813 LanguageMode language_mode = SLOPPY); |
| 1810 MUST_USE_RESULT static MaybeHandle<Object> DeleteProperty( | 1814 MUST_USE_RESULT static MaybeHandle<Object> DeleteProperty( |
| 1811 Handle<JSReceiver> object, Handle<Name> name, | 1815 Handle<JSReceiver> object, Handle<Name> name, |
| 1812 LanguageMode language_mode = SLOPPY); | 1816 LanguageMode language_mode = SLOPPY); |
| 1813 MUST_USE_RESULT static MaybeHandle<Object> DeleteProperty( | 1817 MUST_USE_RESULT static MaybeHandle<Object> DeleteProperty( |
| 1814 LookupIterator* it, LanguageMode language_mode); | 1818 LookupIterator* it, LanguageMode language_mode); |
| 1815 MUST_USE_RESULT static MaybeHandle<Object> DeleteElement( | 1819 MUST_USE_RESULT static MaybeHandle<Object> DeleteElement( |
| 1816 Handle<JSReceiver> object, uint32_t index, | 1820 Handle<JSReceiver> object, uint32_t index, |
| 1817 LanguageMode language_mode = SLOPPY); | 1821 LanguageMode language_mode = SLOPPY); |
| 1818 | 1822 |
| 1823 MUST_USE_RESULT static Object* DefineProperty(Isolate* isolate, |
| 1824 Handle<Object> object, |
| 1825 Handle<Object> name, |
| 1826 Handle<Object> attributes); |
| 1827 MUST_USE_RESULT static Object* DefineProperties(Isolate* isolate, |
| 1828 Handle<Object> object, |
| 1829 Handle<Object> properties); |
| 1830 |
| 1831 // "virtual" dispatcher to the correct [[DefineOwnProperty]] implementation. |
| 1832 static bool DefineOwnProperty(Isolate* isolate, Handle<JSObject> object, |
| 1833 Handle<Object> key, PropertyDescriptor* desc, |
| 1834 ShouldThrow should_throw); |
| 1835 |
| 1836 static bool OrdinaryDefineOwnProperty(Isolate* isolate, |
| 1837 Handle<JSObject> object, |
| 1838 Handle<Object> key, |
| 1839 PropertyDescriptor* desc, |
| 1840 ShouldThrow should_throw); |
| 1841 static bool OrdinaryDefineOwnProperty(LookupIterator* it, |
| 1842 PropertyDescriptor* desc, |
| 1843 ShouldThrow should_throw); |
| 1844 |
| 1845 static bool GetOwnPropertyDescriptor(Isolate* isolate, |
| 1846 Handle<JSObject> object, |
| 1847 Handle<Object> key, |
| 1848 PropertyDescriptor* desc); |
| 1849 static bool GetOwnPropertyDescriptor(LookupIterator* it, |
| 1850 PropertyDescriptor* desc); |
| 1851 |
| 1819 // Tests for the fast common case for property enumeration. | 1852 // Tests for the fast common case for property enumeration. |
| 1820 bool IsSimpleEnum(); | 1853 bool IsSimpleEnum(); |
| 1821 | 1854 |
| 1822 // Returns the class name ([[Class]] property in the specification). | 1855 // Returns the class name ([[Class]] property in the specification). |
| 1823 String* class_name(); | 1856 String* class_name(); |
| 1824 | 1857 |
| 1825 // Returns the constructor name (the name (possibly, inferred name) of the | 1858 // Returns the constructor name (the name (possibly, inferred name) of the |
| 1826 // function that was used to instantiate the object). | 1859 // function that was used to instantiate the object). |
| 1827 String* constructor_name(); | 1860 String* constructor_name(); |
| 1828 | 1861 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2055 Handle<Name> name, | 2088 Handle<Name> name, |
| 2056 AccessorComponent component); | 2089 AccessorComponent component); |
| 2057 | 2090 |
| 2058 // Defines an AccessorPair property on the given object. | 2091 // Defines an AccessorPair property on the given object. |
| 2059 // TODO(mstarzinger): Rename to SetAccessor(). | 2092 // TODO(mstarzinger): Rename to SetAccessor(). |
| 2060 static MaybeHandle<Object> DefineAccessor(Handle<JSObject> object, | 2093 static MaybeHandle<Object> DefineAccessor(Handle<JSObject> object, |
| 2061 Handle<Name> name, | 2094 Handle<Name> name, |
| 2062 Handle<Object> getter, | 2095 Handle<Object> getter, |
| 2063 Handle<Object> setter, | 2096 Handle<Object> setter, |
| 2064 PropertyAttributes attributes); | 2097 PropertyAttributes attributes); |
| 2098 static MaybeHandle<Object> DefineAccessor(LookupIterator* it, |
| 2099 Handle<Object> getter, |
| 2100 Handle<Object> setter, |
| 2101 PropertyAttributes attributes); |
| 2065 | 2102 |
| 2066 // Defines an AccessorInfo property on the given object. | 2103 // Defines an AccessorInfo property on the given object. |
| 2067 MUST_USE_RESULT static MaybeHandle<Object> SetAccessor( | 2104 MUST_USE_RESULT static MaybeHandle<Object> SetAccessor( |
| 2068 Handle<JSObject> object, | 2105 Handle<JSObject> object, |
| 2069 Handle<AccessorInfo> info); | 2106 Handle<AccessorInfo> info); |
| 2070 | 2107 |
| 2071 // The result must be checked first for exceptions. If there's no exception, | 2108 // The result must be checked first for exceptions. If there's no exception, |
| 2072 // the output parameter |done| indicates whether the interceptor has a result | 2109 // the output parameter |done| indicates whether the interceptor has a result |
| 2073 // or not. | 2110 // or not. |
| 2074 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithInterceptor( | 2111 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithInterceptor( |
| (...skipping 7939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10014 | 10051 |
| 10015 static void SetLength(Handle<JSArray> array, uint32_t length); | 10052 static void SetLength(Handle<JSArray> array, uint32_t length); |
| 10016 // Same as above but will also queue splice records if |array| is observed. | 10053 // Same as above but will also queue splice records if |array| is observed. |
| 10017 static MaybeHandle<Object> ObservableSetLength(Handle<JSArray> array, | 10054 static MaybeHandle<Object> ObservableSetLength(Handle<JSArray> array, |
| 10018 uint32_t length); | 10055 uint32_t length); |
| 10019 | 10056 |
| 10020 // Set the content of the array to the content of storage. | 10057 // Set the content of the array to the content of storage. |
| 10021 static inline void SetContent(Handle<JSArray> array, | 10058 static inline void SetContent(Handle<JSArray> array, |
| 10022 Handle<FixedArrayBase> storage); | 10059 Handle<FixedArrayBase> storage); |
| 10023 | 10060 |
| 10061 static bool DefineOwnProperty(Isolate* isolate, Handle<JSArray> o, |
| 10062 Handle<Object> name, PropertyDescriptor* desc, |
| 10063 ShouldThrow should_throw); |
| 10064 |
| 10065 static bool ArraySetLength(Isolate* isolate, Handle<JSArray> a, |
| 10066 PropertyDescriptor* desc, |
| 10067 ShouldThrow should_throw); |
| 10068 |
| 10024 DECLARE_CAST(JSArray) | 10069 DECLARE_CAST(JSArray) |
| 10025 | 10070 |
| 10026 // Dispatched behavior. | 10071 // Dispatched behavior. |
| 10027 DECLARE_PRINTER(JSArray) | 10072 DECLARE_PRINTER(JSArray) |
| 10028 DECLARE_VERIFIER(JSArray) | 10073 DECLARE_VERIFIER(JSArray) |
| 10029 | 10074 |
| 10030 // Number of element slots to pre-allocate for an empty array. | 10075 // Number of element slots to pre-allocate for an empty array. |
| 10031 static const int kPreallocatedArrayElements = 4; | 10076 static const int kPreallocatedArrayElements = 4; |
| 10032 | 10077 |
| 10033 // Layout description. | 10078 // Layout description. |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10662 Handle<FixedArray> keys_; | 10707 Handle<FixedArray> keys_; |
| 10663 Handle<OrderedHashSet> set_; | 10708 Handle<OrderedHashSet> set_; |
| 10664 int length_; | 10709 int length_; |
| 10665 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator); | 10710 DISALLOW_COPY_AND_ASSIGN(KeyAccumulator); |
| 10666 }; | 10711 }; |
| 10667 | 10712 |
| 10668 } // NOLINT, false-positive due to second-order macros. | 10713 } // NOLINT, false-positive due to second-order macros. |
| 10669 } // NOLINT, false-positive due to second-order macros. | 10714 } // NOLINT, false-positive due to second-order macros. |
| 10670 | 10715 |
| 10671 #endif // V8_OBJECTS_H_ | 10716 #endif // V8_OBJECTS_H_ |
| OLD | NEW |