OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/assert-scope.h" | 9 #include "src/assert-scope.h" |
10 #include "src/builtins.h" | 10 #include "src/builtins.h" |
(...skipping 2138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2149 Handle<JSObject> object, | 2149 Handle<JSObject> object, |
2150 Handle<Name> key, | 2150 Handle<Name> key, |
2151 Handle<Object> value, | 2151 Handle<Object> value, |
2152 PropertyAttributes attributes, | 2152 PropertyAttributes attributes, |
2153 ValueType value_type = OPTIMAL_REPRESENTATION, | 2153 ValueType value_type = OPTIMAL_REPRESENTATION, |
2154 StoreMode mode = ALLOW_AS_CONSTANT, | 2154 StoreMode mode = ALLOW_AS_CONSTANT, |
2155 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK, | 2155 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK, |
2156 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, | 2156 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, |
2157 ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING); | 2157 ExecutableAccessorInfoHandling handling = DEFAULT_HANDLING); |
2158 | 2158 |
2159 static inline Handle<String> ExpectedTransitionKey(Handle<Map> map); | |
2160 static inline Handle<Map> ExpectedTransitionTarget(Handle<Map> map); | |
2161 | |
2162 // Try to follow an existing transition to a field with attributes NONE. The | |
2163 // return value indicates whether the transition was successful. | |
2164 static inline Handle<Map> FindTransitionToField(Handle<Map> map, | |
2165 Handle<Name> key); | |
2166 | |
2167 // Extend the receiver with a single fast property appeared first in the | 2159 // Extend the receiver with a single fast property appeared first in the |
2168 // passed map. This also extends the property backing store if necessary. | 2160 // passed map. This also extends the property backing store if necessary. |
2169 static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map); | 2161 static void AllocateStorageForMap(Handle<JSObject> object, Handle<Map> map); |
2170 | 2162 |
2171 // Migrates the given object to a map whose field representations are the | 2163 // Migrates the given object to a map whose field representations are the |
2172 // lowest upper bound of all known representations for that field. | 2164 // lowest upper bound of all known representations for that field. |
2173 static void MigrateInstance(Handle<JSObject> instance); | 2165 static void MigrateInstance(Handle<JSObject> instance); |
2174 | 2166 |
2175 // Migrates the given object only if the target map is already available, | 2167 // Migrates the given object only if the target map is already available, |
2176 // or returns false if such a map is not yet available. | 2168 // or returns false if such a map is not yet available. |
(...skipping 4060 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6237 static bool IsValidElementsTransition(ElementsKind from_kind, | 6229 static bool IsValidElementsTransition(ElementsKind from_kind, |
6238 ElementsKind to_kind); | 6230 ElementsKind to_kind); |
6239 | 6231 |
6240 // Returns true if the current map doesn't have DICTIONARY_ELEMENTS but if a | 6232 // Returns true if the current map doesn't have DICTIONARY_ELEMENTS but if a |
6241 // map with DICTIONARY_ELEMENTS was found in the prototype chain. | 6233 // map with DICTIONARY_ELEMENTS was found in the prototype chain. |
6242 bool DictionaryElementsInPrototypeChainOnly(); | 6234 bool DictionaryElementsInPrototypeChainOnly(); |
6243 | 6235 |
6244 inline bool HasTransitionArray() const; | 6236 inline bool HasTransitionArray() const; |
6245 inline bool HasElementsTransition(); | 6237 inline bool HasElementsTransition(); |
6246 inline Map* elements_transition_map(); | 6238 inline Map* elements_transition_map(); |
6247 static Handle<TransitionArray> SetElementsTransitionMap( | 6239 |
6248 Handle<Map> map, Handle<Map> transitioned_map); | |
6249 inline Map* GetTransition(int transition_index); | 6240 inline Map* GetTransition(int transition_index); |
6250 inline int SearchTransition(Name* name); | 6241 inline int SearchTransition(Name* name); |
6251 inline FixedArrayBase* GetInitialElements(); | 6242 inline FixedArrayBase* GetInitialElements(); |
6252 | 6243 |
6253 DECL_ACCESSORS(transitions, TransitionArray) | 6244 DECL_ACCESSORS(transitions, TransitionArray) |
6254 | 6245 |
| 6246 static inline Handle<String> ExpectedTransitionKey(Handle<Map> map); |
| 6247 static inline Handle<Map> ExpectedTransitionTarget(Handle<Map> map); |
| 6248 |
| 6249 // Try to follow an existing transition to a field with attributes NONE. The |
| 6250 // return value indicates whether the transition was successful. |
| 6251 static inline Handle<Map> FindTransitionToField(Handle<Map> map, |
| 6252 Handle<Name> key); |
| 6253 |
6255 Map* FindRootMap(); | 6254 Map* FindRootMap(); |
6256 Map* FindFieldOwner(int descriptor); | 6255 Map* FindFieldOwner(int descriptor); |
6257 | 6256 |
6258 inline int GetInObjectPropertyOffset(int index); | 6257 inline int GetInObjectPropertyOffset(int index); |
6259 | 6258 |
6260 int NumberOfFields(); | 6259 int NumberOfFields(); |
6261 | 6260 |
| 6261 // TODO(ishell): candidate with JSObject::MigrateToMap(). |
6262 bool InstancesNeedRewriting(Map* target, | 6262 bool InstancesNeedRewriting(Map* target, |
6263 int target_number_of_fields, | 6263 int target_number_of_fields, |
6264 int target_inobject, | 6264 int target_inobject, |
6265 int target_unused); | 6265 int target_unused); |
| 6266 // TODO(ishell): moveit! |
6266 static Handle<Map> GeneralizeAllFieldRepresentations(Handle<Map> map); | 6267 static Handle<Map> GeneralizeAllFieldRepresentations(Handle<Map> map); |
6267 static Handle<HeapType> GeneralizeFieldType(Handle<HeapType> type1, | 6268 MUST_USE_RESULT static Handle<HeapType> GeneralizeFieldType( |
6268 Handle<HeapType> type2, | 6269 Handle<HeapType> type1, |
6269 Isolate* isolate) | 6270 Handle<HeapType> type2, |
6270 V8_WARN_UNUSED_RESULT; | 6271 Isolate* isolate); |
6271 static void GeneralizeFieldType(Handle<Map> map, | 6272 static void GeneralizeFieldType(Handle<Map> map, |
6272 int modify_index, | 6273 int modify_index, |
6273 Handle<HeapType> new_field_type); | 6274 Handle<HeapType> new_field_type); |
6274 static Handle<Map> GeneralizeRepresentation( | 6275 static Handle<Map> GeneralizeRepresentation( |
6275 Handle<Map> map, | 6276 Handle<Map> map, |
6276 int modify_index, | 6277 int modify_index, |
6277 Representation new_representation, | 6278 Representation new_representation, |
6278 Handle<HeapType> new_field_type, | 6279 Handle<HeapType> new_field_type, |
6279 StoreMode store_mode); | 6280 StoreMode store_mode); |
6280 static Handle<Map> CopyGeneralizeAllRepresentations( | 6281 static Handle<Map> CopyGeneralizeAllRepresentations( |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6545 // Returns the map that this map transitions to if its elements_kind | 6546 // Returns the map that this map transitions to if its elements_kind |
6546 // is changed to |elements_kind|, or NULL if no such map is cached yet. | 6547 // is changed to |elements_kind|, or NULL if no such map is cached yet. |
6547 // |safe_to_add_transitions| is set to false if adding transitions is not | 6548 // |safe_to_add_transitions| is set to false if adding transitions is not |
6548 // allowed. | 6549 // allowed. |
6549 Map* LookupElementsTransitionMap(ElementsKind elements_kind); | 6550 Map* LookupElementsTransitionMap(ElementsKind elements_kind); |
6550 | 6551 |
6551 // Returns the transitioned map for this map with the most generic | 6552 // Returns the transitioned map for this map with the most generic |
6552 // elements_kind that's found in |candidates|, or null handle if no match is | 6553 // elements_kind that's found in |candidates|, or null handle if no match is |
6553 // found at all. | 6554 // found at all. |
6554 Handle<Map> FindTransitionedMap(MapHandleList* candidates); | 6555 Handle<Map> FindTransitionedMap(MapHandleList* candidates); |
6555 Map* FindTransitionedMap(MapList* candidates); | |
6556 | 6556 |
6557 bool CanTransition() { | 6557 bool CanTransition() { |
6558 // Only JSObject and subtypes have map transitions and back pointers. | 6558 // Only JSObject and subtypes have map transitions and back pointers. |
6559 STATIC_ASSERT(LAST_TYPE == LAST_JS_OBJECT_TYPE); | 6559 STATIC_ASSERT(LAST_TYPE == LAST_JS_OBJECT_TYPE); |
6560 return instance_type() >= FIRST_JS_OBJECT_TYPE; | 6560 return instance_type() >= FIRST_JS_OBJECT_TYPE; |
6561 } | 6561 } |
6562 | 6562 |
6563 bool IsJSObjectMap() { | 6563 bool IsJSObjectMap() { |
6564 return instance_type() >= FIRST_JS_OBJECT_TYPE; | 6564 return instance_type() >= FIRST_JS_OBJECT_TYPE; |
6565 } | 6565 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6707 kPointerFieldsEndOffset, | 6707 kPointerFieldsEndOffset, |
6708 kSize> BodyDescriptor; | 6708 kSize> BodyDescriptor; |
6709 | 6709 |
6710 // Compares this map to another to see if they describe equivalent objects. | 6710 // Compares this map to another to see if they describe equivalent objects. |
6711 // If |mode| is set to CLEAR_INOBJECT_PROPERTIES, |other| is treated as if | 6711 // If |mode| is set to CLEAR_INOBJECT_PROPERTIES, |other| is treated as if |
6712 // it had exactly zero inobject properties. | 6712 // it had exactly zero inobject properties. |
6713 // The "shared" flags of both this map and |other| are ignored. | 6713 // The "shared" flags of both this map and |other| are ignored. |
6714 bool EquivalentToForNormalization(Map* other, PropertyNormalizationMode mode); | 6714 bool EquivalentToForNormalization(Map* other, PropertyNormalizationMode mode); |
6715 | 6715 |
6716 private: | 6716 private: |
| 6717 static Handle<TransitionArray> SetElementsTransitionMap( |
| 6718 Handle<Map> map, Handle<Map> transitioned_map); |
| 6719 |
6717 bool EquivalentToForTransition(Map* other); | 6720 bool EquivalentToForTransition(Map* other); |
6718 static Handle<Map> RawCopy(Handle<Map> map, int instance_size); | 6721 static Handle<Map> RawCopy(Handle<Map> map, int instance_size); |
6719 static Handle<Map> ShareDescriptor(Handle<Map> map, | 6722 static Handle<Map> ShareDescriptor(Handle<Map> map, |
6720 Handle<DescriptorArray> descriptors, | 6723 Handle<DescriptorArray> descriptors, |
6721 Descriptor* descriptor); | 6724 Descriptor* descriptor); |
6722 static Handle<Map> CopyInstallDescriptors( | 6725 static Handle<Map> CopyInstallDescriptors( |
6723 Handle<Map> map, | 6726 Handle<Map> map, |
6724 int new_descriptor, | 6727 int new_descriptor, |
6725 Handle<DescriptorArray> descriptors); | 6728 Handle<DescriptorArray> descriptors); |
6726 static Handle<Map> CopyAddDescriptor(Handle<Map> map, | 6729 static Handle<Map> CopyAddDescriptor(Handle<Map> map, |
(...skipping 4438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11165 } else { | 11168 } else { |
11166 value &= ~(1 << bit_position); | 11169 value &= ~(1 << bit_position); |
11167 } | 11170 } |
11168 return value; | 11171 return value; |
11169 } | 11172 } |
11170 }; | 11173 }; |
11171 | 11174 |
11172 } } // namespace v8::internal | 11175 } } // namespace v8::internal |
11173 | 11176 |
11174 #endif // V8_OBJECTS_H_ | 11177 #endif // V8_OBJECTS_H_ |
OLD | NEW |