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