| 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 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1091 | 1091 |
| 1092 inline ElementsKind OptimalElementsKind(); | 1092 inline ElementsKind OptimalElementsKind(); |
| 1093 | 1093 |
| 1094 inline bool FitsRepresentation(Representation representation); | 1094 inline bool FitsRepresentation(Representation representation); |
| 1095 | 1095 |
| 1096 // Checks whether two valid primitive encodings of a property name resolve to | 1096 // Checks whether two valid primitive encodings of a property name resolve to |
| 1097 // the same logical property. E.g., the smi 1, the string "1" and the double | 1097 // the same logical property. E.g., the smi 1, the string "1" and the double |
| 1098 // 1 all refer to the same property, so this helper will return true. | 1098 // 1 all refer to the same property, so this helper will return true. |
| 1099 inline bool KeyEquals(Object* other); | 1099 inline bool KeyEquals(Object* other); |
| 1100 | 1100 |
| 1101 inline bool FilterKey(PropertyAttributes filter); | 1101 inline bool FilterKey(PropertyFilter filter); |
| 1102 | 1102 |
| 1103 Handle<HeapType> OptimalType(Isolate* isolate, Representation representation); | 1103 Handle<HeapType> OptimalType(Isolate* isolate, Representation representation); |
| 1104 | 1104 |
| 1105 inline static Handle<Object> NewStorageFor(Isolate* isolate, | 1105 inline static Handle<Object> NewStorageFor(Isolate* isolate, |
| 1106 Handle<Object> object, | 1106 Handle<Object> object, |
| 1107 Representation representation); | 1107 Representation representation); |
| 1108 | 1108 |
| 1109 inline static Handle<Object> WrapForRead(Isolate* isolate, | 1109 inline static Handle<Object> WrapForRead(Isolate* isolate, |
| 1110 Handle<Object> object, | 1110 Handle<Object> object, |
| 1111 Representation representation); | 1111 Representation representation); |
| (...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1766 }; | 1766 }; |
| 1767 | 1767 |
| 1768 | 1768 |
| 1769 // Indicator for one component of an AccessorPair. | 1769 // Indicator for one component of an AccessorPair. |
| 1770 enum AccessorComponent { | 1770 enum AccessorComponent { |
| 1771 ACCESSOR_GETTER, | 1771 ACCESSOR_GETTER, |
| 1772 ACCESSOR_SETTER | 1772 ACCESSOR_SETTER |
| 1773 }; | 1773 }; |
| 1774 | 1774 |
| 1775 | 1775 |
| 1776 enum KeyFilter { SKIP_SYMBOLS, INCLUDE_SYMBOLS }; | |
| 1777 | |
| 1778 enum Enumerability { RESPECT_ENUMERABILITY, IGNORE_ENUMERABILITY }; | |
| 1779 | |
| 1780 enum GetKeysConversion { KEEP_NUMBERS, CONVERT_TO_STRING }; | 1776 enum GetKeysConversion { KEEP_NUMBERS, CONVERT_TO_STRING }; |
| 1781 | 1777 |
| 1782 | 1778 |
| 1783 // JSReceiver includes types on which properties can be defined, i.e., | 1779 // JSReceiver includes types on which properties can be defined, i.e., |
| 1784 // JSObject and JSProxy. | 1780 // JSObject and JSProxy. |
| 1785 class JSReceiver: public HeapObject { | 1781 class JSReceiver: public HeapObject { |
| 1786 public: | 1782 public: |
| 1787 DECLARE_CAST(JSReceiver) | 1783 DECLARE_CAST(JSReceiver) |
| 1788 | 1784 |
| 1789 // ES6 section 7.1.1 ToPrimitive | 1785 // ES6 section 7.1.1 ToPrimitive |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1916 // Retrieves a permanent object identity hash code. May create and store a | 1912 // Retrieves a permanent object identity hash code. May create and store a |
| 1917 // hash code if needed and none exists. | 1913 // hash code if needed and none exists. |
| 1918 inline static Handle<Smi> GetOrCreateIdentityHash( | 1914 inline static Handle<Smi> GetOrCreateIdentityHash( |
| 1919 Handle<JSReceiver> object); | 1915 Handle<JSReceiver> object); |
| 1920 | 1916 |
| 1921 enum KeyCollectionType { OWN_ONLY, INCLUDE_PROTOS }; | 1917 enum KeyCollectionType { OWN_ONLY, INCLUDE_PROTOS }; |
| 1922 | 1918 |
| 1923 // Computes the enumerable keys for a JSObject. Used for implementing | 1919 // Computes the enumerable keys for a JSObject. Used for implementing |
| 1924 // "for (n in object) { }". | 1920 // "for (n in object) { }". |
| 1925 MUST_USE_RESULT static MaybeHandle<FixedArray> GetKeys( | 1921 MUST_USE_RESULT static MaybeHandle<FixedArray> GetKeys( |
| 1926 Handle<JSReceiver> object, KeyCollectionType type, | 1922 Handle<JSReceiver> object, KeyCollectionType type, PropertyFilter filter, |
| 1927 KeyFilter filter = SKIP_SYMBOLS, | 1923 GetKeysConversion keys_conversion = KEEP_NUMBERS); |
| 1928 GetKeysConversion keys_conversion = KEEP_NUMBERS, | |
| 1929 Enumerability enum_policy = RESPECT_ENUMERABILITY); | |
| 1930 | 1924 |
| 1931 private: | 1925 private: |
| 1932 DISALLOW_IMPLICIT_CONSTRUCTORS(JSReceiver); | 1926 DISALLOW_IMPLICIT_CONSTRUCTORS(JSReceiver); |
| 1933 }; | 1927 }; |
| 1934 | 1928 |
| 1935 | 1929 |
| 1936 // The JSObject describes real heap allocated JavaScript objects with | 1930 // The JSObject describes real heap allocated JavaScript objects with |
| 1937 // properties. | 1931 // properties. |
| 1938 // Note that the map of JSObject changes during execution to enable inline | 1932 // Note that the map of JSObject changes during execution to enable inline |
| 1939 // caching. | 1933 // caching. |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2247 | 2241 |
| 2248 static inline int GetInternalFieldCount(Map* map); | 2242 static inline int GetInternalFieldCount(Map* map); |
| 2249 inline int GetInternalFieldCount(); | 2243 inline int GetInternalFieldCount(); |
| 2250 inline int GetInternalFieldOffset(int index); | 2244 inline int GetInternalFieldOffset(int index); |
| 2251 inline Object* GetInternalField(int index); | 2245 inline Object* GetInternalField(int index); |
| 2252 inline void SetInternalField(int index, Object* value); | 2246 inline void SetInternalField(int index, Object* value); |
| 2253 inline void SetInternalField(int index, Smi* value); | 2247 inline void SetInternalField(int index, Smi* value); |
| 2254 | 2248 |
| 2255 // Returns the number of properties on this object filtering out properties | 2249 // Returns the number of properties on this object filtering out properties |
| 2256 // with the specified attributes (ignoring interceptors). | 2250 // with the specified attributes (ignoring interceptors). |
| 2257 int NumberOfOwnProperties(PropertyAttributes filter = NONE); | 2251 int NumberOfOwnProperties(PropertyFilter filter = ALL_PROPERTIES); |
| 2258 // Fill in details for properties into storage starting at the specified | 2252 // Fill in details for properties into storage starting at the specified |
| 2259 // index. Returns the number of properties added. | 2253 // index. Returns the number of properties added. |
| 2260 int GetOwnPropertyNames(FixedArray* storage, int index, | 2254 int GetOwnPropertyNames(FixedArray* storage, int index, |
| 2261 PropertyAttributes filter = NONE); | 2255 PropertyFilter filter = ALL_PROPERTIES); |
| 2262 void CollectOwnPropertyNames(KeyAccumulator* keys, | 2256 void CollectOwnPropertyNames(KeyAccumulator* keys, |
| 2263 PropertyAttributes filter = NONE); | 2257 PropertyFilter filter = ALL_PROPERTIES); |
| 2264 | 2258 |
| 2265 // Returns the number of properties on this object filtering out properties | 2259 // Returns the number of properties on this object filtering out properties |
| 2266 // with the specified attributes (ignoring interceptors). | 2260 // with the specified attributes (ignoring interceptors). |
| 2267 int NumberOfOwnElements(PropertyAttributes filter); | 2261 int NumberOfOwnElements(PropertyFilter filter); |
| 2268 // Returns the number of enumerable elements (ignoring interceptors). | 2262 // Returns the number of enumerable elements (ignoring interceptors). |
| 2269 int NumberOfEnumElements(); | 2263 int NumberOfEnumElements(); |
| 2270 // Returns the number of elements on this object filtering out elements | 2264 // Returns the number of elements on this object filtering out elements |
| 2271 // with the specified attributes (ignoring interceptors). | 2265 // with the specified attributes (ignoring interceptors). |
| 2272 int GetOwnElementKeys(FixedArray* storage, PropertyAttributes filter); | 2266 int GetOwnElementKeys(FixedArray* storage, PropertyFilter filter); |
| 2273 static void CollectOwnElementKeys(Handle<JSObject> object, | 2267 static void CollectOwnElementKeys(Handle<JSObject> object, |
| 2274 KeyAccumulator* keys, | 2268 KeyAccumulator* keys, |
| 2275 PropertyAttributes filter); | 2269 PropertyFilter filter); |
| 2276 // Count and fill in the enumerable elements into storage. | 2270 // Count and fill in the enumerable elements into storage. |
| 2277 // (storage->length() == NumberOfEnumElements()). | 2271 // (storage->length() == NumberOfEnumElements()). |
| 2278 // If storage is NULL, will count the elements without adding | 2272 // If storage is NULL, will count the elements without adding |
| 2279 // them to any storage. | 2273 // them to any storage. |
| 2280 // Returns the number of enumerable elements. | 2274 // Returns the number of enumerable elements. |
| 2281 int GetEnumElementKeys(FixedArray* storage); | 2275 int GetEnumElementKeys(FixedArray* storage); |
| 2282 | 2276 |
| 2283 static Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object, | 2277 static Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object, |
| 2284 bool cache_result); | 2278 bool cache_result); |
| 2285 | 2279 |
| (...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3350 Key key) { | 3344 Key key) { |
| 3351 return DerivedHashTable::Shrink(dictionary, key); | 3345 return DerivedHashTable::Shrink(dictionary, key); |
| 3352 } | 3346 } |
| 3353 | 3347 |
| 3354 // Sorting support | 3348 // Sorting support |
| 3355 // TODO(dcarney): templatize or move to SeededNumberDictionary | 3349 // TODO(dcarney): templatize or move to SeededNumberDictionary |
| 3356 void CopyValuesTo(FixedArray* elements); | 3350 void CopyValuesTo(FixedArray* elements); |
| 3357 | 3351 |
| 3358 // Returns the number of elements in the dictionary filtering out properties | 3352 // Returns the number of elements in the dictionary filtering out properties |
| 3359 // with the specified attributes. | 3353 // with the specified attributes. |
| 3360 int NumberOfElementsFilterAttributes(PropertyAttributes filter); | 3354 int NumberOfElementsFilterAttributes(PropertyFilter filter); |
| 3361 | 3355 |
| 3362 // Returns the number of enumerable elements in the dictionary. | 3356 // Returns the number of enumerable elements in the dictionary. |
| 3363 int NumberOfEnumElements() { | 3357 int NumberOfEnumElements() { |
| 3364 return NumberOfElementsFilterAttributes( | 3358 return NumberOfElementsFilterAttributes(ENUMERABLE_STRINGS); |
| 3365 static_cast<PropertyAttributes>(DONT_ENUM | SYMBOLIC)); | |
| 3366 } | 3359 } |
| 3367 | 3360 |
| 3368 // Returns true if the dictionary contains any elements that are non-writable, | 3361 // Returns true if the dictionary contains any elements that are non-writable, |
| 3369 // non-configurable, non-enumerable, or have getters/setters. | 3362 // non-configurable, non-enumerable, or have getters/setters. |
| 3370 bool HasComplexElements(); | 3363 bool HasComplexElements(); |
| 3371 | 3364 |
| 3372 enum SortMode { UNSORTED, SORTED }; | 3365 enum SortMode { UNSORTED, SORTED }; |
| 3373 | 3366 |
| 3374 // Fill in details for properties into storage. | 3367 // Fill in details for properties into storage. |
| 3375 // Returns the number of properties added. | 3368 // Returns the number of properties added. |
| 3376 int CopyKeysTo(FixedArray* storage, int index, PropertyAttributes filter, | 3369 int CopyKeysTo(FixedArray* storage, int index, PropertyFilter filter, |
| 3377 SortMode sort_mode); | 3370 SortMode sort_mode); |
| 3378 // Collect the keys into the given KeyAccumulator, in ascending chronological | 3371 // Collect the keys into the given KeyAccumulator, in ascending chronological |
| 3379 // order of property creation. | 3372 // order of property creation. |
| 3380 static void CollectKeysTo(Handle<Dictionary<Derived, Shape, Key> > dictionary, | 3373 static void CollectKeysTo(Handle<Dictionary<Derived, Shape, Key> > dictionary, |
| 3381 KeyAccumulator* keys, PropertyAttributes filter); | 3374 KeyAccumulator* keys, PropertyFilter filter); |
| 3382 | 3375 |
| 3383 // Copies enumerable keys to preallocated fixed array. | 3376 // Copies enumerable keys to preallocated fixed array. |
| 3384 void CopyEnumKeysTo(FixedArray* storage); | 3377 void CopyEnumKeysTo(FixedArray* storage); |
| 3385 | 3378 |
| 3386 // Accessors for next enumeration index. | 3379 // Accessors for next enumeration index. |
| 3387 void SetNextEnumerationIndex(int index) { | 3380 void SetNextEnumerationIndex(int index) { |
| 3388 DCHECK(index != 0); | 3381 DCHECK(index != 0); |
| 3389 this->set(kNextEnumerationIndexIndex, Smi::FromInt(index)); | 3382 this->set(kNextEnumerationIndexIndex, Smi::FromInt(index)); |
| 3390 } | 3383 } |
| 3391 | 3384 |
| (...skipping 2425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5817 // instance descriptors. | 5810 // instance descriptors. |
| 5818 static Handle<Map> Copy(Handle<Map> map, const char* reason); | 5811 static Handle<Map> Copy(Handle<Map> map, const char* reason); |
| 5819 static Handle<Map> Create(Isolate* isolate, int inobject_properties); | 5812 static Handle<Map> Create(Isolate* isolate, int inobject_properties); |
| 5820 | 5813 |
| 5821 // Returns the next free property index (only valid for FAST MODE). | 5814 // Returns the next free property index (only valid for FAST MODE). |
| 5822 int NextFreePropertyIndex(); | 5815 int NextFreePropertyIndex(); |
| 5823 | 5816 |
| 5824 // Returns the number of properties described in instance_descriptors | 5817 // Returns the number of properties described in instance_descriptors |
| 5825 // filtering out properties with the specified attributes. | 5818 // filtering out properties with the specified attributes. |
| 5826 int NumberOfDescribedProperties(DescriptorFlag which = OWN_DESCRIPTORS, | 5819 int NumberOfDescribedProperties(DescriptorFlag which = OWN_DESCRIPTORS, |
| 5827 PropertyAttributes filter = NONE); | 5820 PropertyFilter filter = ALL_PROPERTIES); |
| 5828 | 5821 |
| 5829 DECLARE_CAST(Map) | 5822 DECLARE_CAST(Map) |
| 5830 | 5823 |
| 5831 // Code cache operations. | 5824 // Code cache operations. |
| 5832 | 5825 |
| 5833 // Clears the code cache. | 5826 // Clears the code cache. |
| 5834 inline void ClearCodeCache(Heap* heap); | 5827 inline void ClearCodeCache(Heap* heap); |
| 5835 | 5828 |
| 5836 // Update code cache. | 5829 // Update code cache. |
| 5837 static void UpdateCodeCache(Handle<Map> map, | 5830 static void UpdateCodeCache(Handle<Map> map, |
| (...skipping 3704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9542 // ES6 9.5.10 (when passed SLOPPY) | 9535 // ES6 9.5.10 (when passed SLOPPY) |
| 9543 MUST_USE_RESULT static Maybe<bool> DeletePropertyOrElement( | 9536 MUST_USE_RESULT static Maybe<bool> DeletePropertyOrElement( |
| 9544 Handle<JSProxy> proxy, Handle<Name> name, LanguageMode language_mode); | 9537 Handle<JSProxy> proxy, Handle<Name> name, LanguageMode language_mode); |
| 9545 | 9538 |
| 9546 // ES6 9.5.11 | 9539 // ES6 9.5.11 |
| 9547 static bool Enumerate(Isolate* isolate, Handle<JSReceiver> receiver, | 9540 static bool Enumerate(Isolate* isolate, Handle<JSReceiver> receiver, |
| 9548 Handle<JSProxy> proxy, KeyAccumulator* accumulator); | 9541 Handle<JSProxy> proxy, KeyAccumulator* accumulator); |
| 9549 | 9542 |
| 9550 // ES6 9.5.12 | 9543 // ES6 9.5.12 |
| 9551 static bool OwnPropertyKeys(Isolate* isolate, Handle<JSReceiver> receiver, | 9544 static bool OwnPropertyKeys(Isolate* isolate, Handle<JSReceiver> receiver, |
| 9552 Handle<JSProxy> proxy, KeyFilter filter, | 9545 Handle<JSProxy> proxy, PropertyFilter filter, |
| 9553 Enumerability enum_policy, | |
| 9554 KeyAccumulator* accumulator); | 9546 KeyAccumulator* accumulator); |
| 9555 | 9547 |
| 9556 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithHandler( | 9548 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithHandler( |
| 9557 Handle<JSProxy> proxy, | 9549 Handle<JSProxy> proxy, |
| 9558 Handle<Object> receiver, | 9550 Handle<Object> receiver, |
| 9559 Handle<Name> name); | 9551 Handle<Name> name); |
| 9560 | 9552 |
| 9561 MUST_USE_RESULT static Maybe<PropertyAttributes> GetPropertyAttributes( | 9553 MUST_USE_RESULT static Maybe<PropertyAttributes> GetPropertyAttributes( |
| 9562 LookupIterator* it); | 9554 LookupIterator* it); |
| 9563 | 9555 |
| (...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10716 } | 10708 } |
| 10717 return value; | 10709 return value; |
| 10718 } | 10710 } |
| 10719 }; | 10711 }; |
| 10720 | 10712 |
| 10721 | 10713 |
| 10722 } // NOLINT, false-positive due to second-order macros. | 10714 } // NOLINT, false-positive due to second-order macros. |
| 10723 } // NOLINT, false-positive due to second-order macros. | 10715 } // NOLINT, false-positive due to second-order macros. |
| 10724 | 10716 |
| 10725 #endif // V8_OBJECTS_H_ | 10717 #endif // V8_OBJECTS_H_ |
| OLD | NEW |