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

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: 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
« no previous file with comments | « src/elements.cc ('k') | src/objects.cc » ('j') | src/objects.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2166 matching lines...) Expand 10 before | Expand all | Expand 10 after
2177 // fixed_cow_array_map (for copy-on-write arrays). In the latter case 2177 // fixed_cow_array_map (for copy-on-write arrays). In the latter case
2178 // the elements array may be shared by a few objects and so before 2178 // the elements array may be shared by a few objects and so before
2179 // writing to any element the array must be copied. Use 2179 // writing to any element the array must be copied. Use
2180 // EnsureWritableFastElements in this case. 2180 // EnsureWritableFastElements in this case.
2181 // 2181 //
2182 // In the slow mode the elements is either a NumberDictionary, an 2182 // In the slow mode the elements is either a NumberDictionary, an
2183 // ExternalArray, or a FixedArray parameter map for a (sloppy) 2183 // ExternalArray, or a FixedArray parameter map for a (sloppy)
2184 // arguments object. 2184 // arguments object.
2185 DECL_ACCESSORS(elements, FixedArrayBase) 2185 DECL_ACCESSORS(elements, FixedArrayBase)
2186 inline void initialize_elements(); 2186 inline void initialize_elements();
2187 MUST_USE_RESULT inline MaybeObject* ResetElements();
2188 static void ResetElements(Handle<JSObject> object); 2187 static void ResetElements(Handle<JSObject> object);
2189 static inline void SetMapAndElements(Handle<JSObject> object, 2188 static inline void SetMapAndElements(Handle<JSObject> object,
2190 Handle<Map> map, 2189 Handle<Map> map,
2191 Handle<FixedArrayBase> elements); 2190 Handle<FixedArrayBase> elements);
2192 inline ElementsKind GetElementsKind(); 2191 inline ElementsKind GetElementsKind();
2193 inline ElementsAccessor* GetElementsAccessor(); 2192 inline ElementsAccessor* GetElementsAccessor();
2194 // Returns true if an object has elements of FAST_SMI_ELEMENTS ElementsKind. 2193 // Returns true if an object has elements of FAST_SMI_ELEMENTS ElementsKind.
2195 inline bool HasFastSmiElements(); 2194 inline bool HasFastSmiElements();
2196 // Returns true if an object has elements of FAST_ELEMENTS ElementsKind. 2195 // Returns true if an object has elements of FAST_ELEMENTS ElementsKind.
2197 inline bool HasFastObjectElements(); 2196 inline bool HasFastObjectElements();
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
2568 // (storage->length() == NumberOfEnumElements()). 2567 // (storage->length() == NumberOfEnumElements()).
2569 // If storage is NULL, will count the elements without adding 2568 // If storage is NULL, will count the elements without adding
2570 // them to any storage. 2569 // them to any storage.
2571 // Returns the number of enumerable elements. 2570 // Returns the number of enumerable elements.
2572 int GetEnumElementKeys(FixedArray* storage); 2571 int GetEnumElementKeys(FixedArray* storage);
2573 2572
2574 // Returns a new map with all transitions dropped from the object's current 2573 // Returns a new map with all transitions dropped from the object's current
2575 // map and the ElementsKind set. 2574 // map and the ElementsKind set.
2576 static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object, 2575 static Handle<Map> GetElementsTransitionMap(Handle<JSObject> object,
2577 ElementsKind to_kind); 2576 ElementsKind to_kind);
2578 inline MUST_USE_RESULT MaybeObject* GetElementsTransitionMap( 2577 static Handle<Map> GetElementsTransitionMapSlow(Handle<JSObject> object,
2579 Isolate* isolate, 2578 ElementsKind elements_kind);
2580 ElementsKind elements_kind);
2581 MUST_USE_RESULT MaybeObject* GetElementsTransitionMapSlow(
2582 ElementsKind elements_kind);
2583 2579
2584 static void TransitionElementsKind(Handle<JSObject> object, 2580 static void TransitionElementsKind(Handle<JSObject> object,
2585 ElementsKind to_kind); 2581 ElementsKind to_kind);
2586 2582
2587 // TODO(mstarzinger): Both public because of ConvertAnsSetLocalProperty(). 2583 // TODO(mstarzinger): Both public because of ConvertAnsSetLocalProperty().
2588 static void MigrateToMap(Handle<JSObject> object, Handle<Map> new_map); 2584 static void MigrateToMap(Handle<JSObject> object, Handle<Map> new_map);
2589 static void GeneralizeFieldRepresentation(Handle<JSObject> object, 2585 static void GeneralizeFieldRepresentation(Handle<JSObject> object,
2590 int modify_index, 2586 int modify_index,
2591 Representation new_representation, 2587 Representation new_representation,
2592 StoreMode store_mode); 2588 StoreMode store_mode);
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
3452 int modify_index, 3448 int modify_index,
3453 StoreMode store_mode, 3449 StoreMode store_mode,
3454 Handle<Map> right_map) 3450 Handle<Map> right_map)
3455 V8_WARN_UNUSED_RESULT; 3451 V8_WARN_UNUSED_RESULT;
3456 3452
3457 bool IsMoreGeneralThan(int verbatim, 3453 bool IsMoreGeneralThan(int verbatim,
3458 int valid, 3454 int valid,
3459 int new_size, 3455 int new_size,
3460 DescriptorArray* other); 3456 DescriptorArray* other);
3461 3457
3462 MUST_USE_RESULT MaybeObject* CopyUpTo(int enumeration_index) { 3458 static Handle<DescriptorArray> CopyUpTo(Handle<DescriptorArray> desc,
3463 return CopyUpToAddAttributes(enumeration_index, NONE); 3459 int enumeration_index);
3464 }
3465 3460
3466 static Handle<DescriptorArray> CopyUpToAddAttributes( 3461 static Handle<DescriptorArray> CopyUpToAddAttributes(
3467 Handle<DescriptorArray> desc, 3462 Handle<DescriptorArray> desc,
3468 int enumeration_index, 3463 int enumeration_index,
3469 PropertyAttributes attributes); 3464 PropertyAttributes attributes);
3470 MUST_USE_RESULT MaybeObject* CopyUpToAddAttributes(
3471 int enumeration_index,
3472 PropertyAttributes attributes);
3473 3465
3474 // Sort the instance descriptors by the hash codes of their keys. 3466 // Sort the instance descriptors by the hash codes of their keys.
3475 void Sort(); 3467 void Sort();
3476 3468
3477 // Search the instance descriptors for given name. 3469 // Search the instance descriptors for given name.
3478 INLINE(int Search(Name* name, int number_of_own_descriptors)); 3470 INLINE(int Search(Name* name, int number_of_own_descriptors));
3479 3471
3480 // As the above, but uses DescriptorLookupCache and updates it when 3472 // As the above, but uses DescriptorLookupCache and updates it when
3481 // necessary. 3473 // necessary.
3482 INLINE(int SearchWithCache(Name* name, Map* map)); 3474 INLINE(int SearchWithCache(Name* name, Map* map));
(...skipping 2674 matching lines...) Expand 10 before | Expand all | Expand 10 after
6157 static bool IsValidElementsTransition(ElementsKind from_kind, 6149 static bool IsValidElementsTransition(ElementsKind from_kind,
6158 ElementsKind to_kind); 6150 ElementsKind to_kind);
6159 6151
6160 // Returns true if the current map doesn't have DICTIONARY_ELEMENTS but if a 6152 // Returns true if the current map doesn't have DICTIONARY_ELEMENTS but if a
6161 // map with DICTIONARY_ELEMENTS was found in the prototype chain. 6153 // map with DICTIONARY_ELEMENTS was found in the prototype chain.
6162 bool DictionaryElementsInPrototypeChainOnly(); 6154 bool DictionaryElementsInPrototypeChainOnly();
6163 6155
6164 inline bool HasTransitionArray(); 6156 inline bool HasTransitionArray();
6165 inline bool HasElementsTransition(); 6157 inline bool HasElementsTransition();
6166 inline Map* elements_transition_map(); 6158 inline Map* elements_transition_map();
6167 MUST_USE_RESULT inline MaybeObject* set_elements_transition_map( 6159 static Handle<TransitionArray> SetElementsTransitionMap(
6168 Map* transitioned_map); 6160 Handle<Map> map, Handle<Map> transitioned_map);
6169 inline void SetTransition(int transition_index, Map* target); 6161 inline void SetTransition(int transition_index, Map* target);
6170 inline Map* GetTransition(int transition_index); 6162 inline Map* GetTransition(int transition_index);
6171 inline int SearchTransition(Name* name); 6163 inline int SearchTransition(Name* name);
6172 6164
6173 static Handle<TransitionArray> AddTransition(Handle<Map> map, 6165 static Handle<TransitionArray> AddTransition(Handle<Map> map,
6174 Handle<Name> key, 6166 Handle<Name> key,
6175 Handle<Map> target, 6167 Handle<Map> target,
6176 SimpleTransitionFlag flag); 6168 SimpleTransitionFlag flag);
6177 6169
6178 MUST_USE_RESULT inline MaybeObject* AddTransition(Name* key, 6170 MUST_USE_RESULT inline MaybeObject* AddTransition(Name* key,
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
6380 static Handle<Map> CurrentMapForDeprecatedInternal(Handle<Map> map); 6372 static Handle<Map> CurrentMapForDeprecatedInternal(Handle<Map> map);
6381 6373
6382 static Handle<Map> RawCopy(Handle<Map> map, int instance_size); 6374 static Handle<Map> RawCopy(Handle<Map> map, int instance_size);
6383 MUST_USE_RESULT MaybeObject* RawCopy(int instance_size); 6375 MUST_USE_RESULT MaybeObject* RawCopy(int instance_size);
6384 static Handle<Map> CopyDropDescriptors(Handle<Map> map); 6376 static Handle<Map> CopyDropDescriptors(Handle<Map> map);
6385 MUST_USE_RESULT MaybeObject* CopyDropDescriptors(); 6377 MUST_USE_RESULT MaybeObject* CopyDropDescriptors();
6386 static Handle<Map> CopyReplaceDescriptors(Handle<Map> map, 6378 static Handle<Map> CopyReplaceDescriptors(Handle<Map> map,
6387 Handle<DescriptorArray> descriptors, 6379 Handle<DescriptorArray> descriptors,
6388 TransitionFlag flag, 6380 TransitionFlag flag,
6389 Handle<Name> name); 6381 Handle<Name> name);
6390 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptors( 6382
6383 static Handle<Map> CopyReplaceDescriptorsFull(
6384 Handle<Map> map,
6385 Handle<DescriptorArray> descriptors,
6386 TransitionFlag flag,
6387 Handle<Name> name,
6388 SimpleTransitionFlag simple_flag = FULL_TRANSITION);
6389 static Handle<Map> CopyReplaceDescriptorsFull(
6390 Handle<Map> map,
6391 Handle<DescriptorArray> descriptors,
6392 TransitionFlag flag,
6393 SimpleTransitionFlag simple_flag = FULL_TRANSITION);
6394
6395 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptorsFull(
6391 DescriptorArray* descriptors, 6396 DescriptorArray* descriptors,
6392 TransitionFlag flag, 6397 TransitionFlag flag,
6393 Name* name = NULL, 6398 Name* name = NULL,
6394 SimpleTransitionFlag simple_flag = FULL_TRANSITION); 6399 SimpleTransitionFlag simple_flag = FULL_TRANSITION);
6395 static Handle<Map> CopyInstallDescriptors( 6400 static Handle<Map> CopyInstallDescriptors(
6396 Handle<Map> map, 6401 Handle<Map> map,
6397 int new_descriptor, 6402 int new_descriptor,
6398 Handle<DescriptorArray> descriptors); 6403 Handle<DescriptorArray> descriptors);
6399 MUST_USE_RESULT MaybeObject* ShareDescriptor(DescriptorArray* descriptors, 6404 static Handle<Map> ShareDescriptor(Handle<Map> map,
6400 Descriptor* descriptor); 6405 Handle<DescriptorArray> descriptors,
6401 MUST_USE_RESULT MaybeObject* CopyAddDescriptor(Descriptor* descriptor, 6406 Descriptor* descriptor);
6402 TransitionFlag flag); 6407 static Handle<Map> CopyAddDescriptor(Handle<Map> map,
6403 MUST_USE_RESULT MaybeObject* CopyInsertDescriptor(Descriptor* descriptor, 6408 Descriptor* descriptor,
6404 TransitionFlag flag); 6409 TransitionFlag flag);
6405 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptor( 6410 static Handle<Map> CopyInsertDescriptor(Handle<Map> map,
6406 DescriptorArray* descriptors, 6411 Descriptor* descriptor,
6412 TransitionFlag flag);
6413 static Handle<Map> CopyReplaceDescriptor(
6414 Handle<Map> map,
6415 Handle<DescriptorArray> descriptors,
6407 Descriptor* descriptor, 6416 Descriptor* descriptor,
6408 int index, 6417 int index,
6409 TransitionFlag flag); 6418 TransitionFlag flag);
6410 6419
6411 MUST_USE_RESULT MaybeObject* AsElementsKind(ElementsKind kind);
6412
6413 static Handle<Map> AsElementsKind(Handle<Map> map, ElementsKind kind); 6420 static Handle<Map> AsElementsKind(Handle<Map> map, ElementsKind kind);
6414 6421
6415 MUST_USE_RESULT MaybeObject* CopyAsElementsKind(ElementsKind kind, 6422 static Handle<Map> CopyAsElementsKind(Handle<Map> map,
6416 TransitionFlag flag); 6423 ElementsKind kind,
6424 TransitionFlag flag);
6417 6425
6418 static Handle<Map> CopyForObserved(Handle<Map> map); 6426 static Handle<Map> CopyForObserved(Handle<Map> map);
6419 6427
6420 static Handle<Map> CopyNormalized(Handle<Map> map, 6428 static Handle<Map> CopyNormalized(Handle<Map> map,
6421 PropertyNormalizationMode mode, 6429 PropertyNormalizationMode mode,
6422 NormalizedMapSharingMode sharing); 6430 NormalizedMapSharingMode sharing);
6423 6431
6424 inline void AppendDescriptor(Descriptor* desc, 6432 inline void AppendDescriptor(Descriptor* desc,
6425 const DescriptorArray::WhitenessWitness&); 6433 const DescriptorArray::WhitenessWitness&);
6426 6434
6427 // Returns a copy of the map, with all transitions dropped from the 6435 // Returns a copy of the map, with all transitions dropped from the
6428 // instance descriptors. 6436 // instance descriptors.
6429 static Handle<Map> Copy(Handle<Map> map); 6437 static Handle<Map> Copy(Handle<Map> map);
6430 static Handle<Map> Create(Handle<JSFunction> constructor, 6438 static Handle<Map> Create(Handle<JSFunction> constructor,
6431 int extra_inobject_properties); 6439 int extra_inobject_properties);
6432 MUST_USE_RESULT MaybeObject* Copy();
6433 6440
6434 // Returns the next free property index (only valid for FAST MODE). 6441 // Returns the next free property index (only valid for FAST MODE).
6435 int NextFreePropertyIndex(); 6442 int NextFreePropertyIndex();
6436 6443
6437 // Returns the number of properties described in instance_descriptors 6444 // Returns the number of properties described in instance_descriptors
6438 // filtering out properties with the specified attributes. 6445 // filtering out properties with the specified attributes.
6439 int NumberOfDescribedProperties(DescriptorFlag which = OWN_DESCRIPTORS, 6446 int NumberOfDescribedProperties(DescriptorFlag which = OWN_DESCRIPTORS,
6440 PropertyAttributes filter = NONE); 6447 PropertyAttributes filter = NONE);
6441 6448
6442 // Returns the number of slots allocated for the initial properties 6449 // Returns the number of slots allocated for the initial properties
(...skipping 4543 matching lines...) Expand 10 before | Expand all | Expand 10 after
10986 } else { 10993 } else {
10987 value &= ~(1 << bit_position); 10994 value &= ~(1 << bit_position);
10988 } 10995 }
10989 return value; 10996 return value;
10990 } 10997 }
10991 }; 10998 };
10992 10999
10993 } } // namespace v8::internal 11000 } } // namespace v8::internal
10994 11001
10995 #endif // V8_OBJECTS_H_ 11002 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/elements.cc ('k') | src/objects.cc » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698