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 3897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3908 | 3908 |
3909 static const int kNumberOfBucketsIndex = 0; | 3909 static const int kNumberOfBucketsIndex = 0; |
3910 static const int kNumberOfElementsIndex = kNumberOfBucketsIndex + 1; | 3910 static const int kNumberOfElementsIndex = kNumberOfBucketsIndex + 1; |
3911 static const int kNumberOfDeletedElementsIndex = kNumberOfElementsIndex + 1; | 3911 static const int kNumberOfDeletedElementsIndex = kNumberOfElementsIndex + 1; |
3912 static const int kHashTableStartIndex = kNumberOfDeletedElementsIndex + 1; | 3912 static const int kHashTableStartIndex = kNumberOfDeletedElementsIndex + 1; |
3913 | 3913 |
3914 static const int kNumberOfBucketsOffset = | 3914 static const int kNumberOfBucketsOffset = |
3915 kHeaderSize + kNumberOfBucketsIndex * kPointerSize; | 3915 kHeaderSize + kNumberOfBucketsIndex * kPointerSize; |
3916 static const int kNumberOfElementsOffset = | 3916 static const int kNumberOfElementsOffset = |
3917 kHeaderSize + kNumberOfElementsIndex * kPointerSize; | 3917 kHeaderSize + kNumberOfElementsIndex * kPointerSize; |
3918 static const int kNumberOfDeletedElementsOffset = | |
3919 kHeaderSize + kNumberOfDeletedElementsIndex * kPointerSize; | |
3920 | 3918 |
3921 static const int kEntrySize = entrysize + 1; | 3919 static const int kEntrySize = entrysize + 1; |
3922 static const int kChainOffset = entrysize; | 3920 static const int kChainOffset = entrysize; |
3923 | 3921 |
3924 static const int kLoadFactor = 2; | |
3925 | |
3926 private: | 3922 private: |
3927 static Handle<Derived> Rehash(Handle<Derived> table, int new_capacity); | 3923 static Handle<Derived> Rehash(Handle<Derived> table, int new_capacity); |
3928 | 3924 |
3929 void SetNumberOfBuckets(int num) { | 3925 void SetNumberOfBuckets(int num) { |
3930 set(kNumberOfBucketsIndex, Smi::FromInt(num)); | 3926 set(kNumberOfBucketsIndex, Smi::FromInt(num)); |
3931 } | 3927 } |
3932 | 3928 |
3933 void SetNumberOfElements(int num) { | 3929 void SetNumberOfElements(int num) { |
3934 set(kNumberOfElementsIndex, Smi::FromInt(num)); | 3930 set(kNumberOfElementsIndex, Smi::FromInt(num)); |
3935 } | 3931 } |
(...skipping 24 matching lines...) Expand all Loading... |
3960 set(kNextTableIndex, next_table); | 3956 set(kNextTableIndex, next_table); |
3961 } | 3957 } |
3962 | 3958 |
3963 void SetRemovedIndexAt(int index, int removed_index) { | 3959 void SetRemovedIndexAt(int index, int removed_index) { |
3964 return set(kRemovedHolesIndex + index, Smi::FromInt(removed_index)); | 3960 return set(kRemovedHolesIndex + index, Smi::FromInt(removed_index)); |
3965 } | 3961 } |
3966 | 3962 |
3967 static const int kNextTableIndex = kNumberOfElementsIndex; | 3963 static const int kNextTableIndex = kNumberOfElementsIndex; |
3968 static const int kRemovedHolesIndex = kHashTableStartIndex; | 3964 static const int kRemovedHolesIndex = kHashTableStartIndex; |
3969 | 3965 |
| 3966 static const int kLoadFactor = 2; |
3970 static const int kMaxCapacity = | 3967 static const int kMaxCapacity = |
3971 (FixedArray::kMaxLength - kHashTableStartIndex) | 3968 (FixedArray::kMaxLength - kHashTableStartIndex) |
3972 / (1 + (kEntrySize * kLoadFactor)); | 3969 / (1 + (kEntrySize * kLoadFactor)); |
3973 }; | 3970 }; |
3974 | 3971 |
3975 | 3972 |
3976 class JSSetIterator; | 3973 class JSSetIterator; |
3977 | 3974 |
3978 | 3975 |
3979 class OrderedHashSet: public OrderedHashTable< | 3976 class OrderedHashSet: public OrderedHashTable< |
(...skipping 7028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11008 } else { | 11005 } else { |
11009 value &= ~(1 << bit_position); | 11006 value &= ~(1 << bit_position); |
11010 } | 11007 } |
11011 return value; | 11008 return value; |
11012 } | 11009 } |
11013 }; | 11010 }; |
11014 | 11011 |
11015 } } // namespace v8::internal | 11012 } } // namespace v8::internal |
11016 | 11013 |
11017 #endif // V8_OBJECTS_H_ | 11014 #endif // V8_OBJECTS_H_ |
OLD | NEW |