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

Side by Side Diff: src/objects.h

Issue 235353003: Revert "HashTable::Shrink() handlified and derived template parameter added to HashTable hierarchy." (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 | « no previous file | 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 3634 matching lines...) Expand 10 before | Expand all | Expand 10 after
3645 ASSERT(UsesSeed); 3645 ASSERT(UsesSeed);
3646 return Hash(key); 3646 return Hash(key);
3647 } 3647 }
3648 static uint32_t HashForObject(Key key, Object* object) { return 0; } 3648 static uint32_t HashForObject(Key key, Object* object) { return 0; }
3649 static uint32_t SeededHashForObject(Key key, uint32_t seed, Object* object) { 3649 static uint32_t SeededHashForObject(Key key, uint32_t seed, Object* object) {
3650 ASSERT(UsesSeed); 3650 ASSERT(UsesSeed);
3651 return HashForObject(key, object); 3651 return HashForObject(key, object);
3652 } 3652 }
3653 }; 3653 };
3654 3654
3655 template<typename Derived, typename Shape, typename Key> 3655 template<typename Shape, typename Key>
3656 class HashTable: public FixedArray { 3656 class HashTable: public FixedArray {
3657 public: 3657 public:
3658 // Wrapper methods 3658 // Wrapper methods
3659 inline uint32_t Hash(Key key) { 3659 inline uint32_t Hash(Key key) {
3660 if (Shape::UsesSeed) { 3660 if (Shape::UsesSeed) {
3661 return Shape::SeededHash(key, 3661 return Shape::SeededHash(key,
3662 GetHeap()->HashSeed()); 3662 GetHeap()->HashSeed());
3663 } else { 3663 } else {
3664 return Shape::Hash(key); 3664 return Shape::Hash(key);
3665 } 3665 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3698 void ElementRemoved() { 3698 void ElementRemoved() {
3699 SetNumberOfElements(NumberOfElements() - 1); 3699 SetNumberOfElements(NumberOfElements() - 1);
3700 SetNumberOfDeletedElements(NumberOfDeletedElements() + 1); 3700 SetNumberOfDeletedElements(NumberOfDeletedElements() + 1);
3701 } 3701 }
3702 void ElementsRemoved(int n) { 3702 void ElementsRemoved(int n) {
3703 SetNumberOfElements(NumberOfElements() - n); 3703 SetNumberOfElements(NumberOfElements() - n);
3704 SetNumberOfDeletedElements(NumberOfDeletedElements() + n); 3704 SetNumberOfDeletedElements(NumberOfDeletedElements() + n);
3705 } 3705 }
3706 3706
3707 // Returns a new HashTable object. Might return Failure. 3707 // Returns a new HashTable object. Might return Failure.
3708 // TODO(ishell): this will be eventually replaced by New().
3709 MUST_USE_RESULT static MaybeObject* Allocate( 3708 MUST_USE_RESULT static MaybeObject* Allocate(
3710 Heap* heap, 3709 Heap* heap,
3711 int at_least_space_for, 3710 int at_least_space_for,
3712 MinimumCapacity capacity_option = USE_DEFAULT_MINIMUM_CAPACITY, 3711 MinimumCapacity capacity_option = USE_DEFAULT_MINIMUM_CAPACITY,
3713 PretenureFlag pretenure = NOT_TENURED); 3712 PretenureFlag pretenure = NOT_TENURED);
3714 3713
3715 // Returns a new HashTable object.
3716 static Handle<Derived> New(
3717 Isolate* isolate,
3718 int at_least_space_for,
3719 MinimumCapacity capacity_option = USE_DEFAULT_MINIMUM_CAPACITY,
3720 PretenureFlag pretenure = NOT_TENURED);
3721
3722 // Computes the required capacity for a table holding the given 3714 // Computes the required capacity for a table holding the given
3723 // number of elements. May be more than HashTable::kMaxCapacity. 3715 // number of elements. May be more than HashTable::kMaxCapacity.
3724 static int ComputeCapacity(int at_least_space_for); 3716 static int ComputeCapacity(int at_least_space_for);
3725 3717
3726 // Returns the key at entry. 3718 // Returns the key at entry.
3727 Object* KeyAt(int entry) { return get(EntryToIndex(entry)); } 3719 Object* KeyAt(int entry) { return get(EntryToIndex(entry)); }
3728 3720
3729 // Tells whether k is a real key. The hole and undefined are not allowed 3721 // Tells whether k is a real key. The hole and undefined are not allowed
3730 // as keys and can be used to indicate missing or deleted elements. 3722 // as keys and can be used to indicate missing or deleted elements.
3731 bool IsKey(Object* k) { 3723 bool IsKey(Object* k) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
3821 } 3813 }
3822 3814
3823 // Returns _expected_ if one of entries given by the first _probe_ probes is 3815 // Returns _expected_ if one of entries given by the first _probe_ probes is
3824 // equal to _expected_. Otherwise, returns the entry given by the probe 3816 // equal to _expected_. Otherwise, returns the entry given by the probe
3825 // number _probe_. 3817 // number _probe_.
3826 uint32_t EntryForProbe(Key key, Object* k, int probe, uint32_t expected); 3818 uint32_t EntryForProbe(Key key, Object* k, int probe, uint32_t expected);
3827 3819
3828 void Swap(uint32_t entry1, uint32_t entry2, WriteBarrierMode mode); 3820 void Swap(uint32_t entry1, uint32_t entry2, WriteBarrierMode mode);
3829 3821
3830 // Rehashes this hash-table into the new table. 3822 // Rehashes this hash-table into the new table.
3831 void Rehash(Derived* new_table, Key key); 3823 MUST_USE_RESULT MaybeObject* Rehash(HashTable* new_table, Key key);
3832 3824
3833 // Attempt to shrink hash table after removal of key. 3825 // Attempt to shrink hash table after removal of key.
3834 static Handle<Derived> Shrink(Handle<Derived> table, Key key); 3826 MUST_USE_RESULT MaybeObject* Shrink(Key key);
3835 3827
3836 // Ensure enough space for n additional elements. 3828 // Ensure enough space for n additional elements.
3837 MUST_USE_RESULT MaybeObject* EnsureCapacity( 3829 MUST_USE_RESULT MaybeObject* EnsureCapacity(
3838 int n, 3830 int n,
3839 Key key, 3831 Key key,
3840 PretenureFlag pretenure = NOT_TENURED); 3832 PretenureFlag pretenure = NOT_TENURED);
3841 }; 3833 };
3842 3834
3843 3835
3844 // HashTableKey is an abstract superclass for virtual key behavior. 3836 // HashTableKey is an abstract superclass for virtual key behavior.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3877 static const int kPrefixSize = 0; 3869 static const int kPrefixSize = 0;
3878 static const int kEntrySize = 1; 3870 static const int kEntrySize = 1;
3879 }; 3871 };
3880 3872
3881 class SeqOneByteString; 3873 class SeqOneByteString;
3882 3874
3883 // StringTable. 3875 // StringTable.
3884 // 3876 //
3885 // No special elements in the prefix and the element size is 1 3877 // No special elements in the prefix and the element size is 1
3886 // because only the string itself (the key) needs to be stored. 3878 // because only the string itself (the key) needs to be stored.
3887 class StringTable: public HashTable<StringTable, 3879 class StringTable: public HashTable<StringTableShape, HashTableKey*> {
3888 StringTableShape,
3889 HashTableKey*> {
3890 public: 3880 public:
3891 // Find string in the string table. If it is not there yet, it is 3881 // Find string in the string table. If it is not there yet, it is
3892 // added. The return value is the string table which might have 3882 // added. The return value is the string table which might have
3893 // been enlarged. If the return value is not a failure, the string 3883 // been enlarged. If the return value is not a failure, the string
3894 // pointer *s is set to the string found. 3884 // pointer *s is set to the string found.
3895 MUST_USE_RESULT MaybeObject* LookupString(String* key, Object** s); 3885 MUST_USE_RESULT MaybeObject* LookupString(String* key, Object** s);
3896 MUST_USE_RESULT MaybeObject* LookupKey(HashTableKey* key, Object** s); 3886 MUST_USE_RESULT MaybeObject* LookupKey(HashTableKey* key, Object** s);
3897 3887
3898 // Looks up a string that is equal to the given string and returns 3888 // Looks up a string that is equal to the given string and returns
3899 // true if it is found, assigning the string to the given output 3889 // true if it is found, assigning the string to the given output
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3931 3921
3932 static const int kPrefixSize = 0; 3922 static const int kPrefixSize = 0;
3933 static const int kEntrySize = 2; 3923 static const int kEntrySize = 2;
3934 }; 3924 };
3935 3925
3936 3926
3937 // MapCache. 3927 // MapCache.
3938 // 3928 //
3939 // Maps keys that are a fixed array of unique names to a map. 3929 // Maps keys that are a fixed array of unique names to a map.
3940 // Used for canonicalize maps for object literals. 3930 // Used for canonicalize maps for object literals.
3941 class MapCache: public HashTable<MapCache, MapCacheShape, HashTableKey*> { 3931 class MapCache: public HashTable<MapCacheShape, HashTableKey*> {
3942 public: 3932 public:
3943 // Find cached value for a name key, otherwise return null. 3933 // Find cached value for a name key, otherwise return null.
3944 Object* Lookup(FixedArray* key); 3934 Object* Lookup(FixedArray* key);
3945 MUST_USE_RESULT MaybeObject* Put(FixedArray* key, Map* value); 3935 MUST_USE_RESULT MaybeObject* Put(FixedArray* key, Map* value);
3946 static inline MapCache* cast(Object* obj); 3936 static inline MapCache* cast(Object* obj);
3947 3937
3948 private: 3938 private:
3949 DISALLOW_IMPLICIT_CONSTRUCTORS(MapCache); 3939 DISALLOW_IMPLICIT_CONSTRUCTORS(MapCache);
3950 }; 3940 };
3951 3941
3952 3942
3953 template <typename Derived, typename Shape, typename Key> 3943 template <typename Shape, typename Key>
3954 class Dictionary: public HashTable<Derived, Shape, Key> { 3944 class Dictionary: public HashTable<Shape, Key> {
3955 protected:
3956 typedef HashTable<Derived, Shape, Key> DerivedHashTable;
3957
3958 public: 3945 public:
3959 static inline Dictionary* cast(Object* obj) { 3946 static inline Dictionary<Shape, Key>* cast(Object* obj) {
3960 return reinterpret_cast<Dictionary*>(obj); 3947 return reinterpret_cast<Dictionary<Shape, Key>*>(obj);
3961 } 3948 }
3962 3949
3963 // Returns the value at entry. 3950 // Returns the value at entry.
3964 Object* ValueAt(int entry) { 3951 Object* ValueAt(int entry) {
3965 return this->get(DerivedHashTable::EntryToIndex(entry) + 1); 3952 return this->get(HashTable<Shape, Key>::EntryToIndex(entry) + 1);
3966 } 3953 }
3967 3954
3968 // Set the value for entry. 3955 // Set the value for entry.
3969 void ValueAtPut(int entry, Object* value) { 3956 void ValueAtPut(int entry, Object* value) {
3970 this->set(DerivedHashTable::EntryToIndex(entry) + 1, value); 3957 this->set(HashTable<Shape, Key>::EntryToIndex(entry) + 1, value);
3971 } 3958 }
3972 3959
3973 // Returns the property details for the property at entry. 3960 // Returns the property details for the property at entry.
3974 PropertyDetails DetailsAt(int entry) { 3961 PropertyDetails DetailsAt(int entry) {
3975 ASSERT(entry >= 0); // Not found is -1, which is not caught by get(). 3962 ASSERT(entry >= 0); // Not found is -1, which is not caught by get().
3976 return PropertyDetails( 3963 return PropertyDetails(
3977 Smi::cast(this->get(DerivedHashTable::EntryToIndex(entry) + 2))); 3964 Smi::cast(this->get(HashTable<Shape, Key>::EntryToIndex(entry) + 2)));
3978 } 3965 }
3979 3966
3980 // Set the details for entry. 3967 // Set the details for entry.
3981 void DetailsAtPut(int entry, PropertyDetails value) { 3968 void DetailsAtPut(int entry, PropertyDetails value) {
3982 this->set(DerivedHashTable::EntryToIndex(entry) + 2, value.AsSmi()); 3969 this->set(HashTable<Shape, Key>::EntryToIndex(entry) + 2, value.AsSmi());
3983 } 3970 }
3984 3971
3985 // Sorting support 3972 // Sorting support
3986 void CopyValuesTo(FixedArray* elements); 3973 void CopyValuesTo(FixedArray* elements);
3987 3974
3988 // Delete a property from the dictionary. 3975 // Delete a property from the dictionary.
3989 Object* DeleteProperty(int entry, JSObject::DeleteMode mode); 3976 Object* DeleteProperty(int entry, JSObject::DeleteMode mode);
3990 // TODO(ishell): Temporary wrapper until handlified. 3977 // TODO(ishell): Temporary wrapper until handlified.
3991 static Handle<Object> DeleteProperty( 3978 static Handle<Object> DeleteProperty(
3992 Handle<Dictionary> dictionary, 3979 Handle<Dictionary<Shape, Key> > dictionary,
3993 int entry, 3980 int entry,
3994 JSObject::DeleteMode mode); 3981 JSObject::DeleteMode mode);
3995 3982
3996 // Attempt to shrink the dictionary after deletion of key. 3983 // Attempt to shrink the dictionary after deletion of key.
3997 static inline Handle<Derived> Shrink(Handle<Derived> dictionary, Key key) { 3984 MUST_USE_RESULT MaybeObject* Shrink(Key key);
3998 return DerivedHashTable::Shrink(dictionary, key); 3985 // TODO(ishell): Temporary wrapper until handlified.
3999 } 3986 MUST_USE_RESULT static Handle<FixedArray> Shrink(
3987 Handle<Dictionary<Shape, Key> > dictionary,
3988 Key key);
4000 3989
4001 // Returns the number of elements in the dictionary filtering out properties 3990 // Returns the number of elements in the dictionary filtering out properties
4002 // with the specified attributes. 3991 // with the specified attributes.
4003 int NumberOfElementsFilterAttributes(PropertyAttributes filter); 3992 int NumberOfElementsFilterAttributes(PropertyAttributes filter);
4004 3993
4005 // Returns the number of enumerable elements in the dictionary. 3994 // Returns the number of enumerable elements in the dictionary.
4006 int NumberOfEnumElements(); 3995 int NumberOfEnumElements();
4007 3996
4008 enum SortMode { UNSORTED, SORTED }; 3997 enum SortMode { UNSORTED, SORTED };
4009 // Copies keys to preallocated fixed array. 3998 // Copies keys to preallocated fixed array.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
4059 MUST_USE_RESULT MaybeObject* AtPut(Key key, Object* value); 4048 MUST_USE_RESULT MaybeObject* AtPut(Key key, Object* value);
4060 4049
4061 // Add entry to dictionary. 4050 // Add entry to dictionary.
4062 MUST_USE_RESULT MaybeObject* AddEntry(Key key, 4051 MUST_USE_RESULT MaybeObject* AddEntry(Key key,
4063 Object* value, 4052 Object* value,
4064 PropertyDetails details, 4053 PropertyDetails details,
4065 uint32_t hash); 4054 uint32_t hash);
4066 4055
4067 // Generate new enumeration indices to avoid enumeration index overflow. 4056 // Generate new enumeration indices to avoid enumeration index overflow.
4068 MUST_USE_RESULT MaybeObject* GenerateNewEnumerationIndices(); 4057 MUST_USE_RESULT MaybeObject* GenerateNewEnumerationIndices();
4069 static const int kMaxNumberKeyIndex = DerivedHashTable::kPrefixStartIndex; 4058 static const int kMaxNumberKeyIndex =
4059 HashTable<Shape, Key>::kPrefixStartIndex;
4070 static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1; 4060 static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1;
4071 }; 4061 };
4072 4062
4073 4063
4074 class NameDictionaryShape : public BaseShape<Name*> { 4064 class NameDictionaryShape : public BaseShape<Name*> {
4075 public: 4065 public:
4076 static inline bool IsMatch(Name* key, Object* other); 4066 static inline bool IsMatch(Name* key, Object* other);
4077 static inline uint32_t Hash(Name* key); 4067 static inline uint32_t Hash(Name* key);
4078 static inline uint32_t HashForObject(Name* key, Object* object); 4068 static inline uint32_t HashForObject(Name* key, Object* object);
4079 MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap, 4069 MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap,
4080 Name* key); 4070 Name* key);
4081 static const int kPrefixSize = 2; 4071 static const int kPrefixSize = 2;
4082 static const int kEntrySize = 3; 4072 static const int kEntrySize = 3;
4083 static const bool kIsEnumerable = true; 4073 static const bool kIsEnumerable = true;
4084 }; 4074 };
4085 4075
4086 4076
4087 class NameDictionary: public Dictionary<NameDictionary, 4077 class NameDictionary: public Dictionary<NameDictionaryShape, Name*> {
4088 NameDictionaryShape,
4089 Name*> {
4090 public: 4078 public:
4091 static inline NameDictionary* cast(Object* obj) { 4079 static inline NameDictionary* cast(Object* obj) {
4092 ASSERT(obj->IsDictionary()); 4080 ASSERT(obj->IsDictionary());
4093 return reinterpret_cast<NameDictionary*>(obj); 4081 return reinterpret_cast<NameDictionary*>(obj);
4094 } 4082 }
4095 4083
4096 // Copies enumerable keys to preallocated fixed array. 4084 // Copies enumerable keys to preallocated fixed array.
4097 void CopyEnumKeysTo(FixedArray* storage); 4085 void CopyEnumKeysTo(FixedArray* storage);
4098 static void DoGenerateNewEnumerationIndices( 4086 static void DoGenerateNewEnumerationIndices(
4099 Handle<NameDictionary> dictionary); 4087 Handle<NameDictionary> dictionary);
(...skipping 29 matching lines...) Expand all
4129 class UnseededNumberDictionaryShape : public NumberDictionaryShape { 4117 class UnseededNumberDictionaryShape : public NumberDictionaryShape {
4130 public: 4118 public:
4131 static const int kPrefixSize = 0; 4119 static const int kPrefixSize = 0;
4132 4120
4133 static inline uint32_t Hash(uint32_t key); 4121 static inline uint32_t Hash(uint32_t key);
4134 static inline uint32_t HashForObject(uint32_t key, Object* object); 4122 static inline uint32_t HashForObject(uint32_t key, Object* object);
4135 }; 4123 };
4136 4124
4137 4125
4138 class SeededNumberDictionary 4126 class SeededNumberDictionary
4139 : public Dictionary<SeededNumberDictionary, 4127 : public Dictionary<SeededNumberDictionaryShape, uint32_t> {
4140 SeededNumberDictionaryShape,
4141 uint32_t> {
4142 public: 4128 public:
4143 static SeededNumberDictionary* cast(Object* obj) { 4129 static SeededNumberDictionary* cast(Object* obj) {
4144 ASSERT(obj->IsDictionary()); 4130 ASSERT(obj->IsDictionary());
4145 return reinterpret_cast<SeededNumberDictionary*>(obj); 4131 return reinterpret_cast<SeededNumberDictionary*>(obj);
4146 } 4132 }
4147 4133
4148 // Type specific at put (default NONE attributes is used when adding). 4134 // Type specific at put (default NONE attributes is used when adding).
4149 MUST_USE_RESULT MaybeObject* AtNumberPut(uint32_t key, Object* value); 4135 MUST_USE_RESULT MaybeObject* AtNumberPut(uint32_t key, Object* value);
4150 MUST_USE_RESULT static Handle<SeededNumberDictionary> AddNumberEntry( 4136 MUST_USE_RESULT static Handle<SeededNumberDictionary> AddNumberEntry(
4151 Handle<SeededNumberDictionary> dictionary, 4137 Handle<SeededNumberDictionary> dictionary,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
4184 inline uint32_t max_number_key(); 4170 inline uint32_t max_number_key();
4185 4171
4186 // Bit masks. 4172 // Bit masks.
4187 static const int kRequiresSlowElementsMask = 1; 4173 static const int kRequiresSlowElementsMask = 1;
4188 static const int kRequiresSlowElementsTagSize = 1; 4174 static const int kRequiresSlowElementsTagSize = 1;
4189 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1; 4175 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1;
4190 }; 4176 };
4191 4177
4192 4178
4193 class UnseededNumberDictionary 4179 class UnseededNumberDictionary
4194 : public Dictionary<UnseededNumberDictionary, 4180 : public Dictionary<UnseededNumberDictionaryShape, uint32_t> {
4195 UnseededNumberDictionaryShape,
4196 uint32_t> {
4197 public: 4181 public:
4198 static UnseededNumberDictionary* cast(Object* obj) { 4182 static UnseededNumberDictionary* cast(Object* obj) {
4199 ASSERT(obj->IsDictionary()); 4183 ASSERT(obj->IsDictionary());
4200 return reinterpret_cast<UnseededNumberDictionary*>(obj); 4184 return reinterpret_cast<UnseededNumberDictionary*>(obj);
4201 } 4185 }
4202 4186
4203 // Type specific at put (default NONE attributes is used when adding). 4187 // Type specific at put (default NONE attributes is used when adding).
4204 MUST_USE_RESULT MaybeObject* AtNumberPut(uint32_t key, Object* value); 4188 MUST_USE_RESULT MaybeObject* AtNumberPut(uint32_t key, Object* value);
4205 MUST_USE_RESULT MaybeObject* AddNumberEntry(uint32_t key, Object* value); 4189 MUST_USE_RESULT MaybeObject* AddNumberEntry(uint32_t key, Object* value);
4206 4190
(...skipping 15 matching lines...) Expand all
4222 static inline uint32_t HashForObject(Object* key, Object* object); 4206 static inline uint32_t HashForObject(Object* key, Object* object);
4223 MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap, 4207 MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap,
4224 Object* key); 4208 Object* key);
4225 static const int kPrefixSize = 0; 4209 static const int kPrefixSize = 0;
4226 static const int kEntrySize = 2; 4210 static const int kEntrySize = 2;
4227 }; 4211 };
4228 4212
4229 4213
4230 // ObjectHashTable maps keys that are arbitrary objects to object values by 4214 // ObjectHashTable maps keys that are arbitrary objects to object values by
4231 // using the identity hash of the key for hashing purposes. 4215 // using the identity hash of the key for hashing purposes.
4232 class ObjectHashTable: public HashTable<ObjectHashTable, 4216 class ObjectHashTable: public HashTable<ObjectHashTableShape, Object*> {
4233 ObjectHashTableShape,
4234 Object*> {
4235 typedef HashTable<ObjectHashTable, ObjectHashTableShape, Object*> HashTable_;
4236 public: 4217 public:
4237 static inline ObjectHashTable* cast(Object* obj) { 4218 static inline ObjectHashTable* cast(Object* obj) {
4238 ASSERT(obj->IsHashTable()); 4219 ASSERT(obj->IsHashTable());
4239 return reinterpret_cast<ObjectHashTable*>(obj); 4220 return reinterpret_cast<ObjectHashTable*>(obj);
4240 } 4221 }
4241 4222
4242 static Handle<ObjectHashTable> EnsureCapacity( 4223 static Handle<ObjectHashTable> EnsureCapacity(
4243 Handle<ObjectHashTable> table, 4224 Handle<ObjectHashTable> table,
4244 int n, 4225 int n,
4245 Handle<Object> key, 4226 Handle<Object> key,
4246 PretenureFlag pretenure = NOT_TENURED); 4227 PretenureFlag pretenure = NOT_TENURED);
4247 4228
4248 // Attempt to shrink hash table after removal of key. 4229 // Attempt to shrink hash table after removal of key.
4249 static inline Handle<ObjectHashTable> Shrink(Handle<ObjectHashTable> table, 4230 static Handle<ObjectHashTable> Shrink(Handle<ObjectHashTable> table,
4250 Handle<Object> key); 4231 Handle<Object> key);
4251 4232
4252 // Looks up the value associated with the given key. The hole value is 4233 // Looks up the value associated with the given key. The hole value is
4253 // returned in case the key is not present. 4234 // returned in case the key is not present.
4254 Object* Lookup(Object* key); 4235 Object* Lookup(Object* key);
4255 4236
4256 // Adds (or overwrites) the value associated with the given key. Mapping a 4237 // Adds (or overwrites) the value associated with the given key. Mapping a
4257 // key to the hole value causes removal of the whole entry. 4238 // key to the hole value causes removal of the whole entry.
4258 static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table, 4239 static Handle<ObjectHashTable> Put(Handle<ObjectHashTable> table,
4259 Handle<Object> key, 4240 Handle<Object> key,
4260 Handle<Object> value); 4241 Handle<Object> value);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
4438 MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap, 4419 MUST_USE_RESULT static inline MaybeObject* AsObject(Heap* heap,
4439 Object* key); 4420 Object* key);
4440 static const int kPrefixSize = 0; 4421 static const int kPrefixSize = 0;
4441 static const int kEntrySize = entrysize; 4422 static const int kEntrySize = entrysize;
4442 }; 4423 };
4443 4424
4444 4425
4445 // WeakHashTable maps keys that are arbitrary objects to object values. 4426 // WeakHashTable maps keys that are arbitrary objects to object values.
4446 // It is used for the global weak hash table that maps objects 4427 // It is used for the global weak hash table that maps objects
4447 // embedded in optimized code to dependent code lists. 4428 // embedded in optimized code to dependent code lists.
4448 class WeakHashTable: public HashTable<WeakHashTable, 4429 class WeakHashTable: public HashTable<WeakHashTableShape<2>, Object*> {
4449 WeakHashTableShape<2>,
4450 Object*> {
4451 public: 4430 public:
4452 static inline WeakHashTable* cast(Object* obj) { 4431 static inline WeakHashTable* cast(Object* obj) {
4453 ASSERT(obj->IsHashTable()); 4432 ASSERT(obj->IsHashTable());
4454 return reinterpret_cast<WeakHashTable*>(obj); 4433 return reinterpret_cast<WeakHashTable*>(obj);
4455 } 4434 }
4456 4435
4457 // Looks up the value associated with the given key. The hole value is 4436 // Looks up the value associated with the given key. The hole value is
4458 // returned in case the key is not present. 4437 // returned in case the key is not present.
4459 Object* Lookup(Object* key); 4438 Object* Lookup(Object* key);
4460 4439
(...skipping 3751 matching lines...) Expand 10 before | Expand all | Expand 10 after
8212 MUST_USE_RESULT static MaybeObject* AsObject(Heap* heap, 8191 MUST_USE_RESULT static MaybeObject* AsObject(Heap* heap,
8213 HashTableKey* key) { 8192 HashTableKey* key) {
8214 return key->AsObject(heap); 8193 return key->AsObject(heap);
8215 } 8194 }
8216 8195
8217 static const int kPrefixSize = 0; 8196 static const int kPrefixSize = 0;
8218 static const int kEntrySize = 2; 8197 static const int kEntrySize = 2;
8219 }; 8198 };
8220 8199
8221 8200
8222 class CompilationCacheTable: public HashTable<CompilationCacheTable, 8201 class CompilationCacheTable: public HashTable<CompilationCacheShape,
8223 CompilationCacheShape,
8224 HashTableKey*> { 8202 HashTableKey*> {
8225 public: 8203 public:
8226 // Find cached value for a string key, otherwise return null. 8204 // Find cached value for a string key, otherwise return null.
8227 Handle<Object> Lookup(Handle<String> src, Handle<Context> context); 8205 Handle<Object> Lookup(Handle<String> src, Handle<Context> context);
8228 Handle<Object> LookupEval(Handle<String> src, Handle<Context> context, 8206 Handle<Object> LookupEval(Handle<String> src, Handle<Context> context,
8229 StrictMode strict_mode, int scope_position); 8207 StrictMode strict_mode, int scope_position);
8230 Handle<Object> LookupRegExp(Handle<String> source, JSRegExp::Flags flags); 8208 Handle<Object> LookupRegExp(Handle<String> source, JSRegExp::Flags flags);
8231 static Handle<CompilationCacheTable> Put( 8209 static Handle<CompilationCacheTable> Put(
8232 Handle<CompilationCacheTable> cache, Handle<String> src, 8210 Handle<CompilationCacheTable> cache, Handle<String> src,
8233 Handle<Context> context, Handle<Object> value); 8211 Handle<Context> context, Handle<Object> value);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
8314 MUST_USE_RESULT static MaybeObject* AsObject(Heap* heap, 8292 MUST_USE_RESULT static MaybeObject* AsObject(Heap* heap,
8315 HashTableKey* key) { 8293 HashTableKey* key) {
8316 return key->AsObject(heap); 8294 return key->AsObject(heap);
8317 } 8295 }
8318 8296
8319 static const int kPrefixSize = 0; 8297 static const int kPrefixSize = 0;
8320 static const int kEntrySize = 2; 8298 static const int kEntrySize = 2;
8321 }; 8299 };
8322 8300
8323 8301
8324 class CodeCacheHashTable: public HashTable<CodeCacheHashTable, 8302 class CodeCacheHashTable: public HashTable<CodeCacheHashTableShape,
8325 CodeCacheHashTableShape,
8326 HashTableKey*> { 8303 HashTableKey*> {
8327 public: 8304 public:
8328 Object* Lookup(Name* name, Code::Flags flags); 8305 Object* Lookup(Name* name, Code::Flags flags);
8329 MUST_USE_RESULT MaybeObject* Put(Name* name, Code* code); 8306 MUST_USE_RESULT MaybeObject* Put(Name* name, Code* code);
8330 8307
8331 int GetIndex(Name* name, Code::Flags flags); 8308 int GetIndex(Name* name, Code::Flags flags);
8332 void RemoveByIndex(int index); 8309 void RemoveByIndex(int index);
8333 8310
8334 static inline CodeCacheHashTable* cast(Object* obj); 8311 static inline CodeCacheHashTable* cast(Object* obj);
8335 8312
(...skipping 29 matching lines...) Expand all
8365 8342
8366 static const int kCacheOffset = HeapObject::kHeaderSize; 8343 static const int kCacheOffset = HeapObject::kHeaderSize;
8367 static const int kSize = kCacheOffset + kPointerSize; 8344 static const int kSize = kCacheOffset + kPointerSize;
8368 8345
8369 private: 8346 private:
8370 DISALLOW_IMPLICIT_CONSTRUCTORS(PolymorphicCodeCache); 8347 DISALLOW_IMPLICIT_CONSTRUCTORS(PolymorphicCodeCache);
8371 }; 8348 };
8372 8349
8373 8350
8374 class PolymorphicCodeCacheHashTable 8351 class PolymorphicCodeCacheHashTable
8375 : public HashTable<PolymorphicCodeCacheHashTable, 8352 : public HashTable<CodeCacheHashTableShape, HashTableKey*> {
8376 CodeCacheHashTableShape,
8377 HashTableKey*> {
8378 public: 8353 public:
8379 Object* Lookup(MapHandleList* maps, int code_kind); 8354 Object* Lookup(MapHandleList* maps, int code_kind);
8380 8355
8381 MUST_USE_RESULT MaybeObject* Put(MapHandleList* maps, 8356 MUST_USE_RESULT MaybeObject* Put(MapHandleList* maps,
8382 int code_kind, 8357 int code_kind,
8383 Code* code); 8358 Code* code);
8384 8359
8385 static inline PolymorphicCodeCacheHashTable* cast(Object* obj); 8360 static inline PolymorphicCodeCacheHashTable* cast(Object* obj);
8386 8361
8387 static const int kInitialSize = 64; 8362 static const int kInitialSize = 64;
(...skipping 2659 matching lines...) Expand 10 before | Expand all | Expand 10 after
11047 } else { 11022 } else {
11048 value &= ~(1 << bit_position); 11023 value &= ~(1 << bit_position);
11049 } 11024 }
11050 return value; 11025 return value;
11051 } 11026 }
11052 }; 11027 };
11053 11028
11054 } } // namespace v8::internal 11029 } } // namespace v8::internal
11055 11030
11056 #endif // V8_OBJECTS_H_ 11031 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698