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 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1053 | 1053 |
1054 // Filler objects (fillers and free space objects). | 1054 // Filler objects (fillers and free space objects). |
1055 inline bool IsFiller(); | 1055 inline bool IsFiller(); |
1056 | 1056 |
1057 // Extract the number. | 1057 // Extract the number. |
1058 inline double Number(); | 1058 inline double Number(); |
1059 inline bool IsNaN(); | 1059 inline bool IsNaN(); |
1060 bool ToInt32(int32_t* value); | 1060 bool ToInt32(int32_t* value); |
1061 bool ToUint32(uint32_t* value); | 1061 bool ToUint32(uint32_t* value); |
1062 | 1062 |
1063 inline Representation OptimalRepresentation() { | 1063 // Indicates to OptimalRepresentation what kind of value it is being invoked |
1064 if (FLAG_track_fields && IsSmi()) { | 1064 // on. The representation of REAL_VALUEs is entirely dependent on the value. |
| 1065 // PLACEHOLDER_VALUEs have Representation::None(), so the actual |
| 1066 // representation can be determined later on. FORCE_TAGGED is used when |
| 1067 // initializing a field that will later be used for any kind of value without |
| 1068 // following the regular property assignments paths that will lead to |
| 1069 // generlization. |
| 1070 enum ValueType { |
| 1071 REAL_VALUE, |
| 1072 PLACEHOLDER_VALUE, |
| 1073 FORCE_TAGGED |
| 1074 }; |
| 1075 |
| 1076 inline Representation OptimalRepresentation(ValueType type = REAL_VALUE) { |
| 1077 if (!FLAG_track_fields) return Representation::Tagged(); |
| 1078 if (type == PLACEHOLDER_VALUE) return Representation::None(); |
| 1079 if (type == FORCE_TAGGED) return Representation::Tagged(); |
| 1080 if (IsSmi()) { |
1065 return Representation::Smi(); | 1081 return Representation::Smi(); |
1066 } else if (FLAG_track_double_fields && IsHeapNumber()) { | 1082 } else if (FLAG_track_double_fields && IsHeapNumber()) { |
1067 return Representation::Double(); | 1083 return Representation::Double(); |
1068 } else if (FLAG_track_heap_object_fields && !IsUndefined()) { | 1084 } else if (FLAG_track_heap_object_fields) { |
1069 // Don't track undefined as heapobject because it's also used as temporary | |
1070 // value for computed fields that may turn out to be Smi. That combination | |
1071 // will go tagged, so go tagged immediately. | |
1072 // TODO(verwaest): Change once we track computed boilerplate fields. | |
1073 ASSERT(IsHeapObject()); | 1085 ASSERT(IsHeapObject()); |
1074 return Representation::HeapObject(); | 1086 return Representation::HeapObject(); |
1075 } else { | 1087 } else { |
1076 return Representation::Tagged(); | 1088 return Representation::Tagged(); |
1077 } | 1089 } |
1078 } | 1090 } |
1079 | 1091 |
1080 inline bool FitsRepresentation(Representation representation) { | 1092 inline bool FitsRepresentation(Representation representation) { |
1081 if (FLAG_track_fields && representation.IsSmi()) { | 1093 if (FLAG_track_fields && representation.IsNone()) { |
| 1094 return false; |
| 1095 } else if (FLAG_track_fields && representation.IsSmi()) { |
1082 return IsSmi(); | 1096 return IsSmi(); |
1083 } else if (FLAG_track_double_fields && representation.IsDouble()) { | 1097 } else if (FLAG_track_double_fields && representation.IsDouble()) { |
1084 return IsNumber(); | 1098 return IsNumber(); |
1085 } else if (FLAG_track_heap_object_fields && representation.IsHeapObject()) { | 1099 } else if (FLAG_track_heap_object_fields && representation.IsHeapObject()) { |
1086 return IsHeapObject(); | 1100 return IsHeapObject(); |
1087 } | 1101 } |
1088 return true; | 1102 return true; |
1089 } | 1103 } |
1090 | 1104 |
1091 inline MaybeObject* AllocateNewStorageFor(Heap* heap, | 1105 inline MaybeObject* AllocateNewStorageFor(Heap* heap, |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1820 Name* name, | 1834 Name* name, |
1821 Object* value, | 1835 Object* value, |
1822 PropertyAttributes attributes, | 1836 PropertyAttributes attributes, |
1823 StrictModeFlag strict_mode, | 1837 StrictModeFlag strict_mode, |
1824 ExtensibilityCheck extensibility_check); | 1838 ExtensibilityCheck extensibility_check); |
1825 | 1839 |
1826 static Handle<Object> SetLocalPropertyIgnoreAttributes( | 1840 static Handle<Object> SetLocalPropertyIgnoreAttributes( |
1827 Handle<JSObject> object, | 1841 Handle<JSObject> object, |
1828 Handle<Name> key, | 1842 Handle<Name> key, |
1829 Handle<Object> value, | 1843 Handle<Object> value, |
1830 PropertyAttributes attributes); | 1844 PropertyAttributes attributes, |
| 1845 ValueType value_type = REAL_VALUE); |
1831 | 1846 |
1832 static inline Handle<String> ExpectedTransitionKey(Handle<Map> map); | 1847 static inline Handle<String> ExpectedTransitionKey(Handle<Map> map); |
1833 static inline Handle<Map> ExpectedTransitionTarget(Handle<Map> map); | 1848 static inline Handle<Map> ExpectedTransitionTarget(Handle<Map> map); |
1834 | 1849 |
1835 // Try to follow an existing transition to a field with attributes NONE. The | 1850 // Try to follow an existing transition to a field with attributes NONE. The |
1836 // return value indicates whether the transition was successful. | 1851 // return value indicates whether the transition was successful. |
1837 static inline Handle<Map> FindTransitionToField(Handle<Map> map, | 1852 static inline Handle<Map> FindTransitionToField(Handle<Map> map, |
1838 Handle<Name> key); | 1853 Handle<Name> key); |
1839 | 1854 |
1840 inline int LastAddedFieldIndex(); | 1855 inline int LastAddedFieldIndex(); |
1841 | 1856 |
1842 // Extend the receiver with a single fast property appeared first in the | 1857 // Extend the receiver with a single fast property appeared first in the |
1843 // passed map. This also extends the property backing store if necessary. | 1858 // passed map. This also extends the property backing store if necessary. |
1844 static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map); | 1859 static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map); |
1845 inline MUST_USE_RESULT MaybeObject* AllocateStorageForMap(Map* map); | 1860 inline MUST_USE_RESULT MaybeObject* AllocateStorageForMap(Map* map); |
1846 | 1861 |
1847 static void MigrateInstance(Handle<JSObject> instance); | 1862 static void MigrateInstance(Handle<JSObject> instance); |
1848 inline MUST_USE_RESULT MaybeObject* MigrateInstance(); | 1863 inline MUST_USE_RESULT MaybeObject* MigrateInstance(); |
1849 | 1864 |
1850 static Handle<Object> TryMigrateInstance(Handle<JSObject> instance); | 1865 static Handle<Object> TryMigrateInstance(Handle<JSObject> instance); |
1851 inline MUST_USE_RESULT MaybeObject* TryMigrateInstance(); | 1866 inline MUST_USE_RESULT MaybeObject* TryMigrateInstance(); |
1852 | 1867 |
1853 // Can cause GC. | 1868 // Can cause GC. |
1854 MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributes( | 1869 MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributes( |
1855 Name* key, | 1870 Name* key, |
1856 Object* value, | 1871 Object* value, |
1857 PropertyAttributes attributes); | 1872 PropertyAttributes attributes, |
| 1873 ValueType value_type = REAL_VALUE); |
1858 | 1874 |
1859 // Retrieve a value in a normalized object given a lookup result. | 1875 // Retrieve a value in a normalized object given a lookup result. |
1860 // Handles the special representation of JS global objects. | 1876 // Handles the special representation of JS global objects. |
1861 Object* GetNormalizedProperty(LookupResult* result); | 1877 Object* GetNormalizedProperty(LookupResult* result); |
1862 | 1878 |
1863 // Sets the property value in a normalized object given a lookup result. | 1879 // Sets the property value in a normalized object given a lookup result. |
1864 // Handles the special representation of JS global objects. | 1880 // Handles the special representation of JS global objects. |
1865 Object* SetNormalizedProperty(LookupResult* result, Object* value); | 1881 Object* SetNormalizedProperty(LookupResult* result, Object* value); |
1866 | 1882 |
1867 // Sets the property value in a normalized object given (key, value, details). | 1883 // Sets the property value in a normalized object given (key, value, details). |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2209 MUST_USE_RESULT MaybeObject* MigrateToMap(Map* new_map); | 2225 MUST_USE_RESULT MaybeObject* MigrateToMap(Map* new_map); |
2210 MUST_USE_RESULT MaybeObject* GeneralizeFieldRepresentation( | 2226 MUST_USE_RESULT MaybeObject* GeneralizeFieldRepresentation( |
2211 int modify_index, | 2227 int modify_index, |
2212 Representation new_representation); | 2228 Representation new_representation); |
2213 | 2229 |
2214 // Add a property to a fast-case object. | 2230 // Add a property to a fast-case object. |
2215 MUST_USE_RESULT MaybeObject* AddFastProperty( | 2231 MUST_USE_RESULT MaybeObject* AddFastProperty( |
2216 Name* name, | 2232 Name* name, |
2217 Object* value, | 2233 Object* value, |
2218 PropertyAttributes attributes, | 2234 PropertyAttributes attributes, |
2219 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED); | 2235 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, |
| 2236 ValueType value_type = REAL_VALUE); |
2220 | 2237 |
2221 // Add a property to a slow-case object. | 2238 // Add a property to a slow-case object. |
2222 MUST_USE_RESULT MaybeObject* AddSlowProperty(Name* name, | 2239 MUST_USE_RESULT MaybeObject* AddSlowProperty(Name* name, |
2223 Object* value, | 2240 Object* value, |
2224 PropertyAttributes attributes); | 2241 PropertyAttributes attributes); |
2225 | 2242 |
2226 // Add a property to an object. May cause GC. | 2243 // Add a property to an object. May cause GC. |
2227 MUST_USE_RESULT MaybeObject* AddProperty( | 2244 MUST_USE_RESULT MaybeObject* AddProperty( |
2228 Name* name, | 2245 Name* name, |
2229 Object* value, | 2246 Object* value, |
2230 PropertyAttributes attributes, | 2247 PropertyAttributes attributes, |
2231 StrictModeFlag strict_mode, | 2248 StrictModeFlag strict_mode, |
2232 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, | 2249 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, |
2233 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK); | 2250 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK, |
| 2251 ValueType value_type = REAL_VALUE); |
2234 | 2252 |
2235 // Convert the object to use the canonical dictionary | 2253 // Convert the object to use the canonical dictionary |
2236 // representation. If the object is expected to have additional properties | 2254 // representation. If the object is expected to have additional properties |
2237 // added this number can be indicated to have the backing store allocated to | 2255 // added this number can be indicated to have the backing store allocated to |
2238 // an initial capacity for holding these properties. | 2256 // an initial capacity for holding these properties. |
2239 static void NormalizeProperties(Handle<JSObject> object, | 2257 static void NormalizeProperties(Handle<JSObject> object, |
2240 PropertyNormalizationMode mode, | 2258 PropertyNormalizationMode mode, |
2241 int expected_additional_properties); | 2259 int expected_additional_properties); |
2242 | 2260 |
2243 MUST_USE_RESULT MaybeObject* NormalizeProperties( | 2261 MUST_USE_RESULT MaybeObject* NormalizeProperties( |
(...skipping 7396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9640 } else { | 9658 } else { |
9641 value &= ~(1 << bit_position); | 9659 value &= ~(1 << bit_position); |
9642 } | 9660 } |
9643 return value; | 9661 return value; |
9644 } | 9662 } |
9645 }; | 9663 }; |
9646 | 9664 |
9647 } } // namespace v8::internal | 9665 } } // namespace v8::internal |
9648 | 9666 |
9649 #endif // V8_OBJECTS_H_ | 9667 #endif // V8_OBJECTS_H_ |
OLD | NEW |