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

Side by Side Diff: src/objects.h

Issue 10780031: Grouping all map creation code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing comments Created 8 years, 5 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/heap.cc ('k') | src/objects.cc » ('j') | no next file with comments »
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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 171
172 172
173 // Indicates whether the search function should expect a sorted or an unsorted 173 // Indicates whether the search function should expect a sorted or an unsorted
174 // array as input. 174 // array as input.
175 enum SearchMode { 175 enum SearchMode {
176 EXPECT_SORTED, 176 EXPECT_SORTED,
177 EXPECT_UNSORTED 177 EXPECT_UNSORTED
178 }; 178 };
179 179
180 180
181 // Indicates whether transitions can be added to a source map or not.
182 enum TransitionFlag {
183 INSERT_TRANSITION,
184 OMIT_TRANSITION
185 };
186
187
181 // Instance size sentinel for objects of variable size. 188 // Instance size sentinel for objects of variable size.
182 const int kVariableSizeSentinel = 0; 189 const int kVariableSizeSentinel = 0;
183 190
184 const int kStubMajorKeyBits = 6; 191 const int kStubMajorKeyBits = 6;
185 const int kStubMinorKeyBits = kBitsPerInt - kSmiTagSize - kStubMajorKeyBits; 192 const int kStubMinorKeyBits = kBitsPerInt - kSmiTagSize - kStubMajorKeyBits;
186 193
187 // All Maps have a field instance_type containing a InstanceType. 194 // All Maps have a field instance_type containing a InstanceType.
188 // It describes the type of the instances. 195 // It describes the type of the instances.
189 // 196 //
190 // As an example, a JavaScript object is a heap object and its map 197 // As an example, a JavaScript object is a heap object and its map
(...skipping 2357 matching lines...) Expand 10 before | Expand all | Expand 10 after
2548 inline void Append(Descriptor* desc, 2555 inline void Append(Descriptor* desc,
2549 const WhitenessWitness&); 2556 const WhitenessWitness&);
2550 2557
2551 // Transfer a complete descriptor from the src descriptor array to this 2558 // Transfer a complete descriptor from the src descriptor array to this
2552 // descriptor array. 2559 // descriptor array.
2553 void CopyFrom(int dst_index, 2560 void CopyFrom(int dst_index,
2554 DescriptorArray* src, 2561 DescriptorArray* src,
2555 int src_index, 2562 int src_index,
2556 const WhitenessWitness&); 2563 const WhitenessWitness&);
2557 2564
2558 // Copy the descriptor array, insert a new descriptor and optionally 2565 // Copy the descriptor array, inserting new descriptor. Its enumeration index
2559 // remove map transitions. If the descriptor is already present, it is 2566 // is automatically set to the size of the descriptor array to which it was
2560 // replaced. If a replaced descriptor is a real property (not a transition 2567 // added first.
2561 // or null), its enumeration index is kept as is.
2562 // If adding a real property, map transitions must be removed. If adding
2563 // a transition, they must not be removed. All null descriptors are removed.
2564 MUST_USE_RESULT MaybeObject* CopyInsert(Descriptor* descriptor);
2565 MUST_USE_RESULT MaybeObject* CopyAdd(Descriptor* descriptor); 2568 MUST_USE_RESULT MaybeObject* CopyAdd(Descriptor* descriptor);
2569
2570 // Copy the descriptor array, replacing a descriptor. Its enumeration index is
2571 // kept.
2566 MUST_USE_RESULT MaybeObject* CopyReplace(Descriptor* descriptor, 2572 MUST_USE_RESULT MaybeObject* CopyReplace(Descriptor* descriptor,
2567 int insertion_index); 2573 int insertion_index);
2568 2574
2569 // Indicates whether the search function should expect a sorted or an unsorted 2575 // Indicates whether the search function should expect a sorted or an unsorted
2570 // descriptor array as input. 2576 // descriptor array as input.
2571 enum SharedMode { 2577 enum SharedMode {
2572 MAY_BE_SHARED, 2578 MAY_BE_SHARED,
2573 CANNOT_BE_SHARED 2579 CANNOT_BE_SHARED
2574 }; 2580 };
2575 2581
(...skipping 2326 matching lines...) Expand 10 before | Expand all | Expand 10 after
4902 LookupResult* result); 4908 LookupResult* result);
4903 4909
4904 void LookupTransition(JSObject* holder, 4910 void LookupTransition(JSObject* holder,
4905 String* name, 4911 String* name,
4906 LookupResult* result); 4912 LookupResult* result);
4907 4913
4908 MUST_USE_RESULT MaybeObject* RawCopy(int instance_size); 4914 MUST_USE_RESULT MaybeObject* RawCopy(int instance_size);
4909 MUST_USE_RESULT MaybeObject* CopyWithPreallocatedFieldDescriptors(); 4915 MUST_USE_RESULT MaybeObject* CopyWithPreallocatedFieldDescriptors();
4910 MUST_USE_RESULT MaybeObject* CopyDropDescriptors(); 4916 MUST_USE_RESULT MaybeObject* CopyDropDescriptors();
4911 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptors( 4917 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptors(
4912 DescriptorArray* descriptors); 4918 DescriptorArray* descriptors, String* name, TransitionFlag flag);
4919 MUST_USE_RESULT MaybeObject* CopyAddDescriptor(Descriptor* descriptor,
4920 TransitionFlag flag);
4921 MUST_USE_RESULT MaybeObject* CopyInsertDescriptor(Descriptor* descriptor,
4922 TransitionFlag flag);
4923 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptor(Descriptor* descriptor,
4924 int index,
4925 TransitionFlag flag);
4926 MUST_USE_RESULT MaybeObject* CopyAsElementsKind(ElementsKind kind,
4927 TransitionFlag flag);
4913 4928
4914 MUST_USE_RESULT MaybeObject* CopyNormalized(PropertyNormalizationMode mode, 4929 MUST_USE_RESULT MaybeObject* CopyNormalized(PropertyNormalizationMode mode,
4915 NormalizedMapSharingMode sharing); 4930 NormalizedMapSharingMode sharing);
4916 4931
4917 // Returns a copy of the map, with all transitions dropped from the 4932 // Returns a copy of the map, with all transitions dropped from the
4918 // instance descriptors. 4933 // instance descriptors.
4919 MUST_USE_RESULT MaybeObject* CopyDropTransitions( 4934 MUST_USE_RESULT MaybeObject* Copy(DescriptorArray::SharedMode shared_mode);
4920 DescriptorArray::SharedMode shared_mode);
4921 4935
4922 // Returns the property index for name (only valid for FAST MODE). 4936 // Returns the property index for name (only valid for FAST MODE).
4923 int PropertyIndexFor(String* name); 4937 int PropertyIndexFor(String* name);
4924 4938
4925 // Returns the next free property index (only valid for FAST MODE). 4939 // Returns the next free property index (only valid for FAST MODE).
4926 int NextFreePropertyIndex(); 4940 int NextFreePropertyIndex();
4927 4941
4928 // Returns the number of properties described in instance_descriptors 4942 // Returns the number of properties described in instance_descriptors
4929 // filtering out properties with the specified attributes. 4943 // filtering out properties with the specified attributes.
4930 int NumberOfDescribedProperties(PropertyAttributes filter = NONE); 4944 int NumberOfDescribedProperties(PropertyAttributes filter = NONE);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
4969 // it had exactly zero inobject properties. 4983 // it had exactly zero inobject properties.
4970 // The "shared" flags of both this map and |other| are ignored. 4984 // The "shared" flags of both this map and |other| are ignored.
4971 bool EquivalentToForNormalization(Map* other, PropertyNormalizationMode mode); 4985 bool EquivalentToForNormalization(Map* other, PropertyNormalizationMode mode);
4972 4986
4973 // Returns the map that this map transitions to if its elements_kind 4987 // Returns the map that this map transitions to if its elements_kind
4974 // is changed to |elements_kind|, or NULL if no such map is cached yet. 4988 // is changed to |elements_kind|, or NULL if no such map is cached yet.
4975 // |safe_to_add_transitions| is set to false if adding transitions is not 4989 // |safe_to_add_transitions| is set to false if adding transitions is not
4976 // allowed. 4990 // allowed.
4977 Map* LookupElementsTransitionMap(ElementsKind elements_kind); 4991 Map* LookupElementsTransitionMap(ElementsKind elements_kind);
4978 4992
4979 // Adds a new transitions for changing the elements kind to |elements_kind|.
4980 MUST_USE_RESULT MaybeObject* CreateNextElementsTransition(
4981 ElementsKind elements_kind);
4982
4983 // Returns the transitioned map for this map with the most generic 4993 // Returns the transitioned map for this map with the most generic
4984 // elements_kind that's found in |candidates|, or null handle if no match is 4994 // elements_kind that's found in |candidates|, or null handle if no match is
4985 // found at all. 4995 // found at all.
4986 Handle<Map> FindTransitionedMap(MapHandleList* candidates); 4996 Handle<Map> FindTransitionedMap(MapHandleList* candidates);
4987 Map* FindTransitionedMap(MapList* candidates); 4997 Map* FindTransitionedMap(MapList* candidates);
4988 4998
4989 // Zaps the contents of backing data structures in debug mode. Note that the 4999 // Zaps the contents of backing data structures in debug mode. Note that the
4990 // heap verifier (i.e. VerifyMarkingVisitor) relies on zapping of objects 5000 // heap verifier (i.e. VerifyMarkingVisitor) relies on zapping of objects
4991 // holding weak references when incremental marking is used, because it also 5001 // holding weak references when incremental marking is used, because it also
4992 // iterates over objects that are otherwise unreachable. 5002 // iterates over objects that are otherwise unreachable.
(...skipping 3884 matching lines...) Expand 10 before | Expand all | Expand 10 after
8877 } else { 8887 } else {
8878 value &= ~(1 << bit_position); 8888 value &= ~(1 << bit_position);
8879 } 8889 }
8880 return value; 8890 return value;
8881 } 8891 }
8882 }; 8892 };
8883 8893
8884 } } // namespace v8::internal 8894 } } // namespace v8::internal
8885 8895
8886 #endif // V8_OBJECTS_H_ 8896 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698