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