OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1637 FORCE_DELETION | 1637 FORCE_DELETION |
1638 }; | 1638 }; |
1639 | 1639 |
1640 // A non-keyed store is of the form a.x = foo or a["x"] = foo whereas | 1640 // A non-keyed store is of the form a.x = foo or a["x"] = foo whereas |
1641 // a keyed store is of the form a[expression] = foo. | 1641 // a keyed store is of the form a[expression] = foo. |
1642 enum StoreFromKeyed { | 1642 enum StoreFromKeyed { |
1643 MAY_BE_STORE_FROM_KEYED, | 1643 MAY_BE_STORE_FROM_KEYED, |
1644 CERTAINLY_NOT_STORE_FROM_KEYED | 1644 CERTAINLY_NOT_STORE_FROM_KEYED |
1645 }; | 1645 }; |
1646 | 1646 |
| 1647 // Indicates whether a value can be loaded as a constant. |
| 1648 enum StoreMode { |
| 1649 ALLOW_AS_CONSTANT, |
| 1650 FORCE_FIELD |
| 1651 }; |
| 1652 |
1647 // Internal properties (e.g. the hidden properties dictionary) might | 1653 // Internal properties (e.g. the hidden properties dictionary) might |
1648 // be added even though the receiver is non-extensible. | 1654 // be added even though the receiver is non-extensible. |
1649 enum ExtensibilityCheck { | 1655 enum ExtensibilityCheck { |
1650 PERFORM_EXTENSIBILITY_CHECK, | 1656 PERFORM_EXTENSIBILITY_CHECK, |
1651 OMIT_EXTENSIBILITY_CHECK | 1657 OMIT_EXTENSIBILITY_CHECK |
1652 }; | 1658 }; |
1653 | 1659 |
1654 // Casting. | 1660 // Casting. |
1655 static inline JSReceiver* cast(Object* obj); | 1661 static inline JSReceiver* cast(Object* obj); |
1656 | 1662 |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1864 MUST_USE_RESULT MaybeObject* SetPropertyWithInterceptor( | 1870 MUST_USE_RESULT MaybeObject* SetPropertyWithInterceptor( |
1865 Name* name, | 1871 Name* name, |
1866 Object* value, | 1872 Object* value, |
1867 PropertyAttributes attributes, | 1873 PropertyAttributes attributes, |
1868 StrictModeFlag strict_mode); | 1874 StrictModeFlag strict_mode); |
1869 MUST_USE_RESULT MaybeObject* SetPropertyPostInterceptor( | 1875 MUST_USE_RESULT MaybeObject* SetPropertyPostInterceptor( |
1870 Name* name, | 1876 Name* name, |
1871 Object* value, | 1877 Object* value, |
1872 PropertyAttributes attributes, | 1878 PropertyAttributes attributes, |
1873 StrictModeFlag strict_mode, | 1879 StrictModeFlag strict_mode, |
1874 ExtensibilityCheck extensibility_check); | 1880 ExtensibilityCheck extensibility_check, |
| 1881 StoreMode mode = ALLOW_AS_CONSTANT); |
1875 | 1882 |
1876 static Handle<Object> SetLocalPropertyIgnoreAttributes( | 1883 static Handle<Object> SetLocalPropertyIgnoreAttributes( |
1877 Handle<JSObject> object, | 1884 Handle<JSObject> object, |
1878 Handle<Name> key, | 1885 Handle<Name> key, |
1879 Handle<Object> value, | 1886 Handle<Object> value, |
1880 PropertyAttributes attributes, | 1887 PropertyAttributes attributes, |
1881 ValueType value_type = OPTIMAL_REPRESENTATION); | 1888 ValueType value_type = OPTIMAL_REPRESENTATION, |
| 1889 StoreMode mode = ALLOW_AS_CONSTANT); |
1882 | 1890 |
1883 static inline Handle<String> ExpectedTransitionKey(Handle<Map> map); | 1891 static inline Handle<String> ExpectedTransitionKey(Handle<Map> map); |
1884 static inline Handle<Map> ExpectedTransitionTarget(Handle<Map> map); | 1892 static inline Handle<Map> ExpectedTransitionTarget(Handle<Map> map); |
1885 | 1893 |
1886 // Try to follow an existing transition to a field with attributes NONE. The | 1894 // Try to follow an existing transition to a field with attributes NONE. The |
1887 // return value indicates whether the transition was successful. | 1895 // return value indicates whether the transition was successful. |
1888 static inline Handle<Map> FindTransitionToField(Handle<Map> map, | 1896 static inline Handle<Map> FindTransitionToField(Handle<Map> map, |
1889 Handle<Name> key); | 1897 Handle<Name> key); |
1890 | 1898 |
1891 inline int LastAddedFieldIndex(); | 1899 inline int LastAddedFieldIndex(); |
1892 | 1900 |
1893 // Extend the receiver with a single fast property appeared first in the | 1901 // Extend the receiver with a single fast property appeared first in the |
1894 // passed map. This also extends the property backing store if necessary. | 1902 // passed map. This also extends the property backing store if necessary. |
1895 static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map); | 1903 static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map); |
1896 inline MUST_USE_RESULT MaybeObject* AllocateStorageForMap(Map* map); | 1904 inline MUST_USE_RESULT MaybeObject* AllocateStorageForMap(Map* map); |
1897 | 1905 |
1898 static void MigrateInstance(Handle<JSObject> instance); | 1906 static void MigrateInstance(Handle<JSObject> instance); |
1899 inline MUST_USE_RESULT MaybeObject* MigrateInstance(); | 1907 inline MUST_USE_RESULT MaybeObject* MigrateInstance(); |
1900 | 1908 |
1901 static Handle<Object> TryMigrateInstance(Handle<JSObject> instance); | 1909 static Handle<Object> TryMigrateInstance(Handle<JSObject> instance); |
1902 inline MUST_USE_RESULT MaybeObject* TryMigrateInstance(); | 1910 inline MUST_USE_RESULT MaybeObject* TryMigrateInstance(); |
1903 | 1911 |
1904 // Can cause GC. | 1912 // Can cause GC. |
1905 MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributes( | 1913 MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributes( |
1906 Name* key, | 1914 Name* key, |
1907 Object* value, | 1915 Object* value, |
1908 PropertyAttributes attributes, | 1916 PropertyAttributes attributes, |
1909 ValueType value_type = OPTIMAL_REPRESENTATION); | 1917 ValueType value_type = OPTIMAL_REPRESENTATION, |
| 1918 StoreMode mode = ALLOW_AS_CONSTANT); |
1910 | 1919 |
1911 // Retrieve a value in a normalized object given a lookup result. | 1920 // Retrieve a value in a normalized object given a lookup result. |
1912 // Handles the special representation of JS global objects. | 1921 // Handles the special representation of JS global objects. |
1913 Object* GetNormalizedProperty(LookupResult* result); | 1922 Object* GetNormalizedProperty(LookupResult* result); |
1914 | 1923 |
1915 // Sets the property value in a normalized object given (key, value). | 1924 // Sets the property value in a normalized object given (key, value). |
1916 // Handles the special representation of JS global objects. | 1925 // Handles the special representation of JS global objects. |
1917 static Handle<Object> SetNormalizedProperty(Handle<JSObject> object, | 1926 static Handle<Object> SetNormalizedProperty(Handle<JSObject> object, |
1918 LookupResult* result, | 1927 LookupResult* result, |
1919 Handle<Object> value); | 1928 Handle<Object> value); |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2198 Object* value, | 2207 Object* value, |
2199 int field_index, | 2208 int field_index, |
2200 Representation representation); | 2209 Representation representation); |
2201 | 2210 |
2202 // Add a constant function property to a fast-case object. | 2211 // Add a constant function property to a fast-case object. |
2203 // This leaves a CONSTANT_TRANSITION in the old map, and | 2212 // This leaves a CONSTANT_TRANSITION in the old map, and |
2204 // if it is called on a second object with this map, a | 2213 // if it is called on a second object with this map, a |
2205 // normal property is added instead, with a map transition. | 2214 // normal property is added instead, with a map transition. |
2206 // This avoids the creation of many maps with the same constant | 2215 // This avoids the creation of many maps with the same constant |
2207 // function, all orphaned. | 2216 // function, all orphaned. |
2208 MUST_USE_RESULT MaybeObject* AddConstantFunctionProperty( | 2217 MUST_USE_RESULT MaybeObject* AddConstantProperty( |
2209 Name* name, | 2218 Name* name, |
2210 JSFunction* function, | 2219 Object* constant, |
2211 PropertyAttributes attributes); | 2220 PropertyAttributes attributes); |
2212 | 2221 |
2213 MUST_USE_RESULT MaybeObject* ReplaceSlowProperty( | 2222 MUST_USE_RESULT MaybeObject* ReplaceSlowProperty( |
2214 Name* name, | 2223 Name* name, |
2215 Object* value, | 2224 Object* value, |
2216 PropertyAttributes attributes); | 2225 PropertyAttributes attributes); |
2217 | 2226 |
2218 // Returns a new map with all transitions dropped from the object's current | 2227 // Returns a new map with all transitions dropped from the object's current |
2219 // map and the ElementsKind set. | 2228 // map and the ElementsKind set. |
2220 static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object, | 2229 static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2265 PropertyAttributes attributes); | 2274 PropertyAttributes attributes); |
2266 | 2275 |
2267 // Add a property to an object. May cause GC. | 2276 // Add a property to an object. May cause GC. |
2268 MUST_USE_RESULT MaybeObject* AddProperty( | 2277 MUST_USE_RESULT MaybeObject* AddProperty( |
2269 Name* name, | 2278 Name* name, |
2270 Object* value, | 2279 Object* value, |
2271 PropertyAttributes attributes, | 2280 PropertyAttributes attributes, |
2272 StrictModeFlag strict_mode, | 2281 StrictModeFlag strict_mode, |
2273 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, | 2282 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, |
2274 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK, | 2283 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK, |
2275 ValueType value_type = OPTIMAL_REPRESENTATION); | 2284 ValueType value_type = OPTIMAL_REPRESENTATION, |
| 2285 StoreMode mode = ALLOW_AS_CONSTANT); |
2276 | 2286 |
2277 // Convert the object to use the canonical dictionary | 2287 // Convert the object to use the canonical dictionary |
2278 // representation. If the object is expected to have additional properties | 2288 // representation. If the object is expected to have additional properties |
2279 // added this number can be indicated to have the backing store allocated to | 2289 // added this number can be indicated to have the backing store allocated to |
2280 // an initial capacity for holding these properties. | 2290 // an initial capacity for holding these properties. |
2281 static void NormalizeProperties(Handle<JSObject> object, | 2291 static void NormalizeProperties(Handle<JSObject> object, |
2282 PropertyNormalizationMode mode, | 2292 PropertyNormalizationMode mode, |
2283 int expected_additional_properties); | 2293 int expected_additional_properties); |
2284 | 2294 |
2285 MUST_USE_RESULT MaybeObject* NormalizeProperties( | 2295 MUST_USE_RESULT MaybeObject* NormalizeProperties( |
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2856 // Accessors for fetching instance descriptor at descriptor number. | 2866 // Accessors for fetching instance descriptor at descriptor number. |
2857 inline Name* GetKey(int descriptor_number); | 2867 inline Name* GetKey(int descriptor_number); |
2858 inline Object** GetKeySlot(int descriptor_number); | 2868 inline Object** GetKeySlot(int descriptor_number); |
2859 inline Object* GetValue(int descriptor_number); | 2869 inline Object* GetValue(int descriptor_number); |
2860 inline Object** GetValueSlot(int descriptor_number); | 2870 inline Object** GetValueSlot(int descriptor_number); |
2861 inline Object** GetDescriptorStartSlot(int descriptor_number); | 2871 inline Object** GetDescriptorStartSlot(int descriptor_number); |
2862 inline Object** GetDescriptorEndSlot(int descriptor_number); | 2872 inline Object** GetDescriptorEndSlot(int descriptor_number); |
2863 inline PropertyDetails GetDetails(int descriptor_number); | 2873 inline PropertyDetails GetDetails(int descriptor_number); |
2864 inline PropertyType GetType(int descriptor_number); | 2874 inline PropertyType GetType(int descriptor_number); |
2865 inline int GetFieldIndex(int descriptor_number); | 2875 inline int GetFieldIndex(int descriptor_number); |
2866 inline JSFunction* GetConstantFunction(int descriptor_number); | 2876 inline Object* GetConstant(int descriptor_number); |
2867 inline Object* GetCallbacksObject(int descriptor_number); | 2877 inline Object* GetCallbacksObject(int descriptor_number); |
2868 inline AccessorDescriptor* GetCallbacks(int descriptor_number); | 2878 inline AccessorDescriptor* GetCallbacks(int descriptor_number); |
2869 | 2879 |
2870 inline Name* GetSortedKey(int descriptor_number); | 2880 inline Name* GetSortedKey(int descriptor_number); |
2871 inline int GetSortedKeyIndex(int descriptor_number); | 2881 inline int GetSortedKeyIndex(int descriptor_number); |
2872 inline void SetSortedKey(int pointer, int descriptor_number); | 2882 inline void SetSortedKey(int pointer, int descriptor_number); |
2873 inline void InitializeRepresentations(Representation representation); | 2883 inline void InitializeRepresentations(Representation representation); |
2874 inline void SetRepresentation(int descriptor_number, | 2884 inline void SetRepresentation(int descriptor_number, |
2875 Representation representation); | 2885 Representation representation); |
2876 | 2886 |
(...skipping 1634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4511 // No more than 16 kinds. The value is currently encoded in four bits in | 4521 // No more than 16 kinds. The value is currently encoded in four bits in |
4512 // Flags. | 4522 // Flags. |
4513 STATIC_ASSERT(NUMBER_OF_KINDS <= 16); | 4523 STATIC_ASSERT(NUMBER_OF_KINDS <= 16); |
4514 | 4524 |
4515 static const char* Kind2String(Kind kind); | 4525 static const char* Kind2String(Kind kind); |
4516 | 4526 |
4517 // Types of stubs. | 4527 // Types of stubs. |
4518 enum StubType { | 4528 enum StubType { |
4519 NORMAL, | 4529 NORMAL, |
4520 FIELD, | 4530 FIELD, |
4521 CONSTANT_FUNCTION, | 4531 CONSTANT, |
4522 CALLBACKS, | 4532 CALLBACKS, |
4523 INTERCEPTOR, | 4533 INTERCEPTOR, |
4524 MAP_TRANSITION, | 4534 MAP_TRANSITION, |
4525 NONEXISTENT | 4535 NONEXISTENT |
4526 }; | 4536 }; |
4527 | 4537 |
4528 enum StubHolder { | 4538 enum StubHolder { |
4529 OWN_STUB, | 4539 OWN_STUB, |
4530 PROTOTYPE_STUB | 4540 PROTOTYPE_STUB |
4531 }; | 4541 }; |
(...skipping 5346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9878 } else { | 9888 } else { |
9879 value &= ~(1 << bit_position); | 9889 value &= ~(1 << bit_position); |
9880 } | 9890 } |
9881 return value; | 9891 return value; |
9882 } | 9892 } |
9883 }; | 9893 }; |
9884 | 9894 |
9885 } } // namespace v8::internal | 9895 } } // namespace v8::internal |
9886 | 9896 |
9887 #endif // V8_OBJECTS_H_ | 9897 #endif // V8_OBJECTS_H_ |
OLD | NEW |