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

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: 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
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 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 inline Representation OptimalRepresentation() {
1064 if (FLAG_track_fields && IsSmi()) { 1064 if (FLAG_track_fields && IsSmi()) {
1065 return Representation::Smi(); 1065 return Representation::Smi();
1066 } else if (FLAG_track_double_fields && IsHeapNumber()) { 1066 } else if (FLAG_track_double_fields && IsHeapNumber()) {
1067 return Representation::Double(); 1067 return Representation::Double();
1068 } else if (FLAG_track_heap_object_fields && !IsUndefined()) { 1068 } 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()); 1069 ASSERT(IsHeapObject());
1074 return Representation::HeapObject(); 1070 return Representation::HeapObject();
1075 } else { 1071 } else {
1076 return Representation::Tagged(); 1072 return Representation::Tagged();
1077 } 1073 }
1078 } 1074 }
1079 1075
1080 inline bool FitsRepresentation(Representation representation) { 1076 inline bool FitsRepresentation(Representation representation) {
1081 if (FLAG_track_fields && representation.IsSmi()) { 1077 if (FLAG_track_fields && representation.IsNone()) {
1078 return false;
1079 } else if (FLAG_track_fields && representation.IsSmi()) {
1082 return IsSmi(); 1080 return IsSmi();
1083 } else if (FLAG_track_double_fields && representation.IsDouble()) { 1081 } else if (FLAG_track_double_fields && representation.IsDouble()) {
1084 return IsNumber(); 1082 return IsNumber();
1085 } else if (FLAG_track_heap_object_fields && representation.IsHeapObject()) { 1083 } else if (FLAG_track_heap_object_fields && representation.IsHeapObject()) {
1086 return IsHeapObject(); 1084 return IsHeapObject();
1087 } 1085 }
1088 return true; 1086 return true;
1089 } 1087 }
1090 1088
1091 inline MaybeObject* AllocateNewStorageFor(Heap* heap, 1089 inline MaybeObject* AllocateNewStorageFor(Heap* heap,
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 CERTAINLY_NOT_STORE_FROM_KEYED 1592 CERTAINLY_NOT_STORE_FROM_KEYED
1595 }; 1593 };
1596 1594
1597 // Internal properties (e.g. the hidden properties dictionary) might 1595 // Internal properties (e.g. the hidden properties dictionary) might
1598 // be added even though the receiver is non-extensible. 1596 // be added even though the receiver is non-extensible.
1599 enum ExtensibilityCheck { 1597 enum ExtensibilityCheck {
1600 PERFORM_EXTENSIBILITY_CHECK, 1598 PERFORM_EXTENSIBILITY_CHECK,
1601 OMIT_EXTENSIBILITY_CHECK 1599 OMIT_EXTENSIBILITY_CHECK
1602 }; 1600 };
1603 1601
1602 enum ValueType {
danno 2013/06/06 07:54:19 A comment about the enum and the purpose of its va
Toon Verwaest 2013/06/06 10:31:41 Done.
1603 REAL_VALUE,
1604 PLACEHOLDER_VALUE,
1605 FORCE_TAGGED
1606 };
1607
1604 // Casting. 1608 // Casting.
1605 static inline JSReceiver* cast(Object* obj); 1609 static inline JSReceiver* cast(Object* obj);
1606 1610
1607 static Handle<Object> SetProperty(Handle<JSReceiver> object, 1611 static Handle<Object> SetProperty(Handle<JSReceiver> object,
1608 Handle<Name> key, 1612 Handle<Name> key,
1609 Handle<Object> value, 1613 Handle<Object> value,
1610 PropertyAttributes attributes, 1614 PropertyAttributes attributes,
1611 StrictModeFlag strict_mode); 1615 StrictModeFlag strict_mode);
1612 1616
1613 MUST_USE_RESULT static MaybeObject* SetPropertyOrFail( 1617 MUST_USE_RESULT static MaybeObject* SetPropertyOrFail(
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1820 Name* name, 1824 Name* name,
1821 Object* value, 1825 Object* value,
1822 PropertyAttributes attributes, 1826 PropertyAttributes attributes,
1823 StrictModeFlag strict_mode, 1827 StrictModeFlag strict_mode,
1824 ExtensibilityCheck extensibility_check); 1828 ExtensibilityCheck extensibility_check);
1825 1829
1826 static Handle<Object> SetLocalPropertyIgnoreAttributes( 1830 static Handle<Object> SetLocalPropertyIgnoreAttributes(
1827 Handle<JSObject> object, 1831 Handle<JSObject> object,
1828 Handle<Name> key, 1832 Handle<Name> key,
1829 Handle<Object> value, 1833 Handle<Object> value,
1830 PropertyAttributes attributes); 1834 PropertyAttributes attributes,
1835 ValueType value_type = REAL_VALUE);
1831 1836
1832 static inline Handle<String> ExpectedTransitionKey(Handle<Map> map); 1837 static inline Handle<String> ExpectedTransitionKey(Handle<Map> map);
1833 static inline Handle<Map> ExpectedTransitionTarget(Handle<Map> map); 1838 static inline Handle<Map> ExpectedTransitionTarget(Handle<Map> map);
1834 1839
1835 // Try to follow an existing transition to a field with attributes NONE. The 1840 // Try to follow an existing transition to a field with attributes NONE. The
1836 // return value indicates whether the transition was successful. 1841 // return value indicates whether the transition was successful.
1837 static inline Handle<Map> FindTransitionToField(Handle<Map> map, 1842 static inline Handle<Map> FindTransitionToField(Handle<Map> map,
1838 Handle<Name> key); 1843 Handle<Name> key);
1839 1844
1840 inline int LastAddedFieldIndex(); 1845 inline int LastAddedFieldIndex();
1841 1846
1842 // Extend the receiver with a single fast property appeared first in the 1847 // Extend the receiver with a single fast property appeared first in the
1843 // passed map. This also extends the property backing store if necessary. 1848 // passed map. This also extends the property backing store if necessary.
1844 static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map); 1849 static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map);
1845 inline MUST_USE_RESULT MaybeObject* AllocateStorageForMap(Map* map); 1850 inline MUST_USE_RESULT MaybeObject* AllocateStorageForMap(Map* map);
1846 1851
1847 static void MigrateInstance(Handle<JSObject> instance); 1852 static void MigrateInstance(Handle<JSObject> instance);
1848 inline MUST_USE_RESULT MaybeObject* MigrateInstance(); 1853 inline MUST_USE_RESULT MaybeObject* MigrateInstance();
1849 1854
1850 static Handle<Object> TryMigrateInstance(Handle<JSObject> instance); 1855 static Handle<Object> TryMigrateInstance(Handle<JSObject> instance);
1851 inline MUST_USE_RESULT MaybeObject* TryMigrateInstance(); 1856 inline MUST_USE_RESULT MaybeObject* TryMigrateInstance();
1852 1857
1853 // Can cause GC. 1858 // Can cause GC.
1854 MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributes( 1859 MUST_USE_RESULT MaybeObject* SetLocalPropertyIgnoreAttributes(
1855 Name* key, 1860 Name* key,
1856 Object* value, 1861 Object* value,
1857 PropertyAttributes attributes); 1862 PropertyAttributes attributes,
1863 ValueType value_type = REAL_VALUE);
1858 1864
1859 // Retrieve a value in a normalized object given a lookup result. 1865 // Retrieve a value in a normalized object given a lookup result.
1860 // Handles the special representation of JS global objects. 1866 // Handles the special representation of JS global objects.
1861 Object* GetNormalizedProperty(LookupResult* result); 1867 Object* GetNormalizedProperty(LookupResult* result);
1862 1868
1863 // Sets the property value in a normalized object given a lookup result. 1869 // Sets the property value in a normalized object given a lookup result.
1864 // Handles the special representation of JS global objects. 1870 // Handles the special representation of JS global objects.
1865 Object* SetNormalizedProperty(LookupResult* result, Object* value); 1871 Object* SetNormalizedProperty(LookupResult* result, Object* value);
1866 1872
1867 // Sets the property value in a normalized object given (key, value, details). 1873 // 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); 2215 MUST_USE_RESULT MaybeObject* MigrateToMap(Map* new_map);
2210 MUST_USE_RESULT MaybeObject* GeneralizeFieldRepresentation( 2216 MUST_USE_RESULT MaybeObject* GeneralizeFieldRepresentation(
2211 int modify_index, 2217 int modify_index,
2212 Representation new_representation); 2218 Representation new_representation);
2213 2219
2214 // Add a property to a fast-case object. 2220 // Add a property to a fast-case object.
2215 MUST_USE_RESULT MaybeObject* AddFastProperty( 2221 MUST_USE_RESULT MaybeObject* AddFastProperty(
2216 Name* name, 2222 Name* name,
2217 Object* value, 2223 Object* value,
2218 PropertyAttributes attributes, 2224 PropertyAttributes attributes,
2219 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED); 2225 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED,
2226 ValueType value_type = REAL_VALUE);
2220 2227
2221 // Add a property to a slow-case object. 2228 // Add a property to a slow-case object.
2222 MUST_USE_RESULT MaybeObject* AddSlowProperty(Name* name, 2229 MUST_USE_RESULT MaybeObject* AddSlowProperty(Name* name,
2223 Object* value, 2230 Object* value,
2224 PropertyAttributes attributes); 2231 PropertyAttributes attributes);
2225 2232
2226 // Add a property to an object. May cause GC. 2233 // Add a property to an object. May cause GC.
2227 MUST_USE_RESULT MaybeObject* AddProperty( 2234 MUST_USE_RESULT MaybeObject* AddProperty(
2228 Name* name, 2235 Name* name,
2229 Object* value, 2236 Object* value,
2230 PropertyAttributes attributes, 2237 PropertyAttributes attributes,
2231 StrictModeFlag strict_mode, 2238 StrictModeFlag strict_mode,
2232 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, 2239 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED,
2233 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK); 2240 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK,
2241 ValueType value_type = REAL_VALUE);
2234 2242
2235 // Convert the object to use the canonical dictionary 2243 // Convert the object to use the canonical dictionary
2236 // representation. If the object is expected to have additional properties 2244 // representation. If the object is expected to have additional properties
2237 // added this number can be indicated to have the backing store allocated to 2245 // added this number can be indicated to have the backing store allocated to
2238 // an initial capacity for holding these properties. 2246 // an initial capacity for holding these properties.
2239 static void NormalizeProperties(Handle<JSObject> object, 2247 static void NormalizeProperties(Handle<JSObject> object,
2240 PropertyNormalizationMode mode, 2248 PropertyNormalizationMode mode,
2241 int expected_additional_properties); 2249 int expected_additional_properties);
2242 2250
2243 MUST_USE_RESULT MaybeObject* NormalizeProperties( 2251 MUST_USE_RESULT MaybeObject* NormalizeProperties(
(...skipping 7396 matching lines...) Expand 10 before | Expand all | Expand 10 after
9640 } else { 9648 } else {
9641 value &= ~(1 << bit_position); 9649 value &= ~(1 << bit_position);
9642 } 9650 }
9643 return value; 9651 return value;
9644 } 9652 }
9645 }; 9653 };
9646 9654
9647 } } // namespace v8::internal 9655 } } // namespace v8::internal
9648 9656
9649 #endif // V8_OBJECTS_H_ 9657 #endif // V8_OBJECTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698