| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/assert-scope.h" | 10 #include "src/assert-scope.h" |
| (...skipping 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1122 // ES6 section 7.2.13 Strict Equality Comparison | 1122 // ES6 section 7.2.13 Strict Equality Comparison |
| 1123 bool StrictEquals(Object* that); | 1123 bool StrictEquals(Object* that); |
| 1124 | 1124 |
| 1125 // Convert to a JSObject if needed. | 1125 // Convert to a JSObject if needed. |
| 1126 // native_context is used when creating wrapper object. | 1126 // native_context is used when creating wrapper object. |
| 1127 MUST_USE_RESULT static inline MaybeHandle<JSReceiver> ToObject( | 1127 MUST_USE_RESULT static inline MaybeHandle<JSReceiver> ToObject( |
| 1128 Isolate* isolate, Handle<Object> object); | 1128 Isolate* isolate, Handle<Object> object); |
| 1129 MUST_USE_RESULT static MaybeHandle<JSReceiver> ToObject( | 1129 MUST_USE_RESULT static MaybeHandle<JSReceiver> ToObject( |
| 1130 Isolate* isolate, Handle<Object> object, Handle<Context> context); | 1130 Isolate* isolate, Handle<Object> object, Handle<Context> context); |
| 1131 | 1131 |
| 1132 // ES6 section 9.2.1.2, OrdinaryCallBindThis for sloppy callee. |
| 1133 MUST_USE_RESULT static MaybeHandle<JSReceiver> ConvertReceiver( |
| 1134 Isolate* isolate, Handle<Object> object); |
| 1135 |
| 1132 // ES6 section 7.1.14 ToPropertyKey | 1136 // ES6 section 7.1.14 ToPropertyKey |
| 1133 MUST_USE_RESULT static inline MaybeHandle<Name> ToName(Isolate* isolate, | 1137 MUST_USE_RESULT static inline MaybeHandle<Name> ToName(Isolate* isolate, |
| 1134 Handle<Object> input); | 1138 Handle<Object> input); |
| 1135 | 1139 |
| 1136 // ES6 section 7.1.1 ToPrimitive | 1140 // ES6 section 7.1.1 ToPrimitive |
| 1137 MUST_USE_RESULT static inline MaybeHandle<Object> ToPrimitive( | 1141 MUST_USE_RESULT static inline MaybeHandle<Object> ToPrimitive( |
| 1138 Handle<Object> input, ToPrimitiveHint hint = ToPrimitiveHint::kDefault); | 1142 Handle<Object> input, ToPrimitiveHint hint = ToPrimitiveHint::kDefault); |
| 1139 | 1143 |
| 1140 // ES6 section 7.1.3 ToNumber | 1144 // ES6 section 7.1.3 ToNumber |
| 1141 MUST_USE_RESULT static MaybeHandle<Object> ToNumber(Handle<Object> input); | 1145 MUST_USE_RESULT static MaybeHandle<Object> ToNumber(Handle<Object> input); |
| 1142 | 1146 |
| 1143 // ES6 section 7.1.4 ToInteger | 1147 // ES6 section 7.1.4 ToInteger |
| 1144 MUST_USE_RESULT static MaybeHandle<Object> ToInteger(Isolate* isolate, | 1148 MUST_USE_RESULT static MaybeHandle<Object> ToInteger(Isolate* isolate, |
| 1145 Handle<Object> input); | 1149 Handle<Object> input); |
| 1146 | 1150 |
| 1147 // ES6 section 7.1.5 ToInt32 | 1151 // ES6 section 7.1.5 ToInt32 |
| 1148 MUST_USE_RESULT static MaybeHandle<Object> ToInt32(Isolate* isolate, | 1152 MUST_USE_RESULT static MaybeHandle<Object> ToInt32(Isolate* isolate, |
| 1149 Handle<Object> input); | 1153 Handle<Object> input); |
| 1150 | 1154 |
| 1151 // ES6 section 7.1.6 ToUint32 | 1155 // ES6 section 7.1.6 ToUint32 |
| 1152 MUST_USE_RESULT static MaybeHandle<Object> ToUint32(Isolate* isolate, | 1156 MUST_USE_RESULT static MaybeHandle<Object> ToUint32(Isolate* isolate, |
| 1153 Handle<Object> input); | 1157 Handle<Object> input); |
| 1154 | 1158 |
| 1155 // ES6 section 7.1.12 ToString | 1159 // ES6 section 7.1.12 ToString |
| 1156 MUST_USE_RESULT static MaybeHandle<String> ToString(Isolate* isolate, | 1160 MUST_USE_RESULT static MaybeHandle<String> ToString(Isolate* isolate, |
| 1157 Handle<Object> input); | 1161 Handle<Object> input); |
| 1158 | 1162 |
| 1163 // ES6 section 7.1.14 ToPropertyKey |
| 1164 MUST_USE_RESULT static MaybeHandle<Object> ToPropertyKey( |
| 1165 Isolate* isolate, Handle<Object> value); |
| 1166 |
| 1159 // ES6 section 7.1.15 ToLength | 1167 // ES6 section 7.1.15 ToLength |
| 1160 MUST_USE_RESULT static MaybeHandle<Object> ToLength(Isolate* isolate, | 1168 MUST_USE_RESULT static MaybeHandle<Object> ToLength(Isolate* isolate, |
| 1161 Handle<Object> input); | 1169 Handle<Object> input); |
| 1162 | 1170 |
| 1163 // ES6 section 7.3.9 GetMethod | 1171 // ES6 section 7.3.9 GetMethod |
| 1164 MUST_USE_RESULT static MaybeHandle<Object> GetMethod( | 1172 MUST_USE_RESULT static MaybeHandle<Object> GetMethod( |
| 1165 Handle<JSReceiver> receiver, Handle<Name> name); | 1173 Handle<JSReceiver> receiver, Handle<Name> name); |
| 1166 | 1174 |
| 1167 // ES6 section 7.3.17 CreateListFromArrayLike | 1175 // ES6 section 7.3.17 CreateListFromArrayLike |
| 1168 MUST_USE_RESULT static MaybeHandle<FixedArray> CreateListFromArrayLike( | 1176 MUST_USE_RESULT static MaybeHandle<FixedArray> CreateListFromArrayLike( |
| (...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2171 // Retrieve interceptors. | 2179 // Retrieve interceptors. |
| 2172 inline InterceptorInfo* GetNamedInterceptor(); | 2180 inline InterceptorInfo* GetNamedInterceptor(); |
| 2173 inline InterceptorInfo* GetIndexedInterceptor(); | 2181 inline InterceptorInfo* GetIndexedInterceptor(); |
| 2174 | 2182 |
| 2175 // Used from JSReceiver. | 2183 // Used from JSReceiver. |
| 2176 MUST_USE_RESULT static Maybe<PropertyAttributes> | 2184 MUST_USE_RESULT static Maybe<PropertyAttributes> |
| 2177 GetPropertyAttributesWithInterceptor(LookupIterator* it); | 2185 GetPropertyAttributesWithInterceptor(LookupIterator* it); |
| 2178 MUST_USE_RESULT static Maybe<PropertyAttributes> | 2186 MUST_USE_RESULT static Maybe<PropertyAttributes> |
| 2179 GetPropertyAttributesWithFailedAccessCheck(LookupIterator* it); | 2187 GetPropertyAttributesWithFailedAccessCheck(LookupIterator* it); |
| 2180 | 2188 |
| 2181 // Retrieves an AccessorPair property from the given object. Might return | |
| 2182 // undefined if the property doesn't exist or is of a different kind. | |
| 2183 MUST_USE_RESULT static MaybeHandle<Object> GetAccessor( | |
| 2184 Handle<JSObject> object, | |
| 2185 Handle<Name> name, | |
| 2186 AccessorComponent component); | |
| 2187 | |
| 2188 // Defines an AccessorPair property on the given object. | 2189 // Defines an AccessorPair property on the given object. |
| 2189 // TODO(mstarzinger): Rename to SetAccessor(). | 2190 // TODO(mstarzinger): Rename to SetAccessor(). |
| 2190 static MaybeHandle<Object> DefineAccessor(Handle<JSObject> object, | 2191 static MaybeHandle<Object> DefineAccessor(Handle<JSObject> object, |
| 2191 Handle<Name> name, | 2192 Handle<Name> name, |
| 2192 Handle<Object> getter, | 2193 Handle<Object> getter, |
| 2193 Handle<Object> setter, | 2194 Handle<Object> setter, |
| 2194 PropertyAttributes attributes); | 2195 PropertyAttributes attributes); |
| 2195 static MaybeHandle<Object> DefineAccessor(LookupIterator* it, | 2196 static MaybeHandle<Object> DefineAccessor(LookupIterator* it, |
| 2196 Handle<Object> getter, | 2197 Handle<Object> getter, |
| 2197 Handle<Object> setter, | 2198 Handle<Object> setter, |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2291 inline int GetInternalFieldCount(); | 2292 inline int GetInternalFieldCount(); |
| 2292 inline int GetInternalFieldOffset(int index); | 2293 inline int GetInternalFieldOffset(int index); |
| 2293 inline Object* GetInternalField(int index); | 2294 inline Object* GetInternalField(int index); |
| 2294 inline void SetInternalField(int index, Object* value); | 2295 inline void SetInternalField(int index, Object* value); |
| 2295 inline void SetInternalField(int index, Smi* value); | 2296 inline void SetInternalField(int index, Smi* value); |
| 2296 bool WasConstructedFromApiFunction(); | 2297 bool WasConstructedFromApiFunction(); |
| 2297 | 2298 |
| 2298 void CollectOwnPropertyNames(KeyAccumulator* keys, | 2299 void CollectOwnPropertyNames(KeyAccumulator* keys, |
| 2299 PropertyFilter filter = ALL_PROPERTIES); | 2300 PropertyFilter filter = ALL_PROPERTIES); |
| 2300 | 2301 |
| 2301 // Returns the number of properties on this object filtering out properties | |
| 2302 // with the specified attributes (ignoring interceptors). | |
| 2303 // TODO(jkummerow): Deprecated, only used by Object.observe. | |
| 2304 int NumberOfOwnElements(PropertyFilter filter); | |
| 2305 // Returns the number of elements on this object filtering out elements | |
| 2306 // with the specified attributes (ignoring interceptors). | |
| 2307 // TODO(jkummerow): Deprecated, only used by Object.observe. | |
| 2308 int GetOwnElementKeys(FixedArray* storage, PropertyFilter filter); | |
| 2309 | |
| 2310 static void CollectOwnElementKeys(Handle<JSObject> object, | 2302 static void CollectOwnElementKeys(Handle<JSObject> object, |
| 2311 KeyAccumulator* keys, | 2303 KeyAccumulator* keys, |
| 2312 PropertyFilter filter); | 2304 PropertyFilter filter); |
| 2313 | 2305 |
| 2314 static Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object); | 2306 static Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object); |
| 2315 | 2307 |
| 2316 static Handle<FixedArray> GetFastEnumPropertyKeys(Isolate* isolate, | 2308 static Handle<FixedArray> GetFastEnumPropertyKeys(Isolate* isolate, |
| 2317 Handle<JSObject> object); | 2309 Handle<JSObject> object); |
| 2318 | 2310 |
| 2319 // Returns a new map with all transitions dropped from the object's current | 2311 // Returns a new map with all transitions dropped from the object's current |
| (...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3482 Key key) { | 3474 Key key) { |
| 3483 return DerivedHashTable::Shrink(dictionary, key); | 3475 return DerivedHashTable::Shrink(dictionary, key); |
| 3484 } | 3476 } |
| 3485 | 3477 |
| 3486 // Sorting support | 3478 // Sorting support |
| 3487 // TODO(dcarney): templatize or move to SeededNumberDictionary | 3479 // TODO(dcarney): templatize or move to SeededNumberDictionary |
| 3488 void CopyValuesTo(FixedArray* elements); | 3480 void CopyValuesTo(FixedArray* elements); |
| 3489 | 3481 |
| 3490 // Returns the number of elements in the dictionary filtering out properties | 3482 // Returns the number of elements in the dictionary filtering out properties |
| 3491 // with the specified attributes. | 3483 // with the specified attributes. |
| 3492 // TODO(jkummerow): Deprecated, only used by Object.observe. | |
| 3493 int NumberOfElementsFilterAttributes(PropertyFilter filter); | 3484 int NumberOfElementsFilterAttributes(PropertyFilter filter); |
| 3494 | 3485 |
| 3495 // Returns the number of enumerable elements in the dictionary. | 3486 // Returns the number of enumerable elements in the dictionary. |
| 3496 // TODO(jkummerow): Deprecated, only used by Object.observe. | |
| 3497 int NumberOfEnumElements() { | 3487 int NumberOfEnumElements() { |
| 3498 return NumberOfElementsFilterAttributes(ENUMERABLE_STRINGS); | 3488 return NumberOfElementsFilterAttributes(ENUMERABLE_STRINGS); |
| 3499 } | 3489 } |
| 3500 | 3490 |
| 3501 enum SortMode { UNSORTED, SORTED }; | 3491 enum SortMode { UNSORTED, SORTED }; |
| 3502 | 3492 |
| 3503 // Fill in details for properties into storage. | |
| 3504 // Returns the number of properties added. | |
| 3505 // TODO(jkummerow): Deprecated, only used by Object.observe. | |
| 3506 int CopyKeysTo(FixedArray* storage, int index, PropertyFilter filter, | |
| 3507 SortMode sort_mode); | |
| 3508 // Collect the keys into the given KeyAccumulator, in ascending chronological | 3493 // Collect the keys into the given KeyAccumulator, in ascending chronological |
| 3509 // order of property creation. | 3494 // order of property creation. |
| 3510 static void CollectKeysTo(Handle<Dictionary<Derived, Shape, Key> > dictionary, | 3495 static void CollectKeysTo(Handle<Dictionary<Derived, Shape, Key> > dictionary, |
| 3511 KeyAccumulator* keys, PropertyFilter filter); | 3496 KeyAccumulator* keys, PropertyFilter filter); |
| 3512 | 3497 |
| 3513 // Copies enumerable keys to preallocated fixed array. | 3498 // Copies enumerable keys to preallocated fixed array. |
| 3514 void CopyEnumKeysTo(FixedArray* storage); | 3499 void CopyEnumKeysTo(FixedArray* storage); |
| 3515 | 3500 |
| 3516 // Accessors for next enumeration index. | 3501 // Accessors for next enumeration index. |
| 3517 void SetNextEnumerationIndex(int index) { | 3502 void SetNextEnumerationIndex(int index) { |
| (...skipping 7272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10790 } | 10775 } |
| 10791 return value; | 10776 return value; |
| 10792 } | 10777 } |
| 10793 }; | 10778 }; |
| 10794 | 10779 |
| 10795 | 10780 |
| 10796 } // NOLINT, false-positive due to second-order macros. | 10781 } // NOLINT, false-positive due to second-order macros. |
| 10797 } // NOLINT, false-positive due to second-order macros. | 10782 } // NOLINT, false-positive due to second-order macros. |
| 10798 | 10783 |
| 10799 #endif // V8_OBJECTS_H_ | 10784 #endif // V8_OBJECTS_H_ |
| OLD | NEW |