| OLD | NEW |
| 1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 <iosfwd> | 8 #include <iosfwd> |
| 9 | 9 |
| 10 #include "src/assert-scope.h" | 10 #include "src/assert-scope.h" |
| (...skipping 5831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5842 static const int kPrototypeChainInvalid = 1; | 5842 static const int kPrototypeChainInvalid = 1; |
| 5843 | 5843 |
| 5844 Map* FindRootMap(); | 5844 Map* FindRootMap(); |
| 5845 Map* FindFieldOwner(int descriptor); | 5845 Map* FindFieldOwner(int descriptor); |
| 5846 | 5846 |
| 5847 inline int GetInObjectPropertyOffset(int index); | 5847 inline int GetInObjectPropertyOffset(int index); |
| 5848 | 5848 |
| 5849 int NumberOfFields(); | 5849 int NumberOfFields(); |
| 5850 | 5850 |
| 5851 // TODO(ishell): candidate with JSObject::MigrateToMap(). | 5851 // TODO(ishell): candidate with JSObject::MigrateToMap(). |
| 5852 bool InstancesNeedRewriting(Map* target); |
| 5852 bool InstancesNeedRewriting(Map* target, int target_number_of_fields, | 5853 bool InstancesNeedRewriting(Map* target, int target_number_of_fields, |
| 5853 int target_inobject, int target_unused, | 5854 int target_inobject, int target_unused, |
| 5854 int* old_number_of_fields); | 5855 int* old_number_of_fields); |
| 5855 // TODO(ishell): moveit! | 5856 // TODO(ishell): moveit! |
| 5856 static Handle<Map> GeneralizeAllFieldRepresentations(Handle<Map> map); | 5857 static Handle<Map> GeneralizeAllFieldRepresentations(Handle<Map> map); |
| 5857 MUST_USE_RESULT static Handle<FieldType> GeneralizeFieldType( | 5858 MUST_USE_RESULT static Handle<FieldType> GeneralizeFieldType( |
| 5858 Representation rep1, Handle<FieldType> type1, Representation rep2, | 5859 Representation rep1, Handle<FieldType> type1, Representation rep2, |
| 5859 Handle<FieldType> type2, Isolate* isolate); | 5860 Handle<FieldType> type2, Isolate* isolate); |
| 5860 static void GeneralizeFieldType(Handle<Map> map, int modify_index, | 5861 static void GeneralizeFieldType(Handle<Map> map, int modify_index, |
| 5861 Representation new_representation, | 5862 Representation new_representation, |
| 5862 Handle<FieldType> new_field_type); | 5863 Handle<FieldType> new_field_type); |
| 5863 static Handle<Map> ReconfigureProperty(Handle<Map> map, int modify_index, | 5864 |
| 5864 PropertyKind new_kind, | 5865 static inline Handle<Map> ReconfigureProperty( |
| 5865 PropertyAttributes new_attributes, | 5866 Handle<Map> map, int modify_index, PropertyKind new_kind, |
| 5866 Representation new_representation, | 5867 PropertyAttributes new_attributes, Representation new_representation, |
| 5867 Handle<FieldType> new_field_type, | 5868 Handle<FieldType> new_field_type, StoreMode store_mode); |
| 5868 StoreMode store_mode); | 5869 |
| 5869 static Handle<Map> CopyGeneralizeAllRepresentations( | 5870 static inline Handle<Map> ReconfigureElementsKind( |
| 5870 Handle<Map> map, int modify_index, StoreMode store_mode, | 5871 Handle<Map> map, ElementsKind new_elements_kind); |
| 5871 PropertyKind kind, PropertyAttributes attributes, const char* reason); | |
| 5872 | 5872 |
| 5873 static Handle<Map> PrepareForDataProperty(Handle<Map> old_map, | 5873 static Handle<Map> PrepareForDataProperty(Handle<Map> old_map, |
| 5874 int descriptor_number, | 5874 int descriptor_number, |
| 5875 Handle<Object> value); | 5875 Handle<Object> value); |
| 5876 | 5876 |
| 5877 static Handle<Map> Normalize(Handle<Map> map, PropertyNormalizationMode mode, | 5877 static Handle<Map> Normalize(Handle<Map> map, PropertyNormalizationMode mode, |
| 5878 const char* reason); | 5878 const char* reason); |
| 5879 | 5879 |
| 5880 // Tells whether the map is used for JSObjects in dictionary mode (ie | 5880 // Tells whether the map is used for JSObjects in dictionary mode (ie |
| 5881 // normalized objects, ie objects for which HasFastProperties returns false). | 5881 // normalized objects, ie objects for which HasFastProperties returns false). |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6092 // Returns the non-negative index of the code object if it is in the | 6092 // Returns the non-negative index of the code object if it is in the |
| 6093 // cache and -1 otherwise. | 6093 // cache and -1 otherwise. |
| 6094 int IndexInCodeCache(Object* name, Code* code); | 6094 int IndexInCodeCache(Object* name, Code* code); |
| 6095 | 6095 |
| 6096 // Removes a code object from the code cache at the given index. | 6096 // Removes a code object from the code cache at the given index. |
| 6097 void RemoveFromCodeCache(Name* name, Code* code, int index); | 6097 void RemoveFromCodeCache(Name* name, Code* code, int index); |
| 6098 | 6098 |
| 6099 // Computes a hash value for this map, to be used in HashTables and such. | 6099 // Computes a hash value for this map, to be used in HashTables and such. |
| 6100 int Hash(); | 6100 int Hash(); |
| 6101 | 6101 |
| 6102 // Returns the map that this map transitions to if its elements_kind | |
| 6103 // is changed to |elements_kind|, or NULL if no such map is cached yet. | |
| 6104 // |safe_to_add_transitions| is set to false if adding transitions is not | |
| 6105 // allowed. | |
| 6106 Map* LookupElementsTransitionMap(ElementsKind elements_kind); | |
| 6107 | |
| 6108 // Returns the transitioned map for this map with the most generic | 6102 // Returns the transitioned map for this map with the most generic |
| 6109 // elements_kind that's found in |candidates|, or null handle if no match is | 6103 // elements_kind that's found in |candidates|, or |nullptr| if no match is |
| 6110 // found at all. | 6104 // found at all. |
| 6111 static Handle<Map> FindTransitionedMap(Handle<Map> map, | 6105 Map* FindElementsKindTransitionedMap(MapHandleList* candidates); |
| 6112 MapHandleList* candidates); | |
| 6113 | 6106 |
| 6114 inline bool CanTransition(); | 6107 inline bool CanTransition(); |
| 6115 | 6108 |
| 6116 inline bool IsBooleanMap(); | 6109 inline bool IsBooleanMap(); |
| 6117 inline bool IsPrimitiveMap(); | 6110 inline bool IsPrimitiveMap(); |
| 6118 inline bool IsJSReceiverMap(); | 6111 inline bool IsJSReceiverMap(); |
| 6119 inline bool IsJSObjectMap(); | 6112 inline bool IsJSObjectMap(); |
| 6120 inline bool IsJSArrayMap(); | 6113 inline bool IsJSArrayMap(); |
| 6121 inline bool IsJSFunctionMap(); | 6114 inline bool IsJSFunctionMap(); |
| 6122 inline bool IsStringMap(); | 6115 inline bool IsStringMap(); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6261 #if TRACE_MAPS | 6254 #if TRACE_MAPS |
| 6262 static void TraceTransition(const char* what, Map* from, Map* to, Name* name); | 6255 static void TraceTransition(const char* what, Map* from, Map* to, Name* name); |
| 6263 static void TraceAllTransitions(Map* map); | 6256 static void TraceAllTransitions(Map* map); |
| 6264 #endif | 6257 #endif |
| 6265 | 6258 |
| 6266 static inline Handle<Map> AddMissingTransitionsForTesting( | 6259 static inline Handle<Map> AddMissingTransitionsForTesting( |
| 6267 Handle<Map> split_map, Handle<DescriptorArray> descriptors, | 6260 Handle<Map> split_map, Handle<DescriptorArray> descriptors, |
| 6268 Handle<LayoutDescriptor> full_layout_descriptor); | 6261 Handle<LayoutDescriptor> full_layout_descriptor); |
| 6269 | 6262 |
| 6270 private: | 6263 private: |
| 6264 // Returns the map that this (root) map transitions to if its elements_kind |
| 6265 // is changed to |elements_kind|, or |nullptr| if no such map is cached yet. |
| 6266 Map* LookupElementsTransitionMap(ElementsKind elements_kind); |
| 6267 |
| 6268 // Tries to replay property transitions starting from this (root) map using |
| 6269 // the descriptor array of the |map|. The |root_map| is expected to have |
| 6270 // proper elements kind and therefore elements kinds transitions are not |
| 6271 // taken by this function. Returns |nullptr| if matching transition map is |
| 6272 // not found. |
| 6273 Map* TryReplayPropertyTransitions(Map* map); |
| 6274 |
| 6271 static void ConnectTransition(Handle<Map> parent, Handle<Map> child, | 6275 static void ConnectTransition(Handle<Map> parent, Handle<Map> child, |
| 6272 Handle<Name> name, SimpleTransitionFlag flag); | 6276 Handle<Name> name, SimpleTransitionFlag flag); |
| 6273 | 6277 |
| 6274 bool EquivalentToForTransition(Map* other); | 6278 bool EquivalentToForTransition(Map* other); |
| 6275 static Handle<Map> RawCopy(Handle<Map> map, int instance_size); | 6279 static Handle<Map> RawCopy(Handle<Map> map, int instance_size); |
| 6276 static Handle<Map> ShareDescriptor(Handle<Map> map, | 6280 static Handle<Map> ShareDescriptor(Handle<Map> map, |
| 6277 Handle<DescriptorArray> descriptors, | 6281 Handle<DescriptorArray> descriptors, |
| 6278 Descriptor* descriptor); | 6282 Descriptor* descriptor); |
| 6279 static Handle<Map> AddMissingTransitions( | 6283 static Handle<Map> AddMissingTransitions( |
| 6280 Handle<Map> map, Handle<DescriptorArray> descriptors, | 6284 Handle<Map> map, Handle<DescriptorArray> descriptors, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 6297 Descriptor* descriptor, | 6301 Descriptor* descriptor, |
| 6298 int index, | 6302 int index, |
| 6299 TransitionFlag flag); | 6303 TransitionFlag flag); |
| 6300 static MUST_USE_RESULT MaybeHandle<Map> TryReconfigureExistingProperty( | 6304 static MUST_USE_RESULT MaybeHandle<Map> TryReconfigureExistingProperty( |
| 6301 Handle<Map> map, int descriptor, PropertyKind kind, | 6305 Handle<Map> map, int descriptor, PropertyKind kind, |
| 6302 PropertyAttributes attributes, const char** reason); | 6306 PropertyAttributes attributes, const char** reason); |
| 6303 | 6307 |
| 6304 static Handle<Map> CopyNormalized(Handle<Map> map, | 6308 static Handle<Map> CopyNormalized(Handle<Map> map, |
| 6305 PropertyNormalizationMode mode); | 6309 PropertyNormalizationMode mode); |
| 6306 | 6310 |
| 6311 static Handle<Map> Reconfigure(Handle<Map> map, |
| 6312 ElementsKind new_elements_kind, |
| 6313 int modify_index, PropertyKind new_kind, |
| 6314 PropertyAttributes new_attributes, |
| 6315 Representation new_representation, |
| 6316 Handle<FieldType> new_field_type, |
| 6317 StoreMode store_mode); |
| 6318 |
| 6319 static Handle<Map> CopyGeneralizeAllRepresentations( |
| 6320 Handle<Map> map, ElementsKind elements_kind, int modify_index, |
| 6321 StoreMode store_mode, PropertyKind kind, PropertyAttributes attributes, |
| 6322 const char* reason); |
| 6323 |
| 6307 // Fires when the layout of an object with a leaf map changes. | 6324 // Fires when the layout of an object with a leaf map changes. |
| 6308 // This includes adding transitions to the leaf map or changing | 6325 // This includes adding transitions to the leaf map or changing |
| 6309 // the descriptor array. | 6326 // the descriptor array. |
| 6310 inline void NotifyLeafMapLayoutChange(); | 6327 inline void NotifyLeafMapLayoutChange(); |
| 6311 | 6328 |
| 6312 void DeprecateTransitionTree(); | 6329 void DeprecateTransitionTree(); |
| 6313 | 6330 |
| 6314 void ReplaceDescriptors(DescriptorArray* new_descriptors, | 6331 void ReplaceDescriptors(DescriptorArray* new_descriptors, |
| 6315 LayoutDescriptor* new_layout_descriptor); | 6332 LayoutDescriptor* new_layout_descriptor); |
| 6316 | 6333 |
| (...skipping 4619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10936 } | 10953 } |
| 10937 return value; | 10954 return value; |
| 10938 } | 10955 } |
| 10939 }; | 10956 }; |
| 10940 | 10957 |
| 10941 | 10958 |
| 10942 } // NOLINT, false-positive due to second-order macros. | 10959 } // NOLINT, false-positive due to second-order macros. |
| 10943 } // NOLINT, false-positive due to second-order macros. | 10960 } // NOLINT, false-positive due to second-order macros. |
| 10944 | 10961 |
| 10945 #endif // V8_OBJECTS_H_ | 10962 #endif // V8_OBJECTS_H_ |
| OLD | NEW |