OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 3883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3894 } | 3894 } |
3895 | 3895 |
3896 // When the table is obsolete we store the indexes of the removed holes. | 3896 // When the table is obsolete we store the indexes of the removed holes. |
3897 int RemovedIndexAt(int index) { | 3897 int RemovedIndexAt(int index) { |
3898 return Smi::cast(get(kRemovedHolesIndex + index))->value(); | 3898 return Smi::cast(get(kRemovedHolesIndex + index))->value(); |
3899 } | 3899 } |
3900 | 3900 |
3901 static const int kNotFound = -1; | 3901 static const int kNotFound = -1; |
3902 static const int kMinCapacity = 4; | 3902 static const int kMinCapacity = 4; |
3903 | 3903 |
| 3904 static const int kNumberOfBucketsIndex = 0; |
| 3905 static const int kNumberOfElementsIndex = kNumberOfBucketsIndex + 1; |
| 3906 static const int kNumberOfDeletedElementsIndex = kNumberOfElementsIndex + 1; |
| 3907 static const int kHashTableStartIndex = kNumberOfDeletedElementsIndex + 1; |
| 3908 |
| 3909 static const int kNumberOfBucketsOffset = |
| 3910 kHeaderSize + kNumberOfBucketsIndex * kPointerSize; |
| 3911 static const int kNumberOfElementsOffset = |
| 3912 kHeaderSize + kNumberOfElementsIndex * kPointerSize; |
| 3913 |
| 3914 static const int kEntrySize = entrysize + 1; |
| 3915 static const int kChainOffset = entrysize; |
| 3916 |
3904 private: | 3917 private: |
3905 static Handle<Derived> Rehash(Handle<Derived> table, int new_capacity); | 3918 static Handle<Derived> Rehash(Handle<Derived> table, int new_capacity); |
3906 | 3919 |
3907 void SetNumberOfBuckets(int num) { | 3920 void SetNumberOfBuckets(int num) { |
3908 set(kNumberOfBucketsIndex, Smi::FromInt(num)); | 3921 set(kNumberOfBucketsIndex, Smi::FromInt(num)); |
3909 } | 3922 } |
3910 | 3923 |
3911 void SetNumberOfElements(int num) { | 3924 void SetNumberOfElements(int num) { |
3912 set(kNumberOfElementsIndex, Smi::FromInt(num)); | 3925 set(kNumberOfElementsIndex, Smi::FromInt(num)); |
3913 } | 3926 } |
(...skipping 21 matching lines...) Expand all Loading... |
3935 } | 3948 } |
3936 | 3949 |
3937 void SetNextTable(Derived* next_table) { | 3950 void SetNextTable(Derived* next_table) { |
3938 set(kNextTableIndex, next_table); | 3951 set(kNextTableIndex, next_table); |
3939 } | 3952 } |
3940 | 3953 |
3941 void SetRemovedIndexAt(int index, int removed_index) { | 3954 void SetRemovedIndexAt(int index, int removed_index) { |
3942 return set(kRemovedHolesIndex + index, Smi::FromInt(removed_index)); | 3955 return set(kRemovedHolesIndex + index, Smi::FromInt(removed_index)); |
3943 } | 3956 } |
3944 | 3957 |
3945 static const int kNumberOfBucketsIndex = 0; | |
3946 static const int kNumberOfElementsIndex = kNumberOfBucketsIndex + 1; | |
3947 static const int kNumberOfDeletedElementsIndex = kNumberOfElementsIndex + 1; | |
3948 static const int kHashTableStartIndex = kNumberOfDeletedElementsIndex + 1; | |
3949 | |
3950 static const int kNextTableIndex = kNumberOfElementsIndex; | 3958 static const int kNextTableIndex = kNumberOfElementsIndex; |
3951 static const int kRemovedHolesIndex = kHashTableStartIndex; | 3959 static const int kRemovedHolesIndex = kHashTableStartIndex; |
3952 | 3960 |
3953 static const int kEntrySize = entrysize + 1; | |
3954 static const int kChainOffset = entrysize; | |
3955 | |
3956 static const int kLoadFactor = 2; | 3961 static const int kLoadFactor = 2; |
3957 static const int kMaxCapacity = | 3962 static const int kMaxCapacity = |
3958 (FixedArray::kMaxLength - kHashTableStartIndex) | 3963 (FixedArray::kMaxLength - kHashTableStartIndex) |
3959 / (1 + (kEntrySize * kLoadFactor)); | 3964 / (1 + (kEntrySize * kLoadFactor)); |
3960 }; | 3965 }; |
3961 | 3966 |
3962 | 3967 |
3963 class JSSetIterator; | 3968 class JSSetIterator; |
3964 | 3969 |
3965 | 3970 |
(...skipping 19 matching lines...) Expand all Loading... |
3985 Object* Lookup(Handle<Object> key); | 3990 Object* Lookup(Handle<Object> key); |
3986 static Handle<OrderedHashMap> Put( | 3991 static Handle<OrderedHashMap> Put( |
3987 Handle<OrderedHashMap> table, | 3992 Handle<OrderedHashMap> table, |
3988 Handle<Object> key, | 3993 Handle<Object> key, |
3989 Handle<Object> value); | 3994 Handle<Object> value); |
3990 | 3995 |
3991 Object* ValueAt(int entry) { | 3996 Object* ValueAt(int entry) { |
3992 return get(EntryToIndex(entry) + kValueOffset); | 3997 return get(EntryToIndex(entry) + kValueOffset); |
3993 } | 3998 } |
3994 | 3999 |
3995 private: | |
3996 static const int kValueOffset = 1; | 4000 static const int kValueOffset = 1; |
3997 }; | 4001 }; |
3998 | 4002 |
3999 | 4003 |
4000 template <int entrysize> | 4004 template <int entrysize> |
4001 class WeakHashTableShape : public BaseShape<Handle<Object> > { | 4005 class WeakHashTableShape : public BaseShape<Handle<Object> > { |
4002 public: | 4006 public: |
4003 static inline bool IsMatch(Handle<Object> key, Object* other); | 4007 static inline bool IsMatch(Handle<Object> key, Object* other); |
4004 static inline uint32_t Hash(Handle<Object> key); | 4008 static inline uint32_t Hash(Handle<Object> key); |
4005 static inline uint32_t HashForObject(Handle<Object> key, Object* object); | 4009 static inline uint32_t HashForObject(Handle<Object> key, Object* object); |
(...skipping 6973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10979 } else { | 10983 } else { |
10980 value &= ~(1 << bit_position); | 10984 value &= ~(1 << bit_position); |
10981 } | 10985 } |
10982 return value; | 10986 return value; |
10983 } | 10987 } |
10984 }; | 10988 }; |
10985 | 10989 |
10986 } } // namespace v8::internal | 10990 } } // namespace v8::internal |
10987 | 10991 |
10988 #endif // V8_OBJECTS_H_ | 10992 #endif // V8_OBJECTS_H_ |
OLD | NEW |