| OLD | NEW |
| 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 2168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2179 // fixed_cow_array_map (for copy-on-write arrays). In the latter case | 2179 // fixed_cow_array_map (for copy-on-write arrays). In the latter case |
| 2180 // the elements array may be shared by a few objects and so before | 2180 // the elements array may be shared by a few objects and so before |
| 2181 // writing to any element the array must be copied. Use | 2181 // writing to any element the array must be copied. Use |
| 2182 // EnsureWritableFastElements in this case. | 2182 // EnsureWritableFastElements in this case. |
| 2183 // | 2183 // |
| 2184 // In the slow mode the elements is either a NumberDictionary, an | 2184 // In the slow mode the elements is either a NumberDictionary, an |
| 2185 // ExternalArray, or a FixedArray parameter map for a (sloppy) | 2185 // ExternalArray, or a FixedArray parameter map for a (sloppy) |
| 2186 // arguments object. | 2186 // arguments object. |
| 2187 DECL_ACCESSORS(elements, FixedArrayBase) | 2187 DECL_ACCESSORS(elements, FixedArrayBase) |
| 2188 inline void initialize_elements(); | 2188 inline void initialize_elements(); |
| 2189 MUST_USE_RESULT inline MaybeObject* ResetElements(); | |
| 2190 static void ResetElements(Handle<JSObject> object); | 2189 static void ResetElements(Handle<JSObject> object); |
| 2191 static inline void SetMapAndElements(Handle<JSObject> object, | 2190 static inline void SetMapAndElements(Handle<JSObject> object, |
| 2192 Handle<Map> map, | 2191 Handle<Map> map, |
| 2193 Handle<FixedArrayBase> elements); | 2192 Handle<FixedArrayBase> elements); |
| 2194 inline ElementsKind GetElementsKind(); | 2193 inline ElementsKind GetElementsKind(); |
| 2195 inline ElementsAccessor* GetElementsAccessor(); | 2194 inline ElementsAccessor* GetElementsAccessor(); |
| 2196 // Returns true if an object has elements of FAST_SMI_ELEMENTS ElementsKind. | 2195 // Returns true if an object has elements of FAST_SMI_ELEMENTS ElementsKind. |
| 2197 inline bool HasFastSmiElements(); | 2196 inline bool HasFastSmiElements(); |
| 2198 // Returns true if an object has elements of FAST_ELEMENTS ElementsKind. | 2197 // Returns true if an object has elements of FAST_ELEMENTS ElementsKind. |
| 2199 inline bool HasFastObjectElements(); | 2198 inline bool HasFastObjectElements(); |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2573 // (storage->length() == NumberOfEnumElements()). | 2572 // (storage->length() == NumberOfEnumElements()). |
| 2574 // If storage is NULL, will count the elements without adding | 2573 // If storage is NULL, will count the elements without adding |
| 2575 // them to any storage. | 2574 // them to any storage. |
| 2576 // Returns the number of enumerable elements. | 2575 // Returns the number of enumerable elements. |
| 2577 int GetEnumElementKeys(FixedArray* storage); | 2576 int GetEnumElementKeys(FixedArray* storage); |
| 2578 | 2577 |
| 2579 // Returns a new map with all transitions dropped from the object's current | 2578 // Returns a new map with all transitions dropped from the object's current |
| 2580 // map and the ElementsKind set. | 2579 // map and the ElementsKind set. |
| 2581 static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object, | 2580 static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object, |
| 2582 ElementsKind to_kind); | 2581 ElementsKind to_kind); |
| 2583 inline MUST_USE_RESULT MaybeObject* GetElementsTransitionMap( | 2582 static Handle<Map> GetElementsTransitionMapSlow(Handle<JSObject> object, |
| 2584 Isolate* isolate, | 2583 ElementsKind elements_kind); |
| 2585 ElementsKind elements_kind); | |
| 2586 MUST_USE_RESULT MaybeObject* GetElementsTransitionMapSlow( | |
| 2587 ElementsKind elements_kind); | |
| 2588 | 2584 |
| 2589 static void TransitionElementsKind(Handle<JSObject> object, | 2585 static void TransitionElementsKind(Handle<JSObject> object, |
| 2590 ElementsKind to_kind); | 2586 ElementsKind to_kind); |
| 2591 | 2587 |
| 2592 // TODO(mstarzinger): Both public because of ConvertAnsSetLocalProperty(). | 2588 // TODO(mstarzinger): Both public because of ConvertAnsSetLocalProperty(). |
| 2593 static void MigrateToMap(Handle<JSObject> object, Handle<Map> new_map); | 2589 static void MigrateToMap(Handle<JSObject> object, Handle<Map> new_map); |
| 2594 static void GeneralizeFieldRepresentation(Handle<JSObject> object, | 2590 static void GeneralizeFieldRepresentation(Handle<JSObject> object, |
| 2595 int modify_index, | 2591 int modify_index, |
| 2596 Representation new_representation, | 2592 Representation new_representation, |
| 2597 StoreMode store_mode); | 2593 StoreMode store_mode); |
| (...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3474 int modify_index, | 3470 int modify_index, |
| 3475 StoreMode store_mode, | 3471 StoreMode store_mode, |
| 3476 Handle<Map> right_map) | 3472 Handle<Map> right_map) |
| 3477 V8_WARN_UNUSED_RESULT; | 3473 V8_WARN_UNUSED_RESULT; |
| 3478 | 3474 |
| 3479 bool IsMoreGeneralThan(int verbatim, | 3475 bool IsMoreGeneralThan(int verbatim, |
| 3480 int valid, | 3476 int valid, |
| 3481 int new_size, | 3477 int new_size, |
| 3482 DescriptorArray* other); | 3478 DescriptorArray* other); |
| 3483 | 3479 |
| 3484 MUST_USE_RESULT MaybeObject* CopyUpTo(int enumeration_index) { | 3480 static Handle<DescriptorArray> CopyUpTo(Handle<DescriptorArray> desc, |
| 3485 return CopyUpToAddAttributes(enumeration_index, NONE); | 3481 int enumeration_index); |
| 3486 } | |
| 3487 | 3482 |
| 3488 static Handle<DescriptorArray> CopyUpToAddAttributes( | 3483 static Handle<DescriptorArray> CopyUpToAddAttributes( |
| 3489 Handle<DescriptorArray> desc, | 3484 Handle<DescriptorArray> desc, |
| 3490 int enumeration_index, | 3485 int enumeration_index, |
| 3491 PropertyAttributes attributes); | 3486 PropertyAttributes attributes); |
| 3492 MUST_USE_RESULT MaybeObject* CopyUpToAddAttributes( | |
| 3493 int enumeration_index, | |
| 3494 PropertyAttributes attributes); | |
| 3495 | 3487 |
| 3496 // Sort the instance descriptors by the hash codes of their keys. | 3488 // Sort the instance descriptors by the hash codes of their keys. |
| 3497 void Sort(); | 3489 void Sort(); |
| 3498 | 3490 |
| 3499 // Search the instance descriptors for given name. | 3491 // Search the instance descriptors for given name. |
| 3500 INLINE(int Search(Name* name, int number_of_own_descriptors)); | 3492 INLINE(int Search(Name* name, int number_of_own_descriptors)); |
| 3501 | 3493 |
| 3502 // As the above, but uses DescriptorLookupCache and updates it when | 3494 // As the above, but uses DescriptorLookupCache and updates it when |
| 3503 // necessary. | 3495 // necessary. |
| 3504 INLINE(int SearchWithCache(Name* name, Map* map)); | 3496 INLINE(int SearchWithCache(Name* name, Map* map)); |
| (...skipping 2660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6165 static bool IsValidElementsTransition(ElementsKind from_kind, | 6157 static bool IsValidElementsTransition(ElementsKind from_kind, |
| 6166 ElementsKind to_kind); | 6158 ElementsKind to_kind); |
| 6167 | 6159 |
| 6168 // Returns true if the current map doesn't have DICTIONARY_ELEMENTS but if a | 6160 // Returns true if the current map doesn't have DICTIONARY_ELEMENTS but if a |
| 6169 // map with DICTIONARY_ELEMENTS was found in the prototype chain. | 6161 // map with DICTIONARY_ELEMENTS was found in the prototype chain. |
| 6170 bool DictionaryElementsInPrototypeChainOnly(); | 6162 bool DictionaryElementsInPrototypeChainOnly(); |
| 6171 | 6163 |
| 6172 inline bool HasTransitionArray(); | 6164 inline bool HasTransitionArray(); |
| 6173 inline bool HasElementsTransition(); | 6165 inline bool HasElementsTransition(); |
| 6174 inline Map* elements_transition_map(); | 6166 inline Map* elements_transition_map(); |
| 6175 MUST_USE_RESULT inline MaybeObject* set_elements_transition_map( | 6167 static Handle<TransitionArray> SetElementsTransitionMap( |
| 6176 Map* transitioned_map); | 6168 Handle<Map> map, Handle<Map> transitioned_map); |
| 6177 inline void SetTransition(int transition_index, Map* target); | 6169 inline void SetTransition(int transition_index, Map* target); |
| 6178 inline Map* GetTransition(int transition_index); | 6170 inline Map* GetTransition(int transition_index); |
| 6179 inline int SearchTransition(Name* name); | 6171 inline int SearchTransition(Name* name); |
| 6172 inline FixedArrayBase* GetInitialElements(); |
| 6180 | 6173 |
| 6181 static Handle<TransitionArray> AddTransition(Handle<Map> map, | 6174 static Handle<TransitionArray> AddTransition(Handle<Map> map, |
| 6182 Handle<Name> key, | 6175 Handle<Name> key, |
| 6183 Handle<Map> target, | 6176 Handle<Map> target, |
| 6184 SimpleTransitionFlag flag); | 6177 SimpleTransitionFlag flag); |
| 6185 | |
| 6186 MUST_USE_RESULT inline MaybeObject* AddTransition(Name* key, | |
| 6187 Map* target, | |
| 6188 SimpleTransitionFlag flag); | |
| 6189 DECL_ACCESSORS(transitions, TransitionArray) | 6178 DECL_ACCESSORS(transitions, TransitionArray) |
| 6190 inline void ClearTransitions(Heap* heap, | 6179 inline void ClearTransitions(Heap* heap, |
| 6191 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | 6180 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); |
| 6192 | 6181 |
| 6193 void DeprecateTransitionTree(); | 6182 void DeprecateTransitionTree(); |
| 6194 void DeprecateTarget(Name* key, DescriptorArray* new_descriptors); | 6183 void DeprecateTarget(Name* key, DescriptorArray* new_descriptors); |
| 6195 | 6184 |
| 6196 Map* FindRootMap(); | 6185 Map* FindRootMap(); |
| 6197 Map* FindUpdatedMap(int verbatim, int length, DescriptorArray* descriptors); | 6186 Map* FindUpdatedMap(int verbatim, int length, DescriptorArray* descriptors); |
| 6198 Map* FindLastMatchMap(int verbatim, int length, DescriptorArray* descriptors); | 6187 Map* FindLastMatchMap(int verbatim, int length, DescriptorArray* descriptors); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6384 // descriptor array of the map. Returns NULL if no updated map is found. | 6373 // descriptor array of the map. Returns NULL if no updated map is found. |
| 6385 // This method also applies any pending migrations along the prototype chain. | 6374 // This method also applies any pending migrations along the prototype chain. |
| 6386 static Handle<Map> CurrentMapForDeprecated(Handle<Map> map); | 6375 static Handle<Map> CurrentMapForDeprecated(Handle<Map> map); |
| 6387 // Same as above, but does not touch the prototype chain. | 6376 // Same as above, but does not touch the prototype chain. |
| 6388 static Handle<Map> CurrentMapForDeprecatedInternal(Handle<Map> map); | 6377 static Handle<Map> CurrentMapForDeprecatedInternal(Handle<Map> map); |
| 6389 | 6378 |
| 6390 static Handle<Map> RawCopy(Handle<Map> map, int instance_size); | 6379 static Handle<Map> RawCopy(Handle<Map> map, int instance_size); |
| 6391 MUST_USE_RESULT MaybeObject* RawCopy(int instance_size); | 6380 MUST_USE_RESULT MaybeObject* RawCopy(int instance_size); |
| 6392 static Handle<Map> CopyDropDescriptors(Handle<Map> map); | 6381 static Handle<Map> CopyDropDescriptors(Handle<Map> map); |
| 6393 MUST_USE_RESULT MaybeObject* CopyDropDescriptors(); | 6382 MUST_USE_RESULT MaybeObject* CopyDropDescriptors(); |
| 6394 static Handle<Map> CopyReplaceDescriptors(Handle<Map> map, | 6383 static Handle<Map> CopyReplaceDescriptors( |
| 6395 Handle<DescriptorArray> descriptors, | 6384 Handle<Map> map, |
| 6396 TransitionFlag flag, | 6385 Handle<DescriptorArray> descriptors, |
| 6397 Handle<Name> name); | |
| 6398 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptors( | |
| 6399 DescriptorArray* descriptors, | |
| 6400 TransitionFlag flag, | 6386 TransitionFlag flag, |
| 6401 Name* name = NULL, | 6387 Handle<Name> name, |
| 6388 SimpleTransitionFlag simple_flag = FULL_TRANSITION); |
| 6389 static Handle<Map> CopyReplaceDescriptors( |
| 6390 Handle<Map> map, |
| 6391 Handle<DescriptorArray> descriptors, |
| 6392 TransitionFlag flag, |
| 6402 SimpleTransitionFlag simple_flag = FULL_TRANSITION); | 6393 SimpleTransitionFlag simple_flag = FULL_TRANSITION); |
| 6403 static Handle<Map> CopyInstallDescriptors( | 6394 static Handle<Map> CopyInstallDescriptors( |
| 6404 Handle<Map> map, | 6395 Handle<Map> map, |
| 6405 int new_descriptor, | 6396 int new_descriptor, |
| 6406 Handle<DescriptorArray> descriptors); | 6397 Handle<DescriptorArray> descriptors); |
| 6407 MUST_USE_RESULT MaybeObject* ShareDescriptor(DescriptorArray* descriptors, | 6398 static Handle<Map> ShareDescriptor(Handle<Map> map, |
| 6408 Descriptor* descriptor); | 6399 Handle<DescriptorArray> descriptors, |
| 6409 MUST_USE_RESULT MaybeObject* CopyAddDescriptor(Descriptor* descriptor, | 6400 Descriptor* descriptor); |
| 6410 TransitionFlag flag); | 6401 static Handle<Map> CopyAddDescriptor(Handle<Map> map, |
| 6411 MUST_USE_RESULT MaybeObject* CopyInsertDescriptor(Descriptor* descriptor, | 6402 Descriptor* descriptor, |
| 6412 TransitionFlag flag); | 6403 TransitionFlag flag); |
| 6413 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptor( | 6404 static Handle<Map> CopyInsertDescriptor(Handle<Map> map, |
| 6414 DescriptorArray* descriptors, | 6405 Descriptor* descriptor, |
| 6406 TransitionFlag flag); |
| 6407 static Handle<Map> CopyReplaceDescriptor( |
| 6408 Handle<Map> map, |
| 6409 Handle<DescriptorArray> descriptors, |
| 6415 Descriptor* descriptor, | 6410 Descriptor* descriptor, |
| 6416 int index, | 6411 int index, |
| 6417 TransitionFlag flag); | 6412 TransitionFlag flag); |
| 6418 | 6413 |
| 6419 MUST_USE_RESULT MaybeObject* AsElementsKind(ElementsKind kind); | |
| 6420 | |
| 6421 static Handle<Map> AsElementsKind(Handle<Map> map, ElementsKind kind); | 6414 static Handle<Map> AsElementsKind(Handle<Map> map, ElementsKind kind); |
| 6422 | 6415 |
| 6423 MUST_USE_RESULT MaybeObject* CopyAsElementsKind(ElementsKind kind, | 6416 static Handle<Map> CopyAsElementsKind(Handle<Map> map, |
| 6424 TransitionFlag flag); | 6417 ElementsKind kind, |
| 6418 TransitionFlag flag); |
| 6425 | 6419 |
| 6426 static Handle<Map> CopyForObserved(Handle<Map> map); | 6420 static Handle<Map> CopyForObserved(Handle<Map> map); |
| 6427 | 6421 |
| 6428 static Handle<Map> CopyNormalized(Handle<Map> map, | 6422 static Handle<Map> CopyNormalized(Handle<Map> map, |
| 6429 PropertyNormalizationMode mode, | 6423 PropertyNormalizationMode mode, |
| 6430 NormalizedMapSharingMode sharing); | 6424 NormalizedMapSharingMode sharing); |
| 6431 | 6425 |
| 6432 inline void AppendDescriptor(Descriptor* desc, | 6426 inline void AppendDescriptor(Descriptor* desc, |
| 6433 const DescriptorArray::WhitenessWitness&); | 6427 const DescriptorArray::WhitenessWitness&); |
| 6434 | 6428 |
| 6435 // Returns a copy of the map, with all transitions dropped from the | 6429 // Returns a copy of the map, with all transitions dropped from the |
| 6436 // instance descriptors. | 6430 // instance descriptors. |
| 6437 static Handle<Map> Copy(Handle<Map> map); | 6431 static Handle<Map> Copy(Handle<Map> map); |
| 6438 static Handle<Map> Create(Handle<JSFunction> constructor, | 6432 static Handle<Map> Create(Handle<JSFunction> constructor, |
| 6439 int extra_inobject_properties); | 6433 int extra_inobject_properties); |
| 6440 MUST_USE_RESULT MaybeObject* Copy(); | |
| 6441 | 6434 |
| 6442 // Returns the next free property index (only valid for FAST MODE). | 6435 // Returns the next free property index (only valid for FAST MODE). |
| 6443 int NextFreePropertyIndex(); | 6436 int NextFreePropertyIndex(); |
| 6444 | 6437 |
| 6445 // Returns the number of properties described in instance_descriptors | 6438 // Returns the number of properties described in instance_descriptors |
| 6446 // filtering out properties with the specified attributes. | 6439 // filtering out properties with the specified attributes. |
| 6447 int NumberOfDescribedProperties(DescriptorFlag which = OWN_DESCRIPTORS, | 6440 int NumberOfDescribedProperties(DescriptorFlag which = OWN_DESCRIPTORS, |
| 6448 PropertyAttributes filter = NONE); | 6441 PropertyAttributes filter = NONE); |
| 6449 | 6442 |
| 6450 // Returns the number of slots allocated for the initial properties | 6443 // Returns the number of slots allocated for the initial properties |
| (...skipping 4555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11006 } else { | 10999 } else { |
| 11007 value &= ~(1 << bit_position); | 11000 value &= ~(1 << bit_position); |
| 11008 } | 11001 } |
| 11009 return value; | 11002 return value; |
| 11010 } | 11003 } |
| 11011 }; | 11004 }; |
| 11012 | 11005 |
| 11013 } } // namespace v8::internal | 11006 } } // namespace v8::internal |
| 11014 | 11007 |
| 11015 #endif // V8_OBJECTS_H_ | 11008 #endif // V8_OBJECTS_H_ |
| OLD | NEW |