Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(631)

Side by Side Diff: src/objects.h

Issue 14721009: Track computed literal properties. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Remove PLACEHOLDER_VALUE Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 whether OptimalRepresentation can do its work, or whether it
1064 if (FLAG_track_fields && IsSmi()) { 1066 // always has to return Representation::Tagged().
1067 enum ValueType {
1068 OPTIMAL_REPRESENTATION,
1069 FORCE_TAGGED
1070 };
1071
1072 inline Representation OptimalRepresentation(
1073 ValueType type = OPTIMAL_REPRESENTATION) {
1074 if (!FLAG_track_fields) return Representation::Tagged();
1075 if (type == FORCE_TAGGED) return Representation::Tagged();
1076 if (IsSmi()) {
1065 return Representation::Smi(); 1077 return Representation::Smi();
1066 } else if (FLAG_track_double_fields && IsHeapNumber()) { 1078 } else if (FLAG_track_double_fields && IsHeapNumber()) {
1067 return Representation::Double(); 1079 return Representation::Double();
1068 } else if (FLAG_track_heap_object_fields && !IsUndefined()) { 1080 } else if (FLAG_track_computed_fields && IsUninitialized()) {
1069 // Don't track undefined as heapobject because it's also used as temporary 1081 return Representation::None();
1070 // value for computed fields that may turn out to be Smi. That combination 1082 } else if (FLAG_track_heap_object_fields) {
1071 // will go tagged, so go tagged immediately.
1072 // TODO(verwaest): Change once we track computed boilerplate fields.
1073 ASSERT(IsHeapObject()); 1083 ASSERT(IsHeapObject());
1074 return Representation::HeapObject(); 1084 return Representation::HeapObject();
1075 } else { 1085 } else {
1076 return Representation::Tagged(); 1086 return Representation::Tagged();
1077 } 1087 }
1078 } 1088 }
1079 1089
1080 inline bool FitsRepresentation(Representation representation) { 1090 inline bool FitsRepresentation(Representation representation) {
1081 if (FLAG_track_fields && representation.IsSmi()) { 1091 if (FLAG_track_fields && representation.IsNone()) {
1092 return false;
1093 } else if (FLAG_track_fields && representation.IsSmi()) {
1082 return IsSmi(); 1094 return IsSmi();
1083 } else if (FLAG_track_double_fields && representation.IsDouble()) { 1095 } else if (FLAG_track_double_fields && representation.IsDouble()) {
1084 return IsNumber(); 1096 return IsNumber();
1085 } else if (FLAG_track_heap_object_fields && representation.IsHeapObject()) { 1097 } else if (FLAG_track_heap_object_fields && representation.IsHeapObject()) {
1086 return IsHeapObject(); 1098 return IsHeapObject();
1087 } 1099 }
1088 return true; 1100 return true;
1089 } 1101 }
1090 1102
1091 inline MaybeObject* AllocateNewStorageFor(Heap* heap, 1103 inline MaybeObject* AllocateNewStorageFor(Heap* heap,
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
1820 Name* name, 1832 Name* name,
1821 Object* value, 1833 Object* value,
1822 PropertyAttributes attributes, 1834 PropertyAttributes attributes,
1823 StrictModeFlag strict_mode, 1835 StrictModeFlag strict_mode,
1824 ExtensibilityCheck extensibility_check); 1836 ExtensibilityCheck extensibility_check);
1825 1837
1826 static Handle<Object> SetLocalPropertyIgnoreAttributes( 1838 static Handle<Object> SetLocalPropertyIgnoreAttributes(
1827 Handle<JSObject> object, 1839 Handle<JSObject> object,
1828 Handle<Name> key, 1840 Handle<Name> key,
1829 Handle<Object> value, 1841 Handle<Object> value,
1830 PropertyAttributes attributes); 1842 PropertyAttributes attributes,
1843 ValueType value_type = OPTIMAL_REPRESENTATION);
1831 1844
1832 static inline Handle<String> ExpectedTransitionKey(Handle<Map> map); 1845 static inline Handle<String> ExpectedTransitionKey(Handle<Map> map);
1833 static inline Handle<Map> ExpectedTransitionTarget(Handle<Map> map); 1846 static inline Handle<Map> ExpectedTransitionTarget(Handle<Map> map);
1834 1847
1835 // Try to follow an existing transition to a field with attributes NONE. The 1848 // Try to follow an existing transition to a field with attributes NONE. The
1836 // return value indicates whether the transition was successful. 1849 // return value indicates whether the transition was successful.
1837 static inline Handle<Map> FindTransitionToField(Handle<Map> map, 1850 static inline Handle<Map> FindTransitionToField(Handle<Map> map,
1838 Handle<Name> key); 1851 Handle<Name> key);
1839 1852
1840 inline int LastAddedFieldIndex(); 1853 inline int LastAddedFieldIndex();
1841 1854
1842 // Extend the receiver with a single fast property appeared first in the 1855 // Extend the receiver with a single fast property appeared first in the
1843 // passed map. This also extends the property backing store if necessary. 1856 // passed map. This also extends the property backing store if necessary.
1844 static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map); 1857 static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map);
1845 inline MUST_USE_RESULT MaybeObject* AllocateStorageForMap(Map* map); 1858 inline MUST_USE_RESULT MaybeObject* AllocateStorageForMap(Map* map);
1846 1859
1847 static void MigrateInstance(Handle<JSObject> instance); 1860 static void MigrateInstance(Handle<JSObject> instance);
1848 inline MUST_USE_RESULT MaybeObject* MigrateInstance(); 1861 inline MUST_USE_RESULT MaybeObject* MigrateInstance();
1849 1862
1850 static Handle<Object> TryMigrateInstance(Handle<JSObject> instance); 1863 static Handle<Object> TryMigrateInstance(Handle<JSObject> instance);
1851 inline MUST_USE_RESULT MaybeObject* TryMigrateInstance(); 1864 inline MUST_USE_RESULT MaybeObject* TryMigrateInstance();
1852 1865
1853 // Can cause GC. 1866 // Can cause GC.
1854 MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributes( 1867 MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributes(
1855 Name* key, 1868 Name* key,
1856 Object* value, 1869 Object* value,
1857 PropertyAttributes attributes); 1870 PropertyAttributes attributes,
1871 ValueType value_type = OPTIMAL_REPRESENTATION);
1858 1872
1859 // Retrieve a value in a normalized object given a lookup result. 1873 // Retrieve a value in a normalized object given a lookup result.
1860 // Handles the special representation of JS global objects. 1874 // Handles the special representation of JS global objects.
1861 Object* GetNormalizedProperty(LookupResult* result); 1875 Object* GetNormalizedProperty(LookupResult* result);
1862 1876
1863 // Sets the property value in a normalized object given a lookup result. 1877 // Sets the property value in a normalized object given a lookup result.
1864 // Handles the special representation of JS global objects. 1878 // Handles the special representation of JS global objects.
1865 Object* SetNormalizedProperty(LookupResult* result, Object* value); 1879 Object* SetNormalizedProperty(LookupResult* result, Object* value);
1866 1880
1867 // Sets the property value in a normalized object given (key, value, details). 1881 // Sets the property value in a normalized object given (key, value, details).
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
2209 MUST_USE_RESULT MaybeObject* MigrateToMap(Map* new_map); 2223 MUST_USE_RESULT MaybeObject* MigrateToMap(Map* new_map);
2210 MUST_USE_RESULT MaybeObject* GeneralizeFieldRepresentation( 2224 MUST_USE_RESULT MaybeObject* GeneralizeFieldRepresentation(
2211 int modify_index, 2225 int modify_index,
2212 Representation new_representation); 2226 Representation new_representation);
2213 2227
2214 // Add a property to a fast-case object. 2228 // Add a property to a fast-case object.
2215 MUST_USE_RESULT MaybeObject* AddFastProperty( 2229 MUST_USE_RESULT MaybeObject* AddFastProperty(
2216 Name* name, 2230 Name* name,
2217 Object* value, 2231 Object* value,
2218 PropertyAttributes attributes, 2232 PropertyAttributes attributes,
2219 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED); 2233 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED,
2234 ValueType value_type = OPTIMAL_REPRESENTATION);
2220 2235
2221 // Add a property to a slow-case object. 2236 // Add a property to a slow-case object.
2222 MUST_USE_RESULT MaybeObject* AddSlowProperty(Name* name, 2237 MUST_USE_RESULT MaybeObject* AddSlowProperty(Name* name,
2223 Object* value, 2238 Object* value,
2224 PropertyAttributes attributes); 2239 PropertyAttributes attributes);
2225 2240
2226 // Add a property to an object. May cause GC. 2241 // Add a property to an object. May cause GC.
2227 MUST_USE_RESULT MaybeObject* AddProperty( 2242 MUST_USE_RESULT MaybeObject* AddProperty(
2228 Name* name, 2243 Name* name,
2229 Object* value, 2244 Object* value,
2230 PropertyAttributes attributes, 2245 PropertyAttributes attributes,
2231 StrictModeFlag strict_mode, 2246 StrictModeFlag strict_mode,
2232 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, 2247 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED,
2233 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK); 2248 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK,
2249 ValueType value_type = OPTIMAL_REPRESENTATION);
2234 2250
2235 // Convert the object to use the canonical dictionary 2251 // Convert the object to use the canonical dictionary
2236 // representation. If the object is expected to have additional properties 2252 // representation. If the object is expected to have additional properties
2237 // added this number can be indicated to have the backing store allocated to 2253 // added this number can be indicated to have the backing store allocated to
2238 // an initial capacity for holding these properties. 2254 // an initial capacity for holding these properties.
2239 static void NormalizeProperties(Handle<JSObject> object, 2255 static void NormalizeProperties(Handle<JSObject> object,
2240 PropertyNormalizationMode mode, 2256 PropertyNormalizationMode mode,
2241 int expected_additional_properties); 2257 int expected_additional_properties);
2242 2258
2243 MUST_USE_RESULT MaybeObject* NormalizeProperties( 2259 MUST_USE_RESULT MaybeObject* NormalizeProperties(
(...skipping 6271 matching lines...) Expand 10 before | Expand all | Expand 10 after
8515 static const int kKindOffset = kToNumberOffset + kPointerSize; 8531 static const int kKindOffset = kToNumberOffset + kPointerSize;
8516 static const int kSize = kKindOffset + kPointerSize; 8532 static const int kSize = kKindOffset + kPointerSize;
8517 8533
8518 static const byte kFalse = 0; 8534 static const byte kFalse = 0;
8519 static const byte kTrue = 1; 8535 static const byte kTrue = 1;
8520 static const byte kNotBooleanMask = ~1; 8536 static const byte kNotBooleanMask = ~1;
8521 static const byte kTheHole = 2; 8537 static const byte kTheHole = 2;
8522 static const byte kNull = 3; 8538 static const byte kNull = 3;
8523 static const byte kArgumentMarker = 4; 8539 static const byte kArgumentMarker = 4;
8524 static const byte kUndefined = 5; 8540 static const byte kUndefined = 5;
8525 static const byte kOther = 6; 8541 static const byte kUninitialized = 6;
8542 static const byte kOther = 7;
8526 8543
8527 typedef FixedBodyDescriptor<kToStringOffset, 8544 typedef FixedBodyDescriptor<kToStringOffset,
8528 kToNumberOffset + kPointerSize, 8545 kToNumberOffset + kPointerSize,
8529 kSize> BodyDescriptor; 8546 kSize> BodyDescriptor;
8530 8547
8531 STATIC_CHECK(kKindOffset == Internals::kOddballKindOffset); 8548 STATIC_CHECK(kKindOffset == Internals::kOddballKindOffset);
8532 STATIC_CHECK(kNull == Internals::kNullOddballKind); 8549 STATIC_CHECK(kNull == Internals::kNullOddballKind);
8533 STATIC_CHECK(kUndefined == Internals::kUndefinedOddballKind); 8550 STATIC_CHECK(kUndefined == Internals::kUndefinedOddballKind);
8534 8551
8535 private: 8552 private:
(...skipping 1104 matching lines...) Expand 10 before | Expand all | Expand 10 after
9640 } else { 9657 } else {
9641 value &= ~(1 << bit_position); 9658 value &= ~(1 << bit_position);
9642 } 9659 }
9643 return value; 9660 return value;
9644 } 9661 }
9645 }; 9662 };
9646 9663
9647 } } // namespace v8::internal 9664 } } // namespace v8::internal
9648 9665
9649 #endif // V8_OBJECTS_H_ 9666 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698