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

Side by Side Diff: src/objects.h

Issue 10879013: Make order of addition the primary order of descriptor arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 4 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 2498 matching lines...) Expand 10 before | Expand all | Expand 10 after
2509 inline Object** GetKeySlot(int descriptor_number); 2509 inline Object** GetKeySlot(int descriptor_number);
2510 inline Object* GetValue(int descriptor_number); 2510 inline Object* GetValue(int descriptor_number);
2511 inline Object** GetValueSlot(int descriptor_number); 2511 inline Object** GetValueSlot(int descriptor_number);
2512 inline PropertyDetails GetDetails(int descriptor_number); 2512 inline PropertyDetails GetDetails(int descriptor_number);
2513 inline PropertyType GetType(int descriptor_number); 2513 inline PropertyType GetType(int descriptor_number);
2514 inline int GetFieldIndex(int descriptor_number); 2514 inline int GetFieldIndex(int descriptor_number);
2515 inline JSFunction* GetConstantFunction(int descriptor_number); 2515 inline JSFunction* GetConstantFunction(int descriptor_number);
2516 inline Object* GetCallbacksObject(int descriptor_number); 2516 inline Object* GetCallbacksObject(int descriptor_number);
2517 inline AccessorDescriptor* GetCallbacks(int descriptor_number); 2517 inline AccessorDescriptor* GetCallbacks(int descriptor_number);
2518 2518
2519 inline String* GetSortedKey(int descriptor_number);
2520 inline int GetSortedKeyIndex(int descriptor_number);
2521 inline void SetSortedKey(int pointer, int descriptor_number);
2522
2519 // Accessor for complete descriptor. 2523 // Accessor for complete descriptor.
2520 inline void Get(int descriptor_number, Descriptor* desc); 2524 inline void Get(int descriptor_number, Descriptor* desc);
2521 inline void Set(int descriptor_number, 2525 inline void Set(int descriptor_number,
2522 Descriptor* desc, 2526 Descriptor* desc,
2523 const WhitenessWitness&); 2527 const WhitenessWitness&);
2528
2524 // Append automatically sets the enumeration index. This should only be used 2529 // Append automatically sets the enumeration index. This should only be used
2525 // to add descriptors in bulk at the end, followed by sorting the descriptor 2530 // to add descriptors in bulk at the end, followed by sorting the descriptor
2526 // array. 2531 // array.
2527 inline int Append(Descriptor* desc, 2532 inline void Append(Descriptor* desc,
2528 const WhitenessWitness&, 2533 const WhitenessWitness&,
2529 int number_of_set_descriptors); 2534 int number_of_set_descriptors);
2530 2535
2531 // Transfer a complete descriptor from the src descriptor array to this 2536 // Transfer a complete descriptor from the src descriptor array to this
2532 // descriptor array. 2537 // descriptor array.
2533 void CopyFrom(int dst_index, 2538 void CopyFrom(int dst_index,
2534 DescriptorArray* src, 2539 DescriptorArray* src,
2535 int src_index, 2540 int src_index,
2536 const WhitenessWitness&); 2541 const WhitenessWitness&);
2537 2542
2538 // Sort the instance descriptors by the hash codes of their keys. 2543 // Sort the instance descriptors by the hash codes of their keys.
2539 void Sort(const WhitenessWitness&); 2544 void Sort();
2545 inline void SwapSortedKeys(int first, int second);
2540 2546
2541 // Search the instance descriptors for given name. 2547 // Search the instance descriptors for given name.
2542 INLINE(int Search(String* name)); 2548 INLINE(int Search(String* name));
2543 2549
2544 // As the above, but uses DescriptorLookupCache and updates it when 2550 // As the above, but uses DescriptorLookupCache and updates it when
2545 // necessary. 2551 // necessary.
2546 INLINE(int SearchWithCache(String* name)); 2552 INLINE(int SearchWithCache(String* name));
2547 2553
2548 // Tells whether the name is present int the array. 2554 // Tells whether the name is present int the array.
2549 bool Contains(String* name) { return kNotFound != Search(name); } 2555 bool Contains(String* name) { return kNotFound != Search(name); }
(...skipping 2101 matching lines...) Expand 10 before | Expand all | Expand 10 after
4651 inline void set_bit_field(byte value); 4657 inline void set_bit_field(byte value);
4652 4658
4653 // Bit field 2. 4659 // Bit field 2.
4654 inline byte bit_field2(); 4660 inline byte bit_field2();
4655 inline void set_bit_field2(byte value); 4661 inline void set_bit_field2(byte value);
4656 4662
4657 // Bit field 3. 4663 // Bit field 3.
4658 inline int bit_field3(); 4664 inline int bit_field3();
4659 inline void set_bit_field3(int value); 4665 inline void set_bit_field3(int value);
4660 4666
4661 class IsShared: public BitField<bool, 0, 1> {}; 4667 class NumberOfOwnDescriptorsBits: public BitField<int, 0, 11> {};
4662 class FunctionWithPrototype: public BitField<bool, 1, 1> {}; 4668 class IsShared: public BitField<bool, 11, 1> {};
4663 class DictionaryMap: public BitField<bool, 2, 1> {}; 4669 class FunctionWithPrototype: public BitField<bool, 12, 1> {};
4664 class LastAddedBits: public BitField<int, 3, 11> {}; 4670 class DictionaryMap: public BitField<bool, 13, 1> {};
4665 4671
4666 // Tells whether the object in the prototype property will be used 4672 // Tells whether the object in the prototype property will be used
4667 // for instances created from this function. If the prototype 4673 // for instances created from this function. If the prototype
4668 // property is set to a value that is not a JSObject, the prototype 4674 // property is set to a value that is not a JSObject, the prototype
4669 // property will not be used to create instances of the function. 4675 // property will not be used to create instances of the function.
4670 // See ECMA-262, 13.2.2. 4676 // See ECMA-262, 13.2.2.
4671 inline void set_non_instance_prototype(bool value); 4677 inline void set_non_instance_prototype(bool value);
4672 inline bool has_non_instance_prototype(); 4678 inline bool has_non_instance_prototype();
4673 4679
4674 // Tells whether function has special prototype property. If not, prototype 4680 // Tells whether function has special prototype property. If not, prototype
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
4879 inline void SetNumberOfProtoTransitions(int value) { 4885 inline void SetNumberOfProtoTransitions(int value) {
4880 FixedArray* cache = GetPrototypeTransitions(); 4886 FixedArray* cache = GetPrototypeTransitions();
4881 ASSERT(cache->length() != 0); 4887 ASSERT(cache->length() != 0);
4882 cache->set_unchecked(kProtoTransitionNumberOfEntriesOffset, 4888 cache->set_unchecked(kProtoTransitionNumberOfEntriesOffset,
4883 Smi::FromInt(value)); 4889 Smi::FromInt(value));
4884 } 4890 }
4885 4891
4886 // Lookup in the map's instance descriptors and fill out the result 4892 // Lookup in the map's instance descriptors and fill out the result
4887 // with the given holder if the name is found. The holder may be 4893 // with the given holder if the name is found. The holder may be
4888 // NULL when this function is used from the compiler. 4894 // NULL when this function is used from the compiler.
4889 void LookupDescriptor(JSObject* holder, 4895 inline void LookupDescriptor(JSObject* holder,
4890 String* name, 4896 String* name,
4891 LookupResult* result); 4897 LookupResult* result);
4892 4898
4893 void LookupTransition(JSObject* holder, 4899 inline void LookupTransition(JSObject* holder,
4894 String* name, 4900 String* name,
4895 LookupResult* result); 4901 LookupResult* result);
4896 4902
4897 // The size of transition arrays are limited so they do not end up in large 4903 // The size of transition arrays are limited so they do not end up in large
4898 // object space. Otherwise ClearNonLiveTransitions would leak memory while 4904 // object space. Otherwise ClearNonLiveTransitions would leak memory while
4899 // applying in-place right trimming. 4905 // applying in-place right trimming.
4900 inline bool CanHaveMoreTransitions(); 4906 inline bool CanHaveMoreTransitions();
4901 4907
4902 void SetLastAdded(int index) { 4908 int LastAdded() {
4903 set_bit_field3(LastAddedBits::update(bit_field3(), index)); 4909 int number_of_own_descriptors = NumberOfOwnDescriptors();
4910 ASSERT(number_of_own_descriptors > 0);
4911 return number_of_own_descriptors - 1;
4904 } 4912 }
4905 4913
4906 int LastAdded() { 4914 int NumberOfOwnDescriptors() {
4907 return LastAddedBits::decode(bit_field3()); 4915 return NumberOfOwnDescriptorsBits::decode(bit_field3());
4908 } 4916 }
4909 4917
4910 int NumberOfSetDescriptors() { 4918 void SetNumberOfOwnDescriptors(int number) {
4911 ASSERT(!instance_descriptors()->IsEmpty()); 4919 set_bit_field3(NumberOfOwnDescriptorsBits::update(bit_field3(), number));
4912 if (LastAdded() == kNoneAdded) return 0;
4913 return instance_descriptors()->GetDetails(LastAdded()).index();
4914 } 4920 }
4915 4921
4916 MUST_USE_RESULT MaybeObject* RawCopy(int instance_size); 4922 MUST_USE_RESULT MaybeObject* RawCopy(int instance_size);
4917 MUST_USE_RESULT MaybeObject* CopyWithPreallocatedFieldDescriptors(); 4923 MUST_USE_RESULT MaybeObject* CopyWithPreallocatedFieldDescriptors();
4918 MUST_USE_RESULT MaybeObject* CopyDropDescriptors(); 4924 MUST_USE_RESULT MaybeObject* CopyDropDescriptors();
4919 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptors( 4925 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptors(
4920 DescriptorArray* descriptors, 4926 DescriptorArray* descriptors,
4921 String* name, 4927 String* name,
4922 int last_added,
4923 TransitionFlag flag); 4928 TransitionFlag flag);
4924 MUST_USE_RESULT MaybeObject* CopyAddDescriptor(Descriptor* descriptor, 4929 MUST_USE_RESULT MaybeObject* CopyAddDescriptor(Descriptor* descriptor,
4925 TransitionFlag flag); 4930 TransitionFlag flag);
4926 MUST_USE_RESULT MaybeObject* CopyInsertDescriptor(Descriptor* descriptor, 4931 MUST_USE_RESULT MaybeObject* CopyInsertDescriptor(Descriptor* descriptor,
4927 TransitionFlag flag); 4932 TransitionFlag flag);
4928 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptor(Descriptor* descriptor, 4933 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptor(Descriptor* descriptor,
4929 int index, 4934 int index,
4930 TransitionFlag flag); 4935 TransitionFlag flag);
4931 MUST_USE_RESULT MaybeObject* CopyAsElementsKind(ElementsKind kind, 4936 MUST_USE_RESULT MaybeObject* CopyAsElementsKind(ElementsKind kind,
4932 TransitionFlag flag); 4937 TransitionFlag flag);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
5046 // and the values are the maps the are transitioned to. 5051 // and the values are the maps the are transitioned to.
5047 static const int kMaxCachedPrototypeTransitions = 256; 5052 static const int kMaxCachedPrototypeTransitions = 256;
5048 5053
5049 Map* GetPrototypeTransition(Object* prototype); 5054 Map* GetPrototypeTransition(Object* prototype);
5050 5055
5051 MUST_USE_RESULT MaybeObject* PutPrototypeTransition(Object* prototype, 5056 MUST_USE_RESULT MaybeObject* PutPrototypeTransition(Object* prototype,
5052 Map* map); 5057 Map* map);
5053 5058
5054 static const int kMaxPreAllocatedPropertyFields = 255; 5059 static const int kMaxPreAllocatedPropertyFields = 255;
5055 5060
5056 // Constant for denoting that the LastAdded field was not yet set.
5057 static const int kNoneAdded = LastAddedBits::kMax;
5058
5059 // Layout description. 5061 // Layout description.
5060 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; 5062 static const int kInstanceSizesOffset = HeapObject::kHeaderSize;
5061 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; 5063 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize;
5062 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize; 5064 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize;
5063 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; 5065 static const int kConstructorOffset = kPrototypeOffset + kPointerSize;
5064 // Storage for the transition array is overloaded to directly contain a back 5066 // Storage for the transition array is overloaded to directly contain a back
5065 // pointer if unused. When the map has transitions, the back pointer is 5067 // pointer if unused. When the map has transitions, the back pointer is
5066 // transferred to the transition array and accessed through an extra 5068 // transferred to the transition array and accessed through an extra
5067 // indirection. 5069 // indirection.
5068 static const int kTransitionsOrBackPointerOffset = 5070 static const int kTransitionsOrBackPointerOffset =
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
5124 static const int8_t kMaximumBitField2FastSmiElementValue = 5126 static const int8_t kMaximumBitField2FastSmiElementValue =
5125 static_cast<int8_t>((FAST_SMI_ELEMENTS + 1) << 5127 static_cast<int8_t>((FAST_SMI_ELEMENTS + 1) <<
5126 Map::kElementsKindShift) - 1; 5128 Map::kElementsKindShift) - 1;
5127 static const int8_t kMaximumBitField2FastHoleyElementValue = 5129 static const int8_t kMaximumBitField2FastHoleyElementValue =
5128 static_cast<int8_t>((FAST_HOLEY_ELEMENTS + 1) << 5130 static_cast<int8_t>((FAST_HOLEY_ELEMENTS + 1) <<
5129 Map::kElementsKindShift) - 1; 5131 Map::kElementsKindShift) - 1;
5130 static const int8_t kMaximumBitField2FastHoleySmiElementValue = 5132 static const int8_t kMaximumBitField2FastHoleySmiElementValue =
5131 static_cast<int8_t>((FAST_HOLEY_SMI_ELEMENTS + 1) << 5133 static_cast<int8_t>((FAST_HOLEY_SMI_ELEMENTS + 1) <<
5132 Map::kElementsKindShift) - 1; 5134 Map::kElementsKindShift) - 1;
5133 5135
5134 // Bit positions for bit field 3
5135 static const int kIsShared = 0;
5136 static const int kFunctionWithPrototype = 1;
5137 static const int kDictionaryMap = 2;
5138
5139 typedef FixedBodyDescriptor<kPointerFieldsBeginOffset, 5136 typedef FixedBodyDescriptor<kPointerFieldsBeginOffset,
5140 kPointerFieldsEndOffset, 5137 kPointerFieldsEndOffset,
5141 kSize> BodyDescriptor; 5138 kSize> BodyDescriptor;
5142 5139
5143 private: 5140 private:
5144 DISALLOW_IMPLICIT_CONSTRUCTORS(Map); 5141 DISALLOW_IMPLICIT_CONSTRUCTORS(Map);
5145 }; 5142 };
5146 5143
5147 5144
5148 // An abstract superclass, a marker class really, for simple structure classes. 5145 // An abstract superclass, a marker class really, for simple structure classes.
(...skipping 3766 matching lines...) Expand 10 before | Expand all | Expand 10 after
8915 } else { 8912 } else {
8916 value &= ~(1 << bit_position); 8913 value &= ~(1 << bit_position);
8917 } 8914 }
8918 return value; 8915 return value;
8919 } 8916 }
8920 }; 8917 };
8921 8918
8922 } } // namespace v8::internal 8919 } } // namespace v8::internal
8923 8920
8924 #endif // V8_OBJECTS_H_ 8921 #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