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 1103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1114 | 1114 |
1115 // Converts this to a Smi if possible. | 1115 // Converts this to a Smi if possible. |
1116 static MUST_USE_RESULT inline MaybeHandle<Smi> ToSmi(Isolate* isolate, | 1116 static MUST_USE_RESULT inline MaybeHandle<Smi> ToSmi(Isolate* isolate, |
1117 Handle<Object> object); | 1117 Handle<Object> object); |
1118 | 1118 |
1119 MUST_USE_RESULT static MaybeHandle<Object> GetProperty(LookupIterator* it); | 1119 MUST_USE_RESULT static MaybeHandle<Object> GetProperty(LookupIterator* it); |
1120 | 1120 |
1121 // Implementation of [[Put]], ECMA-262 5th edition, section 8.12.5. | 1121 // Implementation of [[Put]], ECMA-262 5th edition, section 8.12.5. |
1122 MUST_USE_RESULT static MaybeHandle<Object> SetProperty( | 1122 MUST_USE_RESULT static MaybeHandle<Object> SetProperty( |
1123 Handle<Object> object, Handle<Name> key, Handle<Object> value, | 1123 Handle<Object> object, Handle<Name> key, Handle<Object> value, |
1124 StrictMode strict_mode, | 1124 LanguageMode language_mode, |
1125 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED); | 1125 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED); |
1126 | 1126 |
1127 MUST_USE_RESULT static MaybeHandle<Object> SetProperty( | 1127 MUST_USE_RESULT static MaybeHandle<Object> SetProperty( |
1128 LookupIterator* it, Handle<Object> value, StrictMode strict_mode, | 1128 LookupIterator* it, Handle<Object> value, LanguageMode language_mode, |
1129 StoreFromKeyed store_mode, | 1129 StoreFromKeyed store_mode, |
1130 StorePropertyMode data_store_mode = NORMAL_PROPERTY); | 1130 StorePropertyMode data_store_mode = NORMAL_PROPERTY); |
1131 MUST_USE_RESULT static MaybeHandle<Object> WriteToReadOnlyProperty( | 1131 MUST_USE_RESULT static MaybeHandle<Object> WriteToReadOnlyProperty( |
1132 LookupIterator* it, Handle<Object> value, StrictMode strict_mode); | 1132 LookupIterator* it, Handle<Object> value, LanguageMode language_mode); |
1133 MUST_USE_RESULT static MaybeHandle<Object> WriteToReadOnlyElement( | 1133 MUST_USE_RESULT static MaybeHandle<Object> WriteToReadOnlyElement( |
1134 Isolate* isolate, Handle<Object> receiver, uint32_t index, | 1134 Isolate* isolate, Handle<Object> receiver, uint32_t index, |
1135 Handle<Object> value, StrictMode strict_mode); | 1135 Handle<Object> value, LanguageMode language_mode); |
1136 MUST_USE_RESULT static MaybeHandle<Object> SetDataProperty( | 1136 MUST_USE_RESULT static MaybeHandle<Object> SetDataProperty( |
1137 LookupIterator* it, Handle<Object> value); | 1137 LookupIterator* it, Handle<Object> value); |
1138 MUST_USE_RESULT static MaybeHandle<Object> AddDataProperty( | 1138 MUST_USE_RESULT static MaybeHandle<Object> AddDataProperty( |
1139 LookupIterator* it, Handle<Object> value, PropertyAttributes attributes, | 1139 LookupIterator* it, Handle<Object> value, PropertyAttributes attributes, |
1140 StrictMode strict_mode, StoreFromKeyed store_mode); | 1140 LanguageMode language_mode, StoreFromKeyed store_mode); |
1141 MUST_USE_RESULT static inline MaybeHandle<Object> GetPropertyOrElement( | 1141 MUST_USE_RESULT static inline MaybeHandle<Object> GetPropertyOrElement( |
1142 Handle<Object> object, | 1142 Handle<Object> object, |
1143 Handle<Name> key); | 1143 Handle<Name> key); |
1144 MUST_USE_RESULT static inline MaybeHandle<Object> GetProperty( | 1144 MUST_USE_RESULT static inline MaybeHandle<Object> GetProperty( |
1145 Isolate* isolate, | 1145 Isolate* isolate, |
1146 Handle<Object> object, | 1146 Handle<Object> object, |
1147 const char* key); | 1147 const char* key); |
1148 MUST_USE_RESULT static inline MaybeHandle<Object> GetProperty( | 1148 MUST_USE_RESULT static inline MaybeHandle<Object> GetProperty( |
1149 Handle<Object> object, | 1149 Handle<Object> object, |
1150 Handle<Name> key); | 1150 Handle<Name> key); |
1151 | 1151 |
1152 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithAccessor( | 1152 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithAccessor( |
1153 Handle<Object> receiver, | 1153 Handle<Object> receiver, |
1154 Handle<Name> name, | 1154 Handle<Name> name, |
1155 Handle<JSObject> holder, | 1155 Handle<JSObject> holder, |
1156 Handle<Object> structure); | 1156 Handle<Object> structure); |
1157 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithAccessor( | 1157 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithAccessor( |
1158 Handle<Object> receiver, Handle<Name> name, Handle<Object> value, | 1158 Handle<Object> receiver, Handle<Name> name, Handle<Object> value, |
1159 Handle<JSObject> holder, Handle<Object> structure, | 1159 Handle<JSObject> holder, Handle<Object> structure, |
1160 StrictMode strict_mode); | 1160 LanguageMode language_mode); |
1161 | 1161 |
1162 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithDefinedGetter( | 1162 MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithDefinedGetter( |
1163 Handle<Object> receiver, | 1163 Handle<Object> receiver, |
1164 Handle<JSReceiver> getter); | 1164 Handle<JSReceiver> getter); |
1165 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithDefinedSetter( | 1165 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithDefinedSetter( |
1166 Handle<Object> receiver, | 1166 Handle<Object> receiver, |
1167 Handle<JSReceiver> setter, | 1167 Handle<JSReceiver> setter, |
1168 Handle<Object> value); | 1168 Handle<Object> value); |
1169 | 1169 |
1170 MUST_USE_RESULT static inline MaybeHandle<Object> GetElement( | 1170 MUST_USE_RESULT static inline MaybeHandle<Object> GetElement( |
1171 Isolate* isolate, | 1171 Isolate* isolate, |
1172 Handle<Object> object, | 1172 Handle<Object> object, |
1173 uint32_t index); | 1173 uint32_t index); |
1174 | 1174 |
1175 MUST_USE_RESULT static MaybeHandle<Object> GetElementWithReceiver( | 1175 MUST_USE_RESULT static MaybeHandle<Object> GetElementWithReceiver( |
1176 Isolate* isolate, | 1176 Isolate* isolate, |
1177 Handle<Object> object, | 1177 Handle<Object> object, |
1178 Handle<Object> receiver, | 1178 Handle<Object> receiver, |
1179 uint32_t index); | 1179 uint32_t index); |
1180 | 1180 |
1181 MUST_USE_RESULT static MaybeHandle<Object> SetElementWithReceiver( | 1181 MUST_USE_RESULT static MaybeHandle<Object> SetElementWithReceiver( |
1182 Isolate* isolate, Handle<Object> object, Handle<Object> receiver, | 1182 Isolate* isolate, Handle<Object> object, Handle<Object> receiver, |
1183 uint32_t index, Handle<Object> value, StrictMode strict_mode); | 1183 uint32_t index, Handle<Object> value, LanguageMode language_mode); |
1184 | 1184 |
1185 static inline Handle<Object> GetPrototypeSkipHiddenPrototypes( | 1185 static inline Handle<Object> GetPrototypeSkipHiddenPrototypes( |
1186 Isolate* isolate, Handle<Object> receiver); | 1186 Isolate* isolate, Handle<Object> receiver); |
1187 | 1187 |
1188 // Returns the permanent hash code associated with this object. May return | 1188 // Returns the permanent hash code associated with this object. May return |
1189 // undefined if not yet created. | 1189 // undefined if not yet created. |
1190 Object* GetHash(); | 1190 Object* GetHash(); |
1191 | 1191 |
1192 // Returns the permanent hash code associated with this object depending on | 1192 // Returns the permanent hash code associated with this object depending on |
1193 // the actual object type. May create and store a hash code if needed and none | 1193 // the actual object type. May create and store a hash code if needed and none |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1585 }; | 1585 }; |
1586 | 1586 |
1587 | 1587 |
1588 // JSReceiver includes types on which properties can be defined, i.e., | 1588 // JSReceiver includes types on which properties can be defined, i.e., |
1589 // JSObject and JSProxy. | 1589 // JSObject and JSProxy. |
1590 class JSReceiver: public HeapObject { | 1590 class JSReceiver: public HeapObject { |
1591 public: | 1591 public: |
1592 DECLARE_CAST(JSReceiver) | 1592 DECLARE_CAST(JSReceiver) |
1593 | 1593 |
1594 MUST_USE_RESULT static MaybeHandle<Object> SetElement( | 1594 MUST_USE_RESULT static MaybeHandle<Object> SetElement( |
1595 Handle<JSReceiver> object, | 1595 Handle<JSReceiver> object, uint32_t index, Handle<Object> value, |
1596 uint32_t index, | 1596 PropertyAttributes attributes, LanguageMode language_mode); |
1597 Handle<Object> value, | |
1598 PropertyAttributes attributes, | |
1599 StrictMode strict_mode); | |
1600 | 1597 |
1601 // Implementation of [[HasProperty]], ECMA-262 5th edition, section 8.12.6. | 1598 // Implementation of [[HasProperty]], ECMA-262 5th edition, section 8.12.6. |
1602 MUST_USE_RESULT static inline Maybe<bool> HasProperty( | 1599 MUST_USE_RESULT static inline Maybe<bool> HasProperty( |
1603 Handle<JSReceiver> object, Handle<Name> name); | 1600 Handle<JSReceiver> object, Handle<Name> name); |
1604 MUST_USE_RESULT static inline Maybe<bool> HasOwnProperty(Handle<JSReceiver>, | 1601 MUST_USE_RESULT static inline Maybe<bool> HasOwnProperty(Handle<JSReceiver>, |
1605 Handle<Name> name); | 1602 Handle<Name> name); |
1606 MUST_USE_RESULT static inline Maybe<bool> HasElement( | 1603 MUST_USE_RESULT static inline Maybe<bool> HasElement( |
1607 Handle<JSReceiver> object, uint32_t index); | 1604 Handle<JSReceiver> object, uint32_t index); |
1608 MUST_USE_RESULT static inline Maybe<bool> HasOwnElement( | 1605 MUST_USE_RESULT static inline Maybe<bool> HasOwnElement( |
1609 Handle<JSReceiver> object, uint32_t index); | 1606 Handle<JSReceiver> object, uint32_t index); |
1610 | 1607 |
1611 // Implementation of [[Delete]], ECMA-262 5th edition, section 8.12.7. | 1608 // Implementation of [[Delete]], ECMA-262 5th edition, section 8.12.7. |
1612 MUST_USE_RESULT static MaybeHandle<Object> DeleteProperty( | 1609 MUST_USE_RESULT static MaybeHandle<Object> DeleteProperty( |
1613 Handle<JSReceiver> object, Handle<Name> name, | 1610 Handle<JSReceiver> object, Handle<Name> name, |
1614 StrictMode strict_mode = SLOPPY); | 1611 LanguageMode language_mode = SLOPPY); |
1615 MUST_USE_RESULT static MaybeHandle<Object> DeleteElement( | 1612 MUST_USE_RESULT static MaybeHandle<Object> DeleteElement( |
1616 Handle<JSReceiver> object, uint32_t index, | 1613 Handle<JSReceiver> object, uint32_t index, |
1617 StrictMode strict_mode = SLOPPY); | 1614 LanguageMode language_mode = SLOPPY); |
1618 | 1615 |
1619 // Tests for the fast common case for property enumeration. | 1616 // Tests for the fast common case for property enumeration. |
1620 bool IsSimpleEnum(); | 1617 bool IsSimpleEnum(); |
1621 | 1618 |
1622 // Returns the class name ([[Class]] property in the specification). | 1619 // Returns the class name ([[Class]] property in the specification). |
1623 String* class_name(); | 1620 String* class_name(); |
1624 | 1621 |
1625 // Returns the constructor name (the name (possibly, inferred name) of the | 1622 // Returns the constructor name (the name (possibly, inferred name) of the |
1626 // function that was used to instantiate the object). | 1623 // function that was used to instantiate the object). |
1627 String* constructor_name(); | 1624 String* constructor_name(); |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1925 static int NewElementsCapacity(int old_capacity) { | 1922 static int NewElementsCapacity(int old_capacity) { |
1926 // (old_capacity + 50%) + 16 | 1923 // (old_capacity + 50%) + 16 |
1927 return old_capacity + (old_capacity >> 1) + 16; | 1924 return old_capacity + (old_capacity >> 1) + 16; |
1928 } | 1925 } |
1929 | 1926 |
1930 // These methods do not perform access checks! | 1927 // These methods do not perform access checks! |
1931 MUST_USE_RESULT static MaybeHandle<AccessorPair> GetOwnElementAccessorPair( | 1928 MUST_USE_RESULT static MaybeHandle<AccessorPair> GetOwnElementAccessorPair( |
1932 Handle<JSObject> object, uint32_t index); | 1929 Handle<JSObject> object, uint32_t index); |
1933 | 1930 |
1934 MUST_USE_RESULT static MaybeHandle<Object> SetFastElement( | 1931 MUST_USE_RESULT static MaybeHandle<Object> SetFastElement( |
1935 Handle<JSObject> object, | 1932 Handle<JSObject> object, uint32_t index, Handle<Object> value, |
1936 uint32_t index, | 1933 LanguageMode language_mode, bool check_prototype); |
1937 Handle<Object> value, | |
1938 StrictMode strict_mode, | |
1939 bool check_prototype); | |
1940 | 1934 |
1941 MUST_USE_RESULT static MaybeHandle<Object> SetOwnElement( | 1935 MUST_USE_RESULT static MaybeHandle<Object> SetOwnElement( |
1942 Handle<JSObject> object, | 1936 Handle<JSObject> object, uint32_t index, Handle<Object> value, |
1943 uint32_t index, | 1937 LanguageMode language_mode); |
1944 Handle<Object> value, | |
1945 StrictMode strict_mode); | |
1946 | 1938 |
1947 // Empty handle is returned if the element cannot be set to the given value. | 1939 // Empty handle is returned if the element cannot be set to the given value. |
1948 MUST_USE_RESULT static MaybeHandle<Object> SetElement( | 1940 MUST_USE_RESULT static MaybeHandle<Object> SetElement( |
1949 Handle<JSObject> object, | 1941 Handle<JSObject> object, uint32_t index, Handle<Object> value, |
1950 uint32_t index, | 1942 PropertyAttributes attributes, LanguageMode language_mode, |
1951 Handle<Object> value, | 1943 bool check_prototype = true, SetPropertyMode set_mode = SET_PROPERTY); |
1952 PropertyAttributes attributes, | |
1953 StrictMode strict_mode, | |
1954 bool check_prototype = true, | |
1955 SetPropertyMode set_mode = SET_PROPERTY); | |
1956 | 1944 |
1957 // Returns the index'th element. | 1945 // Returns the index'th element. |
1958 // The undefined object if index is out of bounds. | 1946 // The undefined object if index is out of bounds. |
1959 MUST_USE_RESULT static MaybeHandle<Object> GetElementWithInterceptor( | 1947 MUST_USE_RESULT static MaybeHandle<Object> GetElementWithInterceptor( |
1960 Handle<JSObject> object, | 1948 Handle<JSObject> object, |
1961 Handle<Object> receiver, | 1949 Handle<Object> receiver, |
1962 uint32_t index); | 1950 uint32_t index); |
1963 | 1951 |
1964 enum SetFastElementsCapacitySmiMode { | 1952 enum SetFastElementsCapacitySmiMode { |
1965 kAllowSmiElements, | 1953 kAllowSmiElements, |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2277 Handle<Object> receiver, | 2265 Handle<Object> receiver, |
2278 uint32_t index); | 2266 uint32_t index); |
2279 | 2267 |
2280 MUST_USE_RESULT static Maybe<PropertyAttributes> | 2268 MUST_USE_RESULT static Maybe<PropertyAttributes> |
2281 GetElementAttributeWithoutInterceptor(Handle<JSObject> object, | 2269 GetElementAttributeWithoutInterceptor(Handle<JSObject> object, |
2282 Handle<JSReceiver> receiver, | 2270 Handle<JSReceiver> receiver, |
2283 uint32_t index, | 2271 uint32_t index, |
2284 bool continue_search); | 2272 bool continue_search); |
2285 MUST_USE_RESULT static MaybeHandle<Object> SetElementWithCallback( | 2273 MUST_USE_RESULT static MaybeHandle<Object> SetElementWithCallback( |
2286 Handle<Object> object, Handle<Object> structure, uint32_t index, | 2274 Handle<Object> object, Handle<Object> structure, uint32_t index, |
2287 Handle<Object> value, Handle<JSObject> holder, StrictMode strict_mode); | 2275 Handle<Object> value, Handle<JSObject> holder, |
| 2276 LanguageMode language_mode); |
2288 MUST_USE_RESULT static MaybeHandle<Object> SetElementWithInterceptor( | 2277 MUST_USE_RESULT static MaybeHandle<Object> SetElementWithInterceptor( |
2289 Handle<JSObject> object, | 2278 Handle<JSObject> object, uint32_t index, Handle<Object> value, |
2290 uint32_t index, | 2279 PropertyAttributes attributes, LanguageMode language_mode, |
2291 Handle<Object> value, | 2280 bool check_prototype, SetPropertyMode set_mode); |
2292 PropertyAttributes attributes, | |
2293 StrictMode strict_mode, | |
2294 bool check_prototype, | |
2295 SetPropertyMode set_mode); | |
2296 MUST_USE_RESULT static MaybeHandle<Object> SetElementWithoutInterceptor( | 2281 MUST_USE_RESULT static MaybeHandle<Object> SetElementWithoutInterceptor( |
2297 Handle<JSObject> object, | 2282 Handle<JSObject> object, uint32_t index, Handle<Object> value, |
2298 uint32_t index, | 2283 PropertyAttributes attributes, LanguageMode language_mode, |
2299 Handle<Object> value, | 2284 bool check_prototype, SetPropertyMode set_mode); |
2300 PropertyAttributes attributes, | |
2301 StrictMode strict_mode, | |
2302 bool check_prototype, | |
2303 SetPropertyMode set_mode); | |
2304 MUST_USE_RESULT | 2285 MUST_USE_RESULT |
2305 static MaybeHandle<Object> SetElementWithCallbackSetterInPrototypes( | 2286 static MaybeHandle<Object> SetElementWithCallbackSetterInPrototypes( |
2306 Handle<JSObject> object, | 2287 Handle<JSObject> object, uint32_t index, Handle<Object> value, |
2307 uint32_t index, | 2288 bool* found, LanguageMode language_mode); |
2308 Handle<Object> value, | |
2309 bool* found, | |
2310 StrictMode strict_mode); | |
2311 MUST_USE_RESULT static MaybeHandle<Object> SetDictionaryElement( | 2289 MUST_USE_RESULT static MaybeHandle<Object> SetDictionaryElement( |
2312 Handle<JSObject> object, | 2290 Handle<JSObject> object, uint32_t index, Handle<Object> value, |
2313 uint32_t index, | 2291 PropertyAttributes attributes, LanguageMode language_mode, |
2314 Handle<Object> value, | 2292 bool check_prototype, SetPropertyMode set_mode = SET_PROPERTY); |
2315 PropertyAttributes attributes, | |
2316 StrictMode strict_mode, | |
2317 bool check_prototype, | |
2318 SetPropertyMode set_mode = SET_PROPERTY); | |
2319 MUST_USE_RESULT static MaybeHandle<Object> SetFastDoubleElement( | 2293 MUST_USE_RESULT static MaybeHandle<Object> SetFastDoubleElement( |
2320 Handle<JSObject> object, | 2294 Handle<JSObject> object, uint32_t index, Handle<Object> value, |
2321 uint32_t index, | 2295 LanguageMode language_mode, bool check_prototype = true); |
2322 Handle<Object> value, | |
2323 StrictMode strict_mode, | |
2324 bool check_prototype = true); | |
2325 | 2296 |
2326 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithFailedAccessCheck( | 2297 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithFailedAccessCheck( |
2327 LookupIterator* it, Handle<Object> value, StrictMode strict_mode); | 2298 LookupIterator* it, Handle<Object> value, LanguageMode language_mode); |
2328 | 2299 |
2329 // Add a property to a slow-case object. | 2300 // Add a property to a slow-case object. |
2330 static void AddSlowProperty(Handle<JSObject> object, | 2301 static void AddSlowProperty(Handle<JSObject> object, |
2331 Handle<Name> name, | 2302 Handle<Name> name, |
2332 Handle<Object> value, | 2303 Handle<Object> value, |
2333 PropertyAttributes attributes); | 2304 PropertyAttributes attributes); |
2334 | 2305 |
2335 MUST_USE_RESULT static MaybeHandle<Object> DeleteProperty( | 2306 MUST_USE_RESULT static MaybeHandle<Object> DeleteProperty( |
2336 Handle<JSObject> object, Handle<Name> name, StrictMode strict_mode); | 2307 Handle<JSObject> object, Handle<Name> name, LanguageMode language_mode); |
2337 MUST_USE_RESULT static MaybeHandle<Object> DeletePropertyWithInterceptor( | 2308 MUST_USE_RESULT static MaybeHandle<Object> DeletePropertyWithInterceptor( |
2338 Handle<JSObject> holder, Handle<JSObject> receiver, Handle<Name> name); | 2309 Handle<JSObject> holder, Handle<JSObject> receiver, Handle<Name> name); |
2339 | 2310 |
2340 // Deletes an existing named property in a normalized object. | 2311 // Deletes an existing named property in a normalized object. |
2341 static void DeleteNormalizedProperty(Handle<JSObject> object, | 2312 static void DeleteNormalizedProperty(Handle<JSObject> object, |
2342 Handle<Name> name); | 2313 Handle<Name> name); |
2343 | 2314 |
2344 MUST_USE_RESULT static MaybeHandle<Object> DeleteElement( | 2315 MUST_USE_RESULT static MaybeHandle<Object> DeleteElement( |
2345 Handle<JSObject> object, uint32_t index, StrictMode strict_mode); | 2316 Handle<JSObject> object, uint32_t index, LanguageMode language_mode); |
2346 MUST_USE_RESULT static MaybeHandle<Object> DeleteElementWithInterceptor( | 2317 MUST_USE_RESULT static MaybeHandle<Object> DeleteElementWithInterceptor( |
2347 Handle<JSObject> object, | 2318 Handle<JSObject> object, |
2348 uint32_t index); | 2319 uint32_t index); |
2349 | 2320 |
2350 bool ReferencesObjectFromElements(FixedArray* elements, | 2321 bool ReferencesObjectFromElements(FixedArray* elements, |
2351 ElementsKind kind, | 2322 ElementsKind kind, |
2352 Object* object); | 2323 Object* object); |
2353 | 2324 |
2354 // Returns true if most of the elements backing storage is used. | 2325 // Returns true if most of the elements backing storage is used. |
2355 bool HasDenseElements(); | 2326 bool HasDenseElements(); |
(...skipping 1796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4152 class ScopeInfo : public FixedArray { | 4123 class ScopeInfo : public FixedArray { |
4153 public: | 4124 public: |
4154 DECLARE_CAST(ScopeInfo) | 4125 DECLARE_CAST(ScopeInfo) |
4155 | 4126 |
4156 // Return the type of this scope. | 4127 // Return the type of this scope. |
4157 ScopeType scope_type(); | 4128 ScopeType scope_type(); |
4158 | 4129 |
4159 // Does this scope call eval? | 4130 // Does this scope call eval? |
4160 bool CallsEval(); | 4131 bool CallsEval(); |
4161 | 4132 |
4162 // Return the strict mode of this scope. | 4133 // Return the language mode of this scope. |
4163 StrictMode strict_mode(); | 4134 LanguageMode language_mode(); |
4164 | 4135 |
4165 // Does this scope make a sloppy eval call? | 4136 // Does this scope make a sloppy eval call? |
4166 bool CallsSloppyEval() { return CallsEval() && strict_mode() == SLOPPY; } | 4137 bool CallsSloppyEval() { return CallsEval() && !is_strict(language_mode()); } |
4167 | 4138 |
4168 // Return the total number of locals allocated on the stack and in the | 4139 // Return the total number of locals allocated on the stack and in the |
4169 // context. This includes the parameters that are allocated in the context. | 4140 // context. This includes the parameters that are allocated in the context. |
4170 int LocalCount(); | 4141 int LocalCount(); |
4171 | 4142 |
4172 // Return the number of stack slots for code. This number consists of two | 4143 // Return the number of stack slots for code. This number consists of two |
4173 // parts: | 4144 // parts: |
4174 // 1. One stack slot per stack allocated local. | 4145 // 1. One stack slot per stack allocated local. |
4175 // 2. One stack slot for the function name if it is stack allocated. | 4146 // 2. One stack slot for the function name if it is stack allocated. |
4176 int StackSlotCount(); | 4147 int StackSlotCount(); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4343 enum FunctionVariableInfo { | 4314 enum FunctionVariableInfo { |
4344 NONE, // No function name present. | 4315 NONE, // No function name present. |
4345 STACK, // Function | 4316 STACK, // Function |
4346 CONTEXT, | 4317 CONTEXT, |
4347 UNUSED | 4318 UNUSED |
4348 }; | 4319 }; |
4349 | 4320 |
4350 // Properties of scopes. | 4321 // Properties of scopes. |
4351 class ScopeTypeField : public BitField<ScopeType, 0, 4> {}; | 4322 class ScopeTypeField : public BitField<ScopeType, 0, 4> {}; |
4352 class CallsEvalField : public BitField<bool, 4, 1> {}; | 4323 class CallsEvalField : public BitField<bool, 4, 1> {}; |
4353 class StrictModeField : public BitField<StrictMode, 5, 1> {}; | 4324 STATIC_ASSERT(LANGUAGE_END == 2); |
| 4325 class LanguageModeField : public BitField<LanguageMode, 5, 1> {}; |
4354 class FunctionVariableField : public BitField<FunctionVariableInfo, 6, 2> {}; | 4326 class FunctionVariableField : public BitField<FunctionVariableInfo, 6, 2> {}; |
4355 class FunctionVariableMode : public BitField<VariableMode, 8, 3> {}; | 4327 class FunctionVariableMode : public BitField<VariableMode, 8, 3> {}; |
4356 class AsmModuleField : public BitField<bool, 11, 1> {}; | 4328 class AsmModuleField : public BitField<bool, 11, 1> {}; |
4357 class AsmFunctionField : public BitField<bool, 12, 1> {}; | 4329 class AsmFunctionField : public BitField<bool, 12, 1> {}; |
4358 | 4330 |
4359 // BitFields representing the encoded information for context locals in the | 4331 // BitFields representing the encoded information for context locals in the |
4360 // ContextLocalInfoEntries part. | 4332 // ContextLocalInfoEntries part. |
4361 class ContextLocalMode: public BitField<VariableMode, 0, 3> {}; | 4333 class ContextLocalMode: public BitField<VariableMode, 0, 3> {}; |
4362 class ContextLocalInitFlag: public BitField<InitializationFlag, 3, 1> {}; | 4334 class ContextLocalInitFlag: public BitField<InitializationFlag, 3, 1> {}; |
4363 class ContextLocalMaybeAssignedFlag | 4335 class ContextLocalMaybeAssignedFlag |
(...skipping 2536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6900 // iteration by the debugger). | 6872 // iteration by the debugger). |
6901 DECL_BOOLEAN_ACCESSORS(allows_lazy_compilation_without_context) | 6873 DECL_BOOLEAN_ACCESSORS(allows_lazy_compilation_without_context) |
6902 | 6874 |
6903 // Indicates whether optimizations have been disabled for this | 6875 // Indicates whether optimizations have been disabled for this |
6904 // shared function info. If a function is repeatedly optimized or if | 6876 // shared function info. If a function is repeatedly optimized or if |
6905 // we cannot optimize the function we disable optimization to avoid | 6877 // we cannot optimize the function we disable optimization to avoid |
6906 // spending time attempting to optimize it again. | 6878 // spending time attempting to optimize it again. |
6907 DECL_BOOLEAN_ACCESSORS(optimization_disabled) | 6879 DECL_BOOLEAN_ACCESSORS(optimization_disabled) |
6908 | 6880 |
6909 // Indicates the language mode. | 6881 // Indicates the language mode. |
6910 inline StrictMode strict_mode(); | 6882 inline LanguageMode language_mode(); |
6911 inline void set_strict_mode(StrictMode strict_mode); | 6883 inline void set_language_mode(LanguageMode language_mode); |
6912 | 6884 |
6913 // False if the function definitely does not allocate an arguments object. | 6885 // False if the function definitely does not allocate an arguments object. |
6914 DECL_BOOLEAN_ACCESSORS(uses_arguments) | 6886 DECL_BOOLEAN_ACCESSORS(uses_arguments) |
6915 | 6887 |
6916 // Indicates that this function uses a super property. | 6888 // Indicates that this function uses a super property. |
6917 // This is needed to set up the [[HomeObject]] on the function instance. | 6889 // This is needed to set up the [[HomeObject]] on the function instance. |
6918 DECL_BOOLEAN_ACCESSORS(uses_super_property) | 6890 DECL_BOOLEAN_ACCESSORS(uses_super_property) |
6919 | 6891 |
6920 // Indicates that this function uses the super constructor. | 6892 // Indicates that this function uses the super constructor. |
6921 DECL_BOOLEAN_ACCESSORS(uses_super_constructor_call) | 6893 DECL_BOOLEAN_ACCESSORS(uses_super_constructor_call) |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7209 kDontCache, | 7181 kDontCache, |
7210 kDontFlush, | 7182 kDontFlush, |
7211 kIsArrow, | 7183 kIsArrow, |
7212 kIsGenerator, | 7184 kIsGenerator, |
7213 kIsConciseMethod, | 7185 kIsConciseMethod, |
7214 kIsDefaultConstructor, | 7186 kIsDefaultConstructor, |
7215 kIsAsmFunction, | 7187 kIsAsmFunction, |
7216 kDeserialized, | 7188 kDeserialized, |
7217 kCompilerHintsCount // Pseudo entry | 7189 kCompilerHintsCount // Pseudo entry |
7218 }; | 7190 }; |
| 7191 // Add hints for other modes when they're added. |
| 7192 STATIC_ASSERT(LANGUAGE_END == 2); |
7219 | 7193 |
7220 class FunctionKindBits : public BitField<FunctionKind, kIsArrow, 4> {}; | 7194 class FunctionKindBits : public BitField<FunctionKind, kIsArrow, 4> {}; |
7221 | 7195 |
7222 class DeoptCountBits : public BitField<int, 0, 4> {}; | 7196 class DeoptCountBits : public BitField<int, 0, 4> {}; |
7223 class OptReenableTriesBits : public BitField<int, 4, 18> {}; | 7197 class OptReenableTriesBits : public BitField<int, 4, 18> {}; |
7224 class ICAgeBits : public BitField<int, 22, 8> {}; | 7198 class ICAgeBits : public BitField<int, 22, 8> {}; |
7225 | 7199 |
7226 class OptCountBits : public BitField<int, 0, 22> {}; | 7200 class OptCountBits : public BitField<int, 0, 22> {}; |
7227 class DisabledOptimizationReasonBits : public BitField<int, 22, 8> {}; | 7201 class DisabledOptimizationReasonBits : public BitField<int, 22, 8> {}; |
7228 | 7202 |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8068 // recompilation stub, or to "old" code. This avoids memory leaks due to | 8042 // recompilation stub, or to "old" code. This avoids memory leaks due to |
8069 // premature caching of scripts and eval strings that are never needed later. | 8043 // premature caching of scripts and eval strings that are never needed later. |
8070 class CompilationCacheTable: public HashTable<CompilationCacheTable, | 8044 class CompilationCacheTable: public HashTable<CompilationCacheTable, |
8071 CompilationCacheShape, | 8045 CompilationCacheShape, |
8072 HashTableKey*> { | 8046 HashTableKey*> { |
8073 public: | 8047 public: |
8074 // Find cached value for a string key, otherwise return null. | 8048 // Find cached value for a string key, otherwise return null. |
8075 Handle<Object> Lookup(Handle<String> src, Handle<Context> context); | 8049 Handle<Object> Lookup(Handle<String> src, Handle<Context> context); |
8076 Handle<Object> LookupEval(Handle<String> src, | 8050 Handle<Object> LookupEval(Handle<String> src, |
8077 Handle<SharedFunctionInfo> shared, | 8051 Handle<SharedFunctionInfo> shared, |
8078 StrictMode strict_mode, int scope_position); | 8052 LanguageMode language_mode, int scope_position); |
8079 Handle<Object> LookupRegExp(Handle<String> source, JSRegExp::Flags flags); | 8053 Handle<Object> LookupRegExp(Handle<String> source, JSRegExp::Flags flags); |
8080 static Handle<CompilationCacheTable> Put( | 8054 static Handle<CompilationCacheTable> Put( |
8081 Handle<CompilationCacheTable> cache, Handle<String> src, | 8055 Handle<CompilationCacheTable> cache, Handle<String> src, |
8082 Handle<Context> context, Handle<Object> value); | 8056 Handle<Context> context, Handle<Object> value); |
8083 static Handle<CompilationCacheTable> PutEval( | 8057 static Handle<CompilationCacheTable> PutEval( |
8084 Handle<CompilationCacheTable> cache, Handle<String> src, | 8058 Handle<CompilationCacheTable> cache, Handle<String> src, |
8085 Handle<SharedFunctionInfo> context, Handle<SharedFunctionInfo> value, | 8059 Handle<SharedFunctionInfo> context, Handle<SharedFunctionInfo> value, |
8086 int scope_position); | 8060 int scope_position); |
8087 static Handle<CompilationCacheTable> PutRegExp( | 8061 static Handle<CompilationCacheTable> PutRegExp( |
8088 Handle<CompilationCacheTable> cache, Handle<String> src, | 8062 Handle<CompilationCacheTable> cache, Handle<String> src, |
(...skipping 1718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9807 Handle<Object> receiver, | 9781 Handle<Object> receiver, |
9808 uint32_t index); | 9782 uint32_t index); |
9809 | 9783 |
9810 // If the handler defines an accessor property with a setter, invoke it. | 9784 // If the handler defines an accessor property with a setter, invoke it. |
9811 // If it defines an accessor property without a setter, or a data property | 9785 // If it defines an accessor property without a setter, or a data property |
9812 // that is read-only, throw. In all these cases set '*done' to true, | 9786 // that is read-only, throw. In all these cases set '*done' to true, |
9813 // otherwise set it to false. | 9787 // otherwise set it to false. |
9814 MUST_USE_RESULT | 9788 MUST_USE_RESULT |
9815 static MaybeHandle<Object> SetPropertyViaPrototypesWithHandler( | 9789 static MaybeHandle<Object> SetPropertyViaPrototypesWithHandler( |
9816 Handle<JSProxy> proxy, Handle<Object> receiver, Handle<Name> name, | 9790 Handle<JSProxy> proxy, Handle<Object> receiver, Handle<Name> name, |
9817 Handle<Object> value, StrictMode strict_mode, bool* done); | 9791 Handle<Object> value, LanguageMode language_mode, bool* done); |
9818 | 9792 |
9819 MUST_USE_RESULT static Maybe<PropertyAttributes> | 9793 MUST_USE_RESULT static Maybe<PropertyAttributes> |
9820 GetPropertyAttributesWithHandler(Handle<JSProxy> proxy, | 9794 GetPropertyAttributesWithHandler(Handle<JSProxy> proxy, |
9821 Handle<Object> receiver, | 9795 Handle<Object> receiver, |
9822 Handle<Name> name); | 9796 Handle<Name> name); |
9823 MUST_USE_RESULT static Maybe<PropertyAttributes> | 9797 MUST_USE_RESULT static Maybe<PropertyAttributes> |
9824 GetElementAttributeWithHandler(Handle<JSProxy> proxy, | 9798 GetElementAttributeWithHandler(Handle<JSProxy> proxy, |
9825 Handle<JSReceiver> receiver, | 9799 Handle<JSReceiver> receiver, |
9826 uint32_t index); | 9800 uint32_t index); |
9827 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithHandler( | 9801 MUST_USE_RESULT static MaybeHandle<Object> SetPropertyWithHandler( |
9828 Handle<JSProxy> proxy, Handle<Object> receiver, Handle<Name> name, | 9802 Handle<JSProxy> proxy, Handle<Object> receiver, Handle<Name> name, |
9829 Handle<Object> value, StrictMode strict_mode); | 9803 Handle<Object> value, LanguageMode language_mode); |
9830 | 9804 |
9831 // Turn the proxy into an (empty) JSObject. | 9805 // Turn the proxy into an (empty) JSObject. |
9832 static void Fix(Handle<JSProxy> proxy); | 9806 static void Fix(Handle<JSProxy> proxy); |
9833 | 9807 |
9834 // Initializes the body after the handler slot. | 9808 // Initializes the body after the handler slot. |
9835 inline void InitializeBody(int object_size, Object* value); | 9809 inline void InitializeBody(int object_size, Object* value); |
9836 | 9810 |
9837 // Invoke a trap by name. If the trap does not exist on this's handler, | 9811 // Invoke a trap by name. If the trap does not exist on this's handler, |
9838 // but derived_trap is non-NULL, invoke that instead. May cause GC. | 9812 // but derived_trap is non-NULL, invoke that instead. May cause GC. |
9839 MUST_USE_RESULT static MaybeHandle<Object> CallTrap( | 9813 MUST_USE_RESULT static MaybeHandle<Object> CallTrap( |
(...skipping 20 matching lines...) Expand all Loading... |
9860 STATIC_ASSERT(kPaddingSize >= 0); | 9834 STATIC_ASSERT(kPaddingSize >= 0); |
9861 | 9835 |
9862 typedef FixedBodyDescriptor<kHandlerOffset, | 9836 typedef FixedBodyDescriptor<kHandlerOffset, |
9863 kPaddingOffset, | 9837 kPaddingOffset, |
9864 kSize> BodyDescriptor; | 9838 kSize> BodyDescriptor; |
9865 | 9839 |
9866 private: | 9840 private: |
9867 friend class JSReceiver; | 9841 friend class JSReceiver; |
9868 | 9842 |
9869 MUST_USE_RESULT static inline MaybeHandle<Object> SetElementWithHandler( | 9843 MUST_USE_RESULT static inline MaybeHandle<Object> SetElementWithHandler( |
9870 Handle<JSProxy> proxy, | 9844 Handle<JSProxy> proxy, Handle<JSReceiver> receiver, uint32_t index, |
9871 Handle<JSReceiver> receiver, | 9845 Handle<Object> value, LanguageMode language_mode); |
9872 uint32_t index, | |
9873 Handle<Object> value, | |
9874 StrictMode strict_mode); | |
9875 | 9846 |
9876 MUST_USE_RESULT static Maybe<bool> HasPropertyWithHandler( | 9847 MUST_USE_RESULT static Maybe<bool> HasPropertyWithHandler( |
9877 Handle<JSProxy> proxy, Handle<Name> name); | 9848 Handle<JSProxy> proxy, Handle<Name> name); |
9878 MUST_USE_RESULT static inline Maybe<bool> HasElementWithHandler( | 9849 MUST_USE_RESULT static inline Maybe<bool> HasElementWithHandler( |
9879 Handle<JSProxy> proxy, uint32_t index); | 9850 Handle<JSProxy> proxy, uint32_t index); |
9880 | 9851 |
9881 MUST_USE_RESULT static MaybeHandle<Object> DeletePropertyWithHandler( | 9852 MUST_USE_RESULT static MaybeHandle<Object> DeletePropertyWithHandler( |
9882 Handle<JSProxy> proxy, Handle<Name> name, StrictMode strict_mode); | 9853 Handle<JSProxy> proxy, Handle<Name> name, LanguageMode language_mode); |
9883 MUST_USE_RESULT static MaybeHandle<Object> DeleteElementWithHandler( | 9854 MUST_USE_RESULT static MaybeHandle<Object> DeleteElementWithHandler( |
9884 Handle<JSProxy> proxy, uint32_t index, StrictMode strict_mode); | 9855 Handle<JSProxy> proxy, uint32_t index, LanguageMode language_mode); |
9885 | 9856 |
9886 MUST_USE_RESULT Object* GetIdentityHash(); | 9857 MUST_USE_RESULT Object* GetIdentityHash(); |
9887 | 9858 |
9888 static Handle<Smi> GetOrCreateIdentityHash(Handle<JSProxy> proxy); | 9859 static Handle<Smi> GetOrCreateIdentityHash(Handle<JSProxy> proxy); |
9889 | 9860 |
9890 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy); | 9861 DISALLOW_IMPLICIT_CONSTRUCTORS(JSProxy); |
9891 }; | 9862 }; |
9892 | 9863 |
9893 | 9864 |
9894 class JSFunctionProxy: public JSProxy { | 9865 class JSFunctionProxy: public JSProxy { |
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10972 } else { | 10943 } else { |
10973 value &= ~(1 << bit_position); | 10944 value &= ~(1 << bit_position); |
10974 } | 10945 } |
10975 return value; | 10946 return value; |
10976 } | 10947 } |
10977 }; | 10948 }; |
10978 | 10949 |
10979 } } // namespace v8::internal | 10950 } } // namespace v8::internal |
10980 | 10951 |
10981 #endif // V8_OBJECTS_H_ | 10952 #endif // V8_OBJECTS_H_ |
OLD | NEW |