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