| 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 5755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5766 static const int kPrototypeChainInvalid = 1; | 5766 static const int kPrototypeChainInvalid = 1; |
| 5767 | 5767 |
| 5768 Map* FindRootMap(); | 5768 Map* FindRootMap(); |
| 5769 Map* FindFieldOwner(int descriptor); | 5769 Map* FindFieldOwner(int descriptor); |
| 5770 | 5770 |
| 5771 inline int GetInObjectPropertyOffset(int index); | 5771 inline int GetInObjectPropertyOffset(int index); |
| 5772 | 5772 |
| 5773 int NumberOfFields(); | 5773 int NumberOfFields(); |
| 5774 | 5774 |
| 5775 // TODO(ishell): candidate with JSObject::MigrateToMap(). | 5775 // TODO(ishell): candidate with JSObject::MigrateToMap(). |
| 5776 bool InstancesNeedRewriting(Map* target); |
| 5776 bool InstancesNeedRewriting(Map* target, int target_number_of_fields, | 5777 bool InstancesNeedRewriting(Map* target, int target_number_of_fields, |
| 5777 int target_inobject, int target_unused, | 5778 int target_inobject, int target_unused, |
| 5778 int* old_number_of_fields); | 5779 int* old_number_of_fields); |
| 5779 // TODO(ishell): moveit! | 5780 // TODO(ishell): moveit! |
| 5780 static Handle<Map> GeneralizeAllFieldRepresentations(Handle<Map> map); | 5781 static Handle<Map> GeneralizeAllFieldRepresentations(Handle<Map> map); |
| 5781 MUST_USE_RESULT static Handle<FieldType> GeneralizeFieldType( | 5782 MUST_USE_RESULT static Handle<FieldType> GeneralizeFieldType( |
| 5782 Representation rep1, Handle<FieldType> type1, Representation rep2, | 5783 Representation rep1, Handle<FieldType> type1, Representation rep2, |
| 5783 Handle<FieldType> type2, Isolate* isolate); | 5784 Handle<FieldType> type2, Isolate* isolate); |
| 5784 static void GeneralizeFieldType(Handle<Map> map, int modify_index, | 5785 static void GeneralizeFieldType(Handle<Map> map, int modify_index, |
| 5785 Representation new_representation, | 5786 Representation new_representation, |
| 5786 Handle<FieldType> new_field_type); | 5787 Handle<FieldType> new_field_type); |
| 5787 static Handle<Map> ReconfigureProperty(Handle<Map> map, int modify_index, | 5788 |
| 5788 PropertyKind new_kind, | 5789 static inline Handle<Map> ReconfigureProperty( |
| 5789 PropertyAttributes new_attributes, | 5790 Handle<Map> map, int modify_index, PropertyKind new_kind, |
| 5790 Representation new_representation, | 5791 PropertyAttributes new_attributes, Representation new_representation, |
| 5791 Handle<FieldType> new_field_type, | 5792 Handle<FieldType> new_field_type, StoreMode store_mode); |
| 5792 StoreMode store_mode); | 5793 |
| 5793 static Handle<Map> CopyGeneralizeAllRepresentations( | 5794 static inline Handle<Map> ReconfigureElementsKind( |
| 5794 Handle<Map> map, int modify_index, StoreMode store_mode, | 5795 Handle<Map> map, ElementsKind new_elements_kind); |
| 5795 PropertyKind kind, PropertyAttributes attributes, const char* reason); | |
| 5796 | 5796 |
| 5797 static Handle<Map> PrepareForDataProperty(Handle<Map> old_map, | 5797 static Handle<Map> PrepareForDataProperty(Handle<Map> old_map, |
| 5798 int descriptor_number, | 5798 int descriptor_number, |
| 5799 Handle<Object> value); | 5799 Handle<Object> value); |
| 5800 | 5800 |
| 5801 static Handle<Map> Normalize(Handle<Map> map, PropertyNormalizationMode mode, | 5801 static Handle<Map> Normalize(Handle<Map> map, PropertyNormalizationMode mode, |
| 5802 const char* reason); | 5802 const char* reason); |
| 5803 | 5803 |
| 5804 // Tells whether the map is used for JSObjects in dictionary mode (ie | 5804 // Tells whether the map is used for JSObjects in dictionary mode (ie |
| 5805 // normalized objects, ie objects for which HasFastProperties returns false). | 5805 // normalized objects, ie objects for which HasFastProperties returns false). |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6015 // Returns the non-negative index of the code object if it is in the | 6015 // Returns the non-negative index of the code object if it is in the |
| 6016 // cache and -1 otherwise. | 6016 // cache and -1 otherwise. |
| 6017 int IndexInCodeCache(Object* name, Code* code); | 6017 int IndexInCodeCache(Object* name, Code* code); |
| 6018 | 6018 |
| 6019 // Removes a code object from the code cache at the given index. | 6019 // Removes a code object from the code cache at the given index. |
| 6020 void RemoveFromCodeCache(Name* name, Code* code, int index); | 6020 void RemoveFromCodeCache(Name* name, Code* code, int index); |
| 6021 | 6021 |
| 6022 // Computes a hash value for this map, to be used in HashTables and such. | 6022 // Computes a hash value for this map, to be used in HashTables and such. |
| 6023 int Hash(); | 6023 int Hash(); |
| 6024 | 6024 |
| 6025 // Returns the map that this map transitions to if its elements_kind | |
| 6026 // is changed to |elements_kind|, or NULL if no such map is cached yet. | |
| 6027 // |safe_to_add_transitions| is set to false if adding transitions is not | |
| 6028 // allowed. | |
| 6029 Map* LookupElementsTransitionMap(ElementsKind elements_kind); | |
| 6030 | |
| 6031 // Returns the transitioned map for this map with the most generic | 6025 // Returns the transitioned map for this map with the most generic |
| 6032 // elements_kind that's found in |candidates|, or null handle if no match is | 6026 // elements_kind that's found in |candidates|, or |nullptr| if no match is |
| 6033 // found at all. | 6027 // found at all. |
| 6034 static Handle<Map> FindTransitionedMap(Handle<Map> map, | 6028 Map* FindElementsKindTransitionedMap(MapHandleList* candidates); |
| 6035 MapHandleList* candidates); | |
| 6036 | 6029 |
| 6037 inline bool CanTransition(); | 6030 inline bool CanTransition(); |
| 6038 | 6031 |
| 6039 inline bool IsBooleanMap(); | 6032 inline bool IsBooleanMap(); |
| 6040 inline bool IsPrimitiveMap(); | 6033 inline bool IsPrimitiveMap(); |
| 6041 inline bool IsJSReceiverMap(); | 6034 inline bool IsJSReceiverMap(); |
| 6042 inline bool IsJSObjectMap(); | 6035 inline bool IsJSObjectMap(); |
| 6043 inline bool IsJSArrayMap(); | 6036 inline bool IsJSArrayMap(); |
| 6044 inline bool IsJSFunctionMap(); | 6037 inline bool IsJSFunctionMap(); |
| 6045 inline bool IsStringMap(); | 6038 inline bool IsStringMap(); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6184 #if TRACE_MAPS | 6177 #if TRACE_MAPS |
| 6185 static void TraceTransition(const char* what, Map* from, Map* to, Name* name); | 6178 static void TraceTransition(const char* what, Map* from, Map* to, Name* name); |
| 6186 static void TraceAllTransitions(Map* map); | 6179 static void TraceAllTransitions(Map* map); |
| 6187 #endif | 6180 #endif |
| 6188 | 6181 |
| 6189 static inline Handle<Map> AddMissingTransitionsForTesting( | 6182 static inline Handle<Map> AddMissingTransitionsForTesting( |
| 6190 Handle<Map> split_map, Handle<DescriptorArray> descriptors, | 6183 Handle<Map> split_map, Handle<DescriptorArray> descriptors, |
| 6191 Handle<LayoutDescriptor> full_layout_descriptor); | 6184 Handle<LayoutDescriptor> full_layout_descriptor); |
| 6192 | 6185 |
| 6193 private: | 6186 private: |
| 6187 // Returns the map that this (root) map transitions to if its elements_kind |
| 6188 // is changed to |elements_kind|, or |nullptr| if no such map is cached yet. |
| 6189 Map* LookupElementsTransitionMap(ElementsKind elements_kind); |
| 6190 |
| 6191 // Tries to replay property transitions starting from this (root) map using |
| 6192 // the descriptor array of the |map|. The |root_map| is expected to have |
| 6193 // proper elements kind and therefore elements kinds transitions are not |
| 6194 // taken by this function. Returns |nullptr| if matching transition map is |
| 6195 // not found. |
| 6196 Map* TryReplayPropertyTransitions(Map* map); |
| 6197 |
| 6194 static void ConnectTransition(Handle<Map> parent, Handle<Map> child, | 6198 static void ConnectTransition(Handle<Map> parent, Handle<Map> child, |
| 6195 Handle<Name> name, SimpleTransitionFlag flag); | 6199 Handle<Name> name, SimpleTransitionFlag flag); |
| 6196 | 6200 |
| 6197 bool EquivalentToForTransition(Map* other); | 6201 bool EquivalentToForTransition(Map* other); |
| 6198 static Handle<Map> RawCopy(Handle<Map> map, int instance_size); | 6202 static Handle<Map> RawCopy(Handle<Map> map, int instance_size); |
| 6199 static Handle<Map> ShareDescriptor(Handle<Map> map, | 6203 static Handle<Map> ShareDescriptor(Handle<Map> map, |
| 6200 Handle<DescriptorArray> descriptors, | 6204 Handle<DescriptorArray> descriptors, |
| 6201 Descriptor* descriptor); | 6205 Descriptor* descriptor); |
| 6202 static Handle<Map> AddMissingTransitions( | 6206 static Handle<Map> AddMissingTransitions( |
| 6203 Handle<Map> map, Handle<DescriptorArray> descriptors, | 6207 Handle<Map> map, Handle<DescriptorArray> descriptors, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 6220 Descriptor* descriptor, | 6224 Descriptor* descriptor, |
| 6221 int index, | 6225 int index, |
| 6222 TransitionFlag flag); | 6226 TransitionFlag flag); |
| 6223 static MUST_USE_RESULT MaybeHandle<Map> TryReconfigureExistingProperty( | 6227 static MUST_USE_RESULT MaybeHandle<Map> TryReconfigureExistingProperty( |
| 6224 Handle<Map> map, int descriptor, PropertyKind kind, | 6228 Handle<Map> map, int descriptor, PropertyKind kind, |
| 6225 PropertyAttributes attributes, const char** reason); | 6229 PropertyAttributes attributes, const char** reason); |
| 6226 | 6230 |
| 6227 static Handle<Map> CopyNormalized(Handle<Map> map, | 6231 static Handle<Map> CopyNormalized(Handle<Map> map, |
| 6228 PropertyNormalizationMode mode); | 6232 PropertyNormalizationMode mode); |
| 6229 | 6233 |
| 6234 static Handle<Map> Reconfigure(Handle<Map> map, |
| 6235 ElementsKind new_elements_kind, |
| 6236 int modify_index, PropertyKind new_kind, |
| 6237 PropertyAttributes new_attributes, |
| 6238 Representation new_representation, |
| 6239 Handle<FieldType> new_field_type, |
| 6240 StoreMode store_mode); |
| 6241 |
| 6242 static Handle<Map> CopyGeneralizeAllRepresentations( |
| 6243 Handle<Map> map, ElementsKind elements_kind, int modify_index, |
| 6244 StoreMode store_mode, PropertyKind kind, PropertyAttributes attributes, |
| 6245 const char* reason); |
| 6246 |
| 6230 // Fires when the layout of an object with a leaf map changes. | 6247 // Fires when the layout of an object with a leaf map changes. |
| 6231 // This includes adding transitions to the leaf map or changing | 6248 // This includes adding transitions to the leaf map or changing |
| 6232 // the descriptor array. | 6249 // the descriptor array. |
| 6233 inline void NotifyLeafMapLayoutChange(); | 6250 inline void NotifyLeafMapLayoutChange(); |
| 6234 | 6251 |
| 6235 void DeprecateTransitionTree(); | 6252 void DeprecateTransitionTree(); |
| 6236 | 6253 |
| 6237 void ReplaceDescriptors(DescriptorArray* new_descriptors, | 6254 void ReplaceDescriptors(DescriptorArray* new_descriptors, |
| 6238 LayoutDescriptor* new_layout_descriptor); | 6255 LayoutDescriptor* new_layout_descriptor); |
| 6239 | 6256 |
| (...skipping 4595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10835 } | 10852 } |
| 10836 return value; | 10853 return value; |
| 10837 } | 10854 } |
| 10838 }; | 10855 }; |
| 10839 | 10856 |
| 10840 | 10857 |
| 10841 } // NOLINT, false-positive due to second-order macros. | 10858 } // NOLINT, false-positive due to second-order macros. |
| 10842 } // NOLINT, false-positive due to second-order macros. | 10859 } // NOLINT, false-positive due to second-order macros. |
| 10843 | 10860 |
| 10844 #endif // V8_OBJECTS_H_ | 10861 #endif // V8_OBJECTS_H_ |
| OLD | NEW |