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

Side by Side Diff: src/objects.h

Issue 228333003: Handlefy Descriptor and other code in objects.cc (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Last comments. Created 6 years, 8 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 2169 matching lines...) Expand 10 before | Expand all | Expand 10 after
2180 // fixed_cow_array_map (for copy-on-write arrays). In the latter case 2180 // fixed_cow_array_map (for copy-on-write arrays). In the latter case
2181 // the elements array may be shared by a few objects and so before 2181 // the elements array may be shared by a few objects and so before
2182 // writing to any element the array must be copied. Use 2182 // writing to any element the array must be copied. Use
2183 // EnsureWritableFastElements in this case. 2183 // EnsureWritableFastElements in this case.
2184 // 2184 //
2185 // In the slow mode the elements is either a NumberDictionary, an 2185 // In the slow mode the elements is either a NumberDictionary, an
2186 // ExternalArray, or a FixedArray parameter map for a (sloppy) 2186 // ExternalArray, or a FixedArray parameter map for a (sloppy)
2187 // arguments object. 2187 // arguments object.
2188 DECL_ACCESSORS(elements, FixedArrayBase) 2188 DECL_ACCESSORS(elements, FixedArrayBase)
2189 inline void initialize_elements(); 2189 inline void initialize_elements();
2190 MUST_USE_RESULT inline MaybeObject* ResetElements();
2191 static void ResetElements(Handle<JSObject> object); 2190 static void ResetElements(Handle<JSObject> object);
2192 static inline void SetMapAndElements(Handle<JSObject> object, 2191 static inline void SetMapAndElements(Handle<JSObject> object,
2193 Handle<Map> map, 2192 Handle<Map> map,
2194 Handle<FixedArrayBase> elements); 2193 Handle<FixedArrayBase> elements);
2195 inline ElementsKind GetElementsKind(); 2194 inline ElementsKind GetElementsKind();
2196 inline ElementsAccessor* GetElementsAccessor(); 2195 inline ElementsAccessor* GetElementsAccessor();
2197 // Returns true if an object has elements of FAST_SMI_ELEMENTS ElementsKind. 2196 // Returns true if an object has elements of FAST_SMI_ELEMENTS ElementsKind.
2198 inline bool HasFastSmiElements(); 2197 inline bool HasFastSmiElements();
2199 // Returns true if an object has elements of FAST_ELEMENTS ElementsKind. 2198 // Returns true if an object has elements of FAST_ELEMENTS ElementsKind.
2200 inline bool HasFastObjectElements(); 2199 inline bool HasFastObjectElements();
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
2578 // (storage->length() == NumberOfEnumElements()). 2577 // (storage->length() == NumberOfEnumElements()).
2579 // If storage is NULL, will count the elements without adding 2578 // If storage is NULL, will count the elements without adding
2580 // them to any storage. 2579 // them to any storage.
2581 // Returns the number of enumerable elements. 2580 // Returns the number of enumerable elements.
2582 int GetEnumElementKeys(FixedArray* storage); 2581 int GetEnumElementKeys(FixedArray* storage);
2583 2582
2584 // Returns a new map with all transitions dropped from the object's current 2583 // Returns a new map with all transitions dropped from the object's current
2585 // map and the ElementsKind set. 2584 // map and the ElementsKind set.
2586 static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object, 2585 static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object,
2587 ElementsKind to_kind); 2586 ElementsKind to_kind);
2588 inline MUST_USE_RESULT MaybeObject* GetElementsTransitionMap( 2587 static Handle<Map> GetElementsTransitionMapSlow(Handle<JSObject> object,
2589 Isolate* isolate, 2588 ElementsKind elements_kind);
2590 ElementsKind elements_kind);
2591 MUST_USE_RESULT MaybeObject* GetElementsTransitionMapSlow(
2592 ElementsKind elements_kind);
2593 2589
2594 static void TransitionElementsKind(Handle<JSObject> object, 2590 static void TransitionElementsKind(Handle<JSObject> object,
2595 ElementsKind to_kind); 2591 ElementsKind to_kind);
2596 2592
2597 // TODO(mstarzinger): Both public because of ConvertAnsSetLocalProperty(). 2593 // TODO(mstarzinger): Both public because of ConvertAnsSetLocalProperty().
2598 static void MigrateToMap(Handle<JSObject> object, Handle<Map> new_map); 2594 static void MigrateToMap(Handle<JSObject> object, Handle<Map> new_map);
2599 static void GeneralizeFieldRepresentation(Handle<JSObject> object, 2595 static void GeneralizeFieldRepresentation(Handle<JSObject> object,
2600 int modify_index, 2596 int modify_index,
2601 Representation new_representation, 2597 Representation new_representation,
2602 StoreMode store_mode); 2598 StoreMode store_mode);
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
3472 int modify_index, 3468 int modify_index,
3473 StoreMode store_mode, 3469 StoreMode store_mode,
3474 Handle<Map> right_map) 3470 Handle<Map> right_map)
3475 V8_WARN_UNUSED_RESULT; 3471 V8_WARN_UNUSED_RESULT;
3476 3472
3477 bool IsMoreGeneralThan(int verbatim, 3473 bool IsMoreGeneralThan(int verbatim,
3478 int valid, 3474 int valid,
3479 int new_size, 3475 int new_size,
3480 DescriptorArray* other); 3476 DescriptorArray* other);
3481 3477
3482 MUST_USE_RESULT MaybeObject* CopyUpTo(int enumeration_index) { 3478 static Handle<DescriptorArray> CopyUpTo(Handle<DescriptorArray> desc,
3483 return CopyUpToAddAttributes(enumeration_index, NONE); 3479 int enumeration_index);
3484 }
3485 3480
3486 static Handle<DescriptorArray> CopyUpToAddAttributes( 3481 static Handle<DescriptorArray> CopyUpToAddAttributes(
3487 Handle<DescriptorArray> desc, 3482 Handle<DescriptorArray> desc,
3488 int enumeration_index, 3483 int enumeration_index,
3489 PropertyAttributes attributes); 3484 PropertyAttributes attributes);
3490 MUST_USE_RESULT MaybeObject* CopyUpToAddAttributes(
3491 int enumeration_index,
3492 PropertyAttributes attributes);
3493 3485
3494 // Sort the instance descriptors by the hash codes of their keys. 3486 // Sort the instance descriptors by the hash codes of their keys.
3495 void Sort(); 3487 void Sort();
3496 3488
3497 // Search the instance descriptors for given name. 3489 // Search the instance descriptors for given name.
3498 INLINE(int Search(Name* name, int number_of_own_descriptors)); 3490 INLINE(int Search(Name* name, int number_of_own_descriptors));
3499 3491
3500 // As the above, but uses DescriptorLookupCache and updates it when 3492 // As the above, but uses DescriptorLookupCache and updates it when
3501 // necessary. 3493 // necessary.
3502 INLINE(int SearchWithCache(Name* name, Map* map)); 3494 INLINE(int SearchWithCache(Name* name, Map* map));
(...skipping 2674 matching lines...) Expand 10 before | Expand all | Expand 10 after
6177 static bool IsValidElementsTransition(ElementsKind from_kind, 6169 static bool IsValidElementsTransition(ElementsKind from_kind,
6178 ElementsKind to_kind); 6170 ElementsKind to_kind);
6179 6171
6180 // Returns true if the current map doesn't have DICTIONARY_ELEMENTS but if a 6172 // Returns true if the current map doesn't have DICTIONARY_ELEMENTS but if a
6181 // map with DICTIONARY_ELEMENTS was found in the prototype chain. 6173 // map with DICTIONARY_ELEMENTS was found in the prototype chain.
6182 bool DictionaryElementsInPrototypeChainOnly(); 6174 bool DictionaryElementsInPrototypeChainOnly();
6183 6175
6184 inline bool HasTransitionArray(); 6176 inline bool HasTransitionArray();
6185 inline bool HasElementsTransition(); 6177 inline bool HasElementsTransition();
6186 inline Map* elements_transition_map(); 6178 inline Map* elements_transition_map();
6187 MUST_USE_RESULT inline MaybeObject* set_elements_transition_map( 6179 static Handle<TransitionArray> SetElementsTransitionMap(
6188 Map* transitioned_map); 6180 Handle<Map> map, Handle<Map> transitioned_map);
6189 inline void SetTransition(int transition_index, Map* target); 6181 inline void SetTransition(int transition_index, Map* target);
6190 inline Map* GetTransition(int transition_index); 6182 inline Map* GetTransition(int transition_index);
6191 inline int SearchTransition(Name* name); 6183 inline int SearchTransition(Name* name);
6184 inline FixedArrayBase* GetInitialElements();
6192 6185
6193 static Handle<TransitionArray> AddTransition(Handle<Map> map, 6186 static Handle<TransitionArray> AddTransition(Handle<Map> map,
6194 Handle<Name> key, 6187 Handle<Name> key,
6195 Handle<Map> target, 6188 Handle<Map> target,
6196 SimpleTransitionFlag flag); 6189 SimpleTransitionFlag flag);
6197
6198 MUST_USE_RESULT inline MaybeObject* AddTransition(Name* key,
6199 Map* target,
6200 SimpleTransitionFlag flag);
6201 DECL_ACCESSORS(transitions, TransitionArray) 6190 DECL_ACCESSORS(transitions, TransitionArray)
6202 inline void ClearTransitions(Heap* heap, 6191 inline void ClearTransitions(Heap* heap,
6203 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); 6192 WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
6204 6193
6205 void DeprecateTransitionTree(); 6194 void DeprecateTransitionTree();
6206 void DeprecateTarget(Name* key, DescriptorArray* new_descriptors); 6195 void DeprecateTarget(Name* key, DescriptorArray* new_descriptors);
6207 6196
6208 Map* FindRootMap(); 6197 Map* FindRootMap();
6209 Map* FindUpdatedMap(int verbatim, int length, DescriptorArray* descriptors); 6198 Map* FindUpdatedMap(int verbatim, int length, DescriptorArray* descriptors);
6210 Map* FindLastMatchMap(int verbatim, int length, DescriptorArray* descriptors); 6199 Map* FindLastMatchMap(int verbatim, int length, DescriptorArray* descriptors);
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
6396 // descriptor array of the map. Returns NULL if no updated map is found. 6385 // descriptor array of the map. Returns NULL if no updated map is found.
6397 // This method also applies any pending migrations along the prototype chain. 6386 // This method also applies any pending migrations along the prototype chain.
6398 static Handle<Map> CurrentMapForDeprecated(Handle<Map> map); 6387 static Handle<Map> CurrentMapForDeprecated(Handle<Map> map);
6399 // Same as above, but does not touch the prototype chain. 6388 // Same as above, but does not touch the prototype chain.
6400 static Handle<Map> CurrentMapForDeprecatedInternal(Handle<Map> map); 6389 static Handle<Map> CurrentMapForDeprecatedInternal(Handle<Map> map);
6401 6390
6402 static Handle<Map> RawCopy(Handle<Map> map, int instance_size); 6391 static Handle<Map> RawCopy(Handle<Map> map, int instance_size);
6403 MUST_USE_RESULT MaybeObject* RawCopy(int instance_size); 6392 MUST_USE_RESULT MaybeObject* RawCopy(int instance_size);
6404 static Handle<Map> CopyDropDescriptors(Handle<Map> map); 6393 static Handle<Map> CopyDropDescriptors(Handle<Map> map);
6405 MUST_USE_RESULT MaybeObject* CopyDropDescriptors(); 6394 MUST_USE_RESULT MaybeObject* CopyDropDescriptors();
6406 static Handle<Map> CopyReplaceDescriptors(Handle<Map> map, 6395 static Handle<Map> CopyReplaceDescriptors(
6407 Handle<DescriptorArray> descriptors, 6396 Handle<Map> map,
6408 TransitionFlag flag, 6397 Handle<DescriptorArray> descriptors,
6409 Handle<Name> name);
6410 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptors(
6411 DescriptorArray* descriptors,
6412 TransitionFlag flag, 6398 TransitionFlag flag,
6413 Name* name = NULL, 6399 Handle<Name> name,
6400 SimpleTransitionFlag simple_flag = FULL_TRANSITION);
6401 static Handle<Map> CopyReplaceDescriptors(
6402 Handle<Map> map,
6403 Handle<DescriptorArray> descriptors,
6404 TransitionFlag flag,
6414 SimpleTransitionFlag simple_flag = FULL_TRANSITION); 6405 SimpleTransitionFlag simple_flag = FULL_TRANSITION);
6415 static Handle<Map> CopyInstallDescriptors( 6406 static Handle<Map> CopyInstallDescriptors(
6416 Handle<Map> map, 6407 Handle<Map> map,
6417 int new_descriptor, 6408 int new_descriptor,
6418 Handle<DescriptorArray> descriptors); 6409 Handle<DescriptorArray> descriptors);
6419 MUST_USE_RESULT MaybeObject* ShareDescriptor(DescriptorArray* descriptors, 6410 static Handle<Map> ShareDescriptor(Handle<Map> map,
6420 Descriptor* descriptor); 6411 Handle<DescriptorArray> descriptors,
6421 MUST_USE_RESULT MaybeObject* CopyAddDescriptor(Descriptor* descriptor, 6412 Descriptor* descriptor);
6422 TransitionFlag flag); 6413 static Handle<Map> CopyAddDescriptor(Handle<Map> map,
6423 MUST_USE_RESULT MaybeObject* CopyInsertDescriptor(Descriptor* descriptor, 6414 Descriptor* descriptor,
6424 TransitionFlag flag); 6415 TransitionFlag flag);
6425 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptor( 6416 static Handle<Map> CopyInsertDescriptor(Handle<Map> map,
6426 DescriptorArray* descriptors, 6417 Descriptor* descriptor,
6418 TransitionFlag flag);
6419 static Handle<Map> CopyReplaceDescriptor(
6420 Handle<Map> map,
6421 Handle<DescriptorArray> descriptors,
6427 Descriptor* descriptor, 6422 Descriptor* descriptor,
6428 int index, 6423 int index,
6429 TransitionFlag flag); 6424 TransitionFlag flag);
6430 6425
6431 MUST_USE_RESULT MaybeObject* AsElementsKind(ElementsKind kind);
6432
6433 static Handle<Map> AsElementsKind(Handle<Map> map, ElementsKind kind); 6426 static Handle<Map> AsElementsKind(Handle<Map> map, ElementsKind kind);
6434 6427
6435 MUST_USE_RESULT MaybeObject* CopyAsElementsKind(ElementsKind kind, 6428 static Handle<Map> CopyAsElementsKind(Handle<Map> map,
6436 TransitionFlag flag); 6429 ElementsKind kind,
6430 TransitionFlag flag);
6437 6431
6438 static Handle<Map> CopyForObserved(Handle<Map> map); 6432 static Handle<Map> CopyForObserved(Handle<Map> map);
6439 6433
6440 static Handle<Map> CopyNormalized(Handle<Map> map, 6434 static Handle<Map> CopyNormalized(Handle<Map> map,
6441 PropertyNormalizationMode mode, 6435 PropertyNormalizationMode mode,
6442 NormalizedMapSharingMode sharing); 6436 NormalizedMapSharingMode sharing);
6443 6437
6444 inline void AppendDescriptor(Descriptor* desc, 6438 inline void AppendDescriptor(Descriptor* desc,
6445 const DescriptorArray::WhitenessWitness&); 6439 const DescriptorArray::WhitenessWitness&);
6446 6440
6447 // Returns a copy of the map, with all transitions dropped from the 6441 // Returns a copy of the map, with all transitions dropped from the
6448 // instance descriptors. 6442 // instance descriptors.
6449 static Handle<Map> Copy(Handle<Map> map); 6443 static Handle<Map> Copy(Handle<Map> map);
6450 static Handle<Map> Create(Handle<JSFunction> constructor, 6444 static Handle<Map> Create(Handle<JSFunction> constructor,
6451 int extra_inobject_properties); 6445 int extra_inobject_properties);
6452 MUST_USE_RESULT MaybeObject* Copy();
6453 6446
6454 // Returns the next free property index (only valid for FAST MODE). 6447 // Returns the next free property index (only valid for FAST MODE).
6455 int NextFreePropertyIndex(); 6448 int NextFreePropertyIndex();
6456 6449
6457 // Returns the number of properties described in instance_descriptors 6450 // Returns the number of properties described in instance_descriptors
6458 // filtering out properties with the specified attributes. 6451 // filtering out properties with the specified attributes.
6459 int NumberOfDescribedProperties(DescriptorFlag which = OWN_DESCRIPTORS, 6452 int NumberOfDescribedProperties(DescriptorFlag which = OWN_DESCRIPTORS,
6460 PropertyAttributes filter = NONE); 6453 PropertyAttributes filter = NONE);
6461 6454
6462 // Returns the number of slots allocated for the initial properties 6455 // Returns the number of slots allocated for the initial properties
(...skipping 4557 matching lines...) Expand 10 before | Expand all | Expand 10 after
11020 } else { 11013 } else {
11021 value &= ~(1 << bit_position); 11014 value &= ~(1 << bit_position);
11022 } 11015 }
11023 return value; 11016 return value;
11024 } 11017 }
11025 }; 11018 };
11026 11019
11027 } } // namespace v8::internal 11020 } } // namespace v8::internal
11028 11021
11029 #endif // V8_OBJECTS_H_ 11022 #endif // V8_OBJECTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698