| 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 851 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 862 #define DECLARE_PRINTER(Name) | 862 #define DECLARE_PRINTER(Name) | 
| 863 #endif | 863 #endif | 
| 864 | 864 | 
| 865 class MaybeObject BASE_EMBEDDED { | 865 class MaybeObject BASE_EMBEDDED { | 
| 866  public: | 866  public: | 
| 867   inline bool IsFailure(); | 867   inline bool IsFailure(); | 
| 868   inline bool IsRetryAfterGC(); | 868   inline bool IsRetryAfterGC(); | 
| 869   inline bool IsOutOfMemory(); | 869   inline bool IsOutOfMemory(); | 
| 870   inline bool IsException(); | 870   inline bool IsException(); | 
| 871   INLINE(bool IsTheHole()); | 871   INLINE(bool IsTheHole()); | 
|  | 872   INLINE(bool IsUninitialized()); | 
| 872   inline bool ToObject(Object** obj) { | 873   inline bool ToObject(Object** obj) { | 
| 873     if (IsFailure()) return false; | 874     if (IsFailure()) return false; | 
| 874     *obj = reinterpret_cast<Object*>(this); | 875     *obj = reinterpret_cast<Object*>(this); | 
| 875     return true; | 876     return true; | 
| 876   } | 877   } | 
| 877   inline Failure* ToFailureUnchecked() { | 878   inline Failure* ToFailureUnchecked() { | 
| 878     ASSERT(IsFailure()); | 879     ASSERT(IsFailure()); | 
| 879     return reinterpret_cast<Failure*>(this); | 880     return reinterpret_cast<Failure*>(this); | 
| 880   } | 881   } | 
| 881   inline Object* ToObjectUnchecked() { | 882   inline Object* ToObjectUnchecked() { | 
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1039   STRUCT_LIST(DECLARE_STRUCT_PREDICATE) | 1040   STRUCT_LIST(DECLARE_STRUCT_PREDICATE) | 
| 1040 #undef DECLARE_STRUCT_PREDICATE | 1041 #undef DECLARE_STRUCT_PREDICATE | 
| 1041 | 1042 | 
| 1042   INLINE(bool IsSpecObject()); | 1043   INLINE(bool IsSpecObject()); | 
| 1043   INLINE(bool IsSpecFunction()); | 1044   INLINE(bool IsSpecFunction()); | 
| 1044 | 1045 | 
| 1045   // Oddball testing. | 1046   // Oddball testing. | 
| 1046   INLINE(bool IsUndefined()); | 1047   INLINE(bool IsUndefined()); | 
| 1047   INLINE(bool IsNull()); | 1048   INLINE(bool IsNull()); | 
| 1048   INLINE(bool IsTheHole());  // Shadows MaybeObject's implementation. | 1049   INLINE(bool IsTheHole());  // Shadows MaybeObject's implementation. | 
|  | 1050   INLINE(bool IsUninitialized()); | 
| 1049   INLINE(bool IsTrue()); | 1051   INLINE(bool IsTrue()); | 
| 1050   INLINE(bool IsFalse()); | 1052   INLINE(bool IsFalse()); | 
| 1051   inline bool IsArgumentsMarker(); | 1053   inline bool IsArgumentsMarker(); | 
| 1052   inline bool NonFailureIsHeapObject(); | 1054   inline bool NonFailureIsHeapObject(); | 
| 1053 | 1055 | 
| 1054   // Filler objects (fillers and free space objects). | 1056   // Filler objects (fillers and free space objects). | 
| 1055   inline bool IsFiller(); | 1057   inline bool IsFiller(); | 
| 1056 | 1058 | 
| 1057   // Extract the number. | 1059   // Extract the number. | 
| 1058   inline double Number(); | 1060   inline double Number(); | 
| 1059   inline bool IsNaN(); | 1061   inline bool IsNaN(); | 
| 1060   bool ToInt32(int32_t* value); | 1062   bool ToInt32(int32_t* value); | 
| 1061   bool ToUint32(uint32_t* value); | 1063   bool ToUint32(uint32_t* value); | 
| 1062 | 1064 | 
| 1063   inline Representation OptimalRepresentation() { | 1065   // Indicates to OptimalRepresentation what kind of value it is being invoked | 
| 1064     if (FLAG_track_fields && IsSmi()) { | 1066   // on. The representation of REAL_VALUEs is entirely dependent on the value. | 
|  | 1067   // PLACEHOLDER_VALUEs have Representation::None(), so the actual | 
|  | 1068   // representation can be determined later on. FORCE_TAGGED is used when | 
|  | 1069   // initializing a field that will later be used for any kind of value without | 
|  | 1070   // following the regular property assignments paths that will lead to | 
|  | 1071   // generlization. | 
|  | 1072   enum ValueType { | 
|  | 1073     REAL_VALUE, | 
|  | 1074     PLACEHOLDER_VALUE, | 
|  | 1075     FORCE_TAGGED | 
|  | 1076   }; | 
|  | 1077 | 
|  | 1078   inline Representation OptimalRepresentation(ValueType type = REAL_VALUE) { | 
|  | 1079     if (!FLAG_track_fields) return Representation::Tagged(); | 
|  | 1080     if (type == PLACEHOLDER_VALUE) return Representation::None(); | 
|  | 1081     if (type == FORCE_TAGGED) return Representation::Tagged(); | 
|  | 1082     if (IsSmi()) { | 
| 1065       return Representation::Smi(); | 1083       return Representation::Smi(); | 
| 1066     } else if (FLAG_track_double_fields && IsHeapNumber()) { | 1084     } else if (FLAG_track_double_fields && IsHeapNumber()) { | 
| 1067       return Representation::Double(); | 1085       return Representation::Double(); | 
| 1068     } else if (FLAG_track_heap_object_fields && !IsUndefined()) { | 1086     } 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()); | 1087       ASSERT(IsHeapObject()); | 
| 1074       return Representation::HeapObject(); | 1088       return Representation::HeapObject(); | 
| 1075     } else { | 1089     } else { | 
| 1076       return Representation::Tagged(); | 1090       return Representation::Tagged(); | 
| 1077     } | 1091     } | 
| 1078   } | 1092   } | 
| 1079 | 1093 | 
| 1080   inline bool FitsRepresentation(Representation representation) { | 1094   inline bool FitsRepresentation(Representation representation) { | 
| 1081     if (FLAG_track_fields && representation.IsSmi()) { | 1095     if (FLAG_track_fields && representation.IsNone()) { | 
|  | 1096       return false; | 
|  | 1097     } else if (FLAG_track_fields && representation.IsSmi()) { | 
| 1082       return IsSmi(); | 1098       return IsSmi(); | 
| 1083     } else if (FLAG_track_double_fields && representation.IsDouble()) { | 1099     } else if (FLAG_track_double_fields && representation.IsDouble()) { | 
| 1084       return IsNumber(); | 1100       return IsNumber(); | 
| 1085     } else if (FLAG_track_heap_object_fields && representation.IsHeapObject()) { | 1101     } else if (FLAG_track_heap_object_fields && representation.IsHeapObject()) { | 
| 1086       return IsHeapObject(); | 1102       return IsHeapObject(); | 
| 1087     } | 1103     } | 
| 1088     return true; | 1104     return true; | 
| 1089   } | 1105   } | 
| 1090 | 1106 | 
| 1091   inline MaybeObject* AllocateNewStorageFor(Heap* heap, | 1107   inline MaybeObject* AllocateNewStorageFor(Heap* heap, | 
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1820       Name* name, | 1836       Name* name, | 
| 1821       Object* value, | 1837       Object* value, | 
| 1822       PropertyAttributes attributes, | 1838       PropertyAttributes attributes, | 
| 1823       StrictModeFlag strict_mode, | 1839       StrictModeFlag strict_mode, | 
| 1824       ExtensibilityCheck extensibility_check); | 1840       ExtensibilityCheck extensibility_check); | 
| 1825 | 1841 | 
| 1826   static Handle<Object> SetLocalPropertyIgnoreAttributes( | 1842   static Handle<Object> SetLocalPropertyIgnoreAttributes( | 
| 1827       Handle<JSObject> object, | 1843       Handle<JSObject> object, | 
| 1828       Handle<Name> key, | 1844       Handle<Name> key, | 
| 1829       Handle<Object> value, | 1845       Handle<Object> value, | 
| 1830       PropertyAttributes attributes); | 1846       PropertyAttributes attributes, | 
|  | 1847       ValueType value_type = REAL_VALUE); | 
| 1831 | 1848 | 
| 1832   static inline Handle<String> ExpectedTransitionKey(Handle<Map> map); | 1849   static inline Handle<String> ExpectedTransitionKey(Handle<Map> map); | 
| 1833   static inline Handle<Map> ExpectedTransitionTarget(Handle<Map> map); | 1850   static inline Handle<Map> ExpectedTransitionTarget(Handle<Map> map); | 
| 1834 | 1851 | 
| 1835   // Try to follow an existing transition to a field with attributes NONE. The | 1852   // Try to follow an existing transition to a field with attributes NONE. The | 
| 1836   // return value indicates whether the transition was successful. | 1853   // return value indicates whether the transition was successful. | 
| 1837   static inline Handle<Map> FindTransitionToField(Handle<Map> map, | 1854   static inline Handle<Map> FindTransitionToField(Handle<Map> map, | 
| 1838                                                   Handle<Name> key); | 1855                                                   Handle<Name> key); | 
| 1839 | 1856 | 
| 1840   inline int LastAddedFieldIndex(); | 1857   inline int LastAddedFieldIndex(); | 
| 1841 | 1858 | 
| 1842   // Extend the receiver with a single fast property appeared first in the | 1859   // Extend the receiver with a single fast property appeared first in the | 
| 1843   // passed map. This also extends the property backing store if necessary. | 1860   // passed map. This also extends the property backing store if necessary. | 
| 1844   static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map); | 1861   static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map); | 
| 1845   inline MUST_USE_RESULT MaybeObject* AllocateStorageForMap(Map* map); | 1862   inline MUST_USE_RESULT MaybeObject* AllocateStorageForMap(Map* map); | 
| 1846 | 1863 | 
| 1847   static void MigrateInstance(Handle<JSObject> instance); | 1864   static void MigrateInstance(Handle<JSObject> instance); | 
| 1848   inline MUST_USE_RESULT MaybeObject* MigrateInstance(); | 1865   inline MUST_USE_RESULT MaybeObject* MigrateInstance(); | 
| 1849 | 1866 | 
| 1850   static Handle<Object> TryMigrateInstance(Handle<JSObject> instance); | 1867   static Handle<Object> TryMigrateInstance(Handle<JSObject> instance); | 
| 1851   inline MUST_USE_RESULT MaybeObject* TryMigrateInstance(); | 1868   inline MUST_USE_RESULT MaybeObject* TryMigrateInstance(); | 
| 1852 | 1869 | 
| 1853   // Can cause GC. | 1870   // Can cause GC. | 
| 1854   MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributes( | 1871   MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributes( | 
| 1855       Name* key, | 1872       Name* key, | 
| 1856       Object* value, | 1873       Object* value, | 
| 1857       PropertyAttributes attributes); | 1874       PropertyAttributes attributes, | 
|  | 1875       ValueType value_type = REAL_VALUE); | 
| 1858 | 1876 | 
| 1859   // Retrieve a value in a normalized object given a lookup result. | 1877   // Retrieve a value in a normalized object given a lookup result. | 
| 1860   // Handles the special representation of JS global objects. | 1878   // Handles the special representation of JS global objects. | 
| 1861   Object* GetNormalizedProperty(LookupResult* result); | 1879   Object* GetNormalizedProperty(LookupResult* result); | 
| 1862 | 1880 | 
| 1863   // Sets the property value in a normalized object given a lookup result. | 1881   // Sets the property value in a normalized object given a lookup result. | 
| 1864   // Handles the special representation of JS global objects. | 1882   // Handles the special representation of JS global objects. | 
| 1865   Object* SetNormalizedProperty(LookupResult* result, Object* value); | 1883   Object* SetNormalizedProperty(LookupResult* result, Object* value); | 
| 1866 | 1884 | 
| 1867   // Sets the property value in a normalized object given (key, value, details). | 1885   // 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); | 2227   MUST_USE_RESULT MaybeObject* MigrateToMap(Map* new_map); | 
| 2210   MUST_USE_RESULT MaybeObject* GeneralizeFieldRepresentation( | 2228   MUST_USE_RESULT MaybeObject* GeneralizeFieldRepresentation( | 
| 2211       int modify_index, | 2229       int modify_index, | 
| 2212       Representation new_representation); | 2230       Representation new_representation); | 
| 2213 | 2231 | 
| 2214   // Add a property to a fast-case object. | 2232   // Add a property to a fast-case object. | 
| 2215   MUST_USE_RESULT MaybeObject* AddFastProperty( | 2233   MUST_USE_RESULT MaybeObject* AddFastProperty( | 
| 2216       Name* name, | 2234       Name* name, | 
| 2217       Object* value, | 2235       Object* value, | 
| 2218       PropertyAttributes attributes, | 2236       PropertyAttributes attributes, | 
| 2219       StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED); | 2237       StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, | 
|  | 2238       ValueType value_type = REAL_VALUE); | 
| 2220 | 2239 | 
| 2221   // Add a property to a slow-case object. | 2240   // Add a property to a slow-case object. | 
| 2222   MUST_USE_RESULT MaybeObject* AddSlowProperty(Name* name, | 2241   MUST_USE_RESULT MaybeObject* AddSlowProperty(Name* name, | 
| 2223                                                Object* value, | 2242                                                Object* value, | 
| 2224                                                PropertyAttributes attributes); | 2243                                                PropertyAttributes attributes); | 
| 2225 | 2244 | 
| 2226   // Add a property to an object. May cause GC. | 2245   // Add a property to an object. May cause GC. | 
| 2227   MUST_USE_RESULT MaybeObject* AddProperty( | 2246   MUST_USE_RESULT MaybeObject* AddProperty( | 
| 2228       Name* name, | 2247       Name* name, | 
| 2229       Object* value, | 2248       Object* value, | 
| 2230       PropertyAttributes attributes, | 2249       PropertyAttributes attributes, | 
| 2231       StrictModeFlag strict_mode, | 2250       StrictModeFlag strict_mode, | 
| 2232       StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, | 2251       StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, | 
| 2233       ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK); | 2252       ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK, | 
|  | 2253       ValueType value_type = REAL_VALUE); | 
| 2234 | 2254 | 
| 2235   // Convert the object to use the canonical dictionary | 2255   // Convert the object to use the canonical dictionary | 
| 2236   // representation. If the object is expected to have additional properties | 2256   // representation. If the object is expected to have additional properties | 
| 2237   // added this number can be indicated to have the backing store allocated to | 2257   // added this number can be indicated to have the backing store allocated to | 
| 2238   // an initial capacity for holding these properties. | 2258   // an initial capacity for holding these properties. | 
| 2239   static void NormalizeProperties(Handle<JSObject> object, | 2259   static void NormalizeProperties(Handle<JSObject> object, | 
| 2240                                   PropertyNormalizationMode mode, | 2260                                   PropertyNormalizationMode mode, | 
| 2241                                   int expected_additional_properties); | 2261                                   int expected_additional_properties); | 
| 2242 | 2262 | 
| 2243   MUST_USE_RESULT MaybeObject* NormalizeProperties( | 2263   MUST_USE_RESULT MaybeObject* NormalizeProperties( | 
| (...skipping 6271 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 8515   static const int kKindOffset = kToNumberOffset + kPointerSize; | 8535   static const int kKindOffset = kToNumberOffset + kPointerSize; | 
| 8516   static const int kSize = kKindOffset + kPointerSize; | 8536   static const int kSize = kKindOffset + kPointerSize; | 
| 8517 | 8537 | 
| 8518   static const byte kFalse = 0; | 8538   static const byte kFalse = 0; | 
| 8519   static const byte kTrue = 1; | 8539   static const byte kTrue = 1; | 
| 8520   static const byte kNotBooleanMask = ~1; | 8540   static const byte kNotBooleanMask = ~1; | 
| 8521   static const byte kTheHole = 2; | 8541   static const byte kTheHole = 2; | 
| 8522   static const byte kNull = 3; | 8542   static const byte kNull = 3; | 
| 8523   static const byte kArgumentMarker = 4; | 8543   static const byte kArgumentMarker = 4; | 
| 8524   static const byte kUndefined = 5; | 8544   static const byte kUndefined = 5; | 
| 8525   static const byte kOther = 6; | 8545   static const byte kUninitialized = 6; | 
|  | 8546   static const byte kOther = 7; | 
| 8526 | 8547 | 
| 8527   typedef FixedBodyDescriptor<kToStringOffset, | 8548   typedef FixedBodyDescriptor<kToStringOffset, | 
| 8528                               kToNumberOffset + kPointerSize, | 8549                               kToNumberOffset + kPointerSize, | 
| 8529                               kSize> BodyDescriptor; | 8550                               kSize> BodyDescriptor; | 
| 8530 | 8551 | 
| 8531   STATIC_CHECK(kKindOffset == Internals::kOddballKindOffset); | 8552   STATIC_CHECK(kKindOffset == Internals::kOddballKindOffset); | 
| 8532   STATIC_CHECK(kNull == Internals::kNullOddballKind); | 8553   STATIC_CHECK(kNull == Internals::kNullOddballKind); | 
| 8533   STATIC_CHECK(kUndefined == Internals::kUndefinedOddballKind); | 8554   STATIC_CHECK(kUndefined == Internals::kUndefinedOddballKind); | 
| 8534 | 8555 | 
| 8535  private: | 8556  private: | 
| (...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 9640     } else { | 9661     } else { | 
| 9641       value &= ~(1 << bit_position); | 9662       value &= ~(1 << bit_position); | 
| 9642     } | 9663     } | 
| 9643     return value; | 9664     return value; | 
| 9644   } | 9665   } | 
| 9645 }; | 9666 }; | 
| 9646 | 9667 | 
| 9647 } }  // namespace v8::internal | 9668 } }  // namespace v8::internal | 
| 9648 | 9669 | 
| 9649 #endif  // V8_OBJECTS_H_ | 9670 #endif  // V8_OBJECTS_H_ | 
| OLD | NEW | 
|---|