| 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 3903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3914 return Smi::cast(get(kRemovedHolesIndex + index))->value(); | 3914 return Smi::cast(get(kRemovedHolesIndex + index))->value(); |
| 3915 } | 3915 } |
| 3916 | 3916 |
| 3917 static const int kNotFound = -1; | 3917 static const int kNotFound = -1; |
| 3918 static const int kMinCapacity = 4; | 3918 static const int kMinCapacity = 4; |
| 3919 | 3919 |
| 3920 static const int kNumberOfBucketsIndex = 0; | 3920 static const int kNumberOfBucketsIndex = 0; |
| 3921 static const int kNumberOfElementsIndex = kNumberOfBucketsIndex + 1; | 3921 static const int kNumberOfElementsIndex = kNumberOfBucketsIndex + 1; |
| 3922 static const int kNumberOfDeletedElementsIndex = kNumberOfElementsIndex + 1; | 3922 static const int kNumberOfDeletedElementsIndex = kNumberOfElementsIndex + 1; |
| 3923 static const int kHashTableStartIndex = kNumberOfDeletedElementsIndex + 1; | 3923 static const int kHashTableStartIndex = kNumberOfDeletedElementsIndex + 1; |
| 3924 static const int kNextTableIndex = kNumberOfElementsIndex; |
| 3924 | 3925 |
| 3925 static const int kNumberOfBucketsOffset = | 3926 static const int kNumberOfBucketsOffset = |
| 3926 kHeaderSize + kNumberOfBucketsIndex * kPointerSize; | 3927 kHeaderSize + kNumberOfBucketsIndex * kPointerSize; |
| 3927 static const int kNumberOfElementsOffset = | 3928 static const int kNumberOfElementsOffset = |
| 3928 kHeaderSize + kNumberOfElementsIndex * kPointerSize; | 3929 kHeaderSize + kNumberOfElementsIndex * kPointerSize; |
| 3929 static const int kNumberOfDeletedElementsOffset = | 3930 static const int kNumberOfDeletedElementsOffset = |
| 3930 kHeaderSize + kNumberOfDeletedElementsIndex * kPointerSize; | 3931 kHeaderSize + kNumberOfDeletedElementsIndex * kPointerSize; |
| 3931 static const int kHashTableStartOffset = | 3932 static const int kHashTableStartOffset = |
| 3932 kHeaderSize + kHashTableStartIndex * kPointerSize; | 3933 kHeaderSize + kHashTableStartIndex * kPointerSize; |
| 3934 static const int kNextTableOffset = |
| 3935 kHeaderSize + kNextTableIndex * kPointerSize; |
| 3933 | 3936 |
| 3934 static const int kEntrySize = entrysize + 1; | 3937 static const int kEntrySize = entrysize + 1; |
| 3935 static const int kChainOffset = entrysize; | 3938 static const int kChainOffset = entrysize; |
| 3936 | 3939 |
| 3937 static const int kLoadFactor = 2; | 3940 static const int kLoadFactor = 2; |
| 3938 | 3941 |
| 3942 // NumberOfDeletedElements is set to kClearedTableSentinel when |
| 3943 // the table is cleared, which allows iterator transitions to |
| 3944 // optimize that case. |
| 3945 static const int kClearedTableSentinel = -1; |
| 3946 |
| 3939 private: | 3947 private: |
| 3940 static Handle<Derived> Rehash(Handle<Derived> table, int new_capacity); | 3948 static Handle<Derived> Rehash(Handle<Derived> table, int new_capacity); |
| 3941 | 3949 |
| 3942 void SetNumberOfBuckets(int num) { | 3950 void SetNumberOfBuckets(int num) { |
| 3943 set(kNumberOfBucketsIndex, Smi::FromInt(num)); | 3951 set(kNumberOfBucketsIndex, Smi::FromInt(num)); |
| 3944 } | 3952 } |
| 3945 | 3953 |
| 3946 void SetNumberOfElements(int num) { | 3954 void SetNumberOfElements(int num) { |
| 3947 set(kNumberOfElementsIndex, Smi::FromInt(num)); | 3955 set(kNumberOfElementsIndex, Smi::FromInt(num)); |
| 3948 } | 3956 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3970 } | 3978 } |
| 3971 | 3979 |
| 3972 void SetNextTable(Derived* next_table) { | 3980 void SetNextTable(Derived* next_table) { |
| 3973 set(kNextTableIndex, next_table); | 3981 set(kNextTableIndex, next_table); |
| 3974 } | 3982 } |
| 3975 | 3983 |
| 3976 void SetRemovedIndexAt(int index, int removed_index) { | 3984 void SetRemovedIndexAt(int index, int removed_index) { |
| 3977 return set(kRemovedHolesIndex + index, Smi::FromInt(removed_index)); | 3985 return set(kRemovedHolesIndex + index, Smi::FromInt(removed_index)); |
| 3978 } | 3986 } |
| 3979 | 3987 |
| 3980 static const int kNextTableIndex = kNumberOfElementsIndex; | |
| 3981 static const int kRemovedHolesIndex = kHashTableStartIndex; | 3988 static const int kRemovedHolesIndex = kHashTableStartIndex; |
| 3982 | 3989 |
| 3983 static const int kMaxCapacity = | 3990 static const int kMaxCapacity = |
| 3984 (FixedArray::kMaxLength - kHashTableStartIndex) | 3991 (FixedArray::kMaxLength - kHashTableStartIndex) |
| 3985 / (1 + (kEntrySize * kLoadFactor)); | 3992 / (1 + (kEntrySize * kLoadFactor)); |
| 3986 }; | 3993 }; |
| 3987 | 3994 |
| 3988 | 3995 |
| 3989 class JSSetIterator; | 3996 class JSSetIterator; |
| 3990 | 3997 |
| (...skipping 7033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11024 } else { | 11031 } else { |
| 11025 value &= ~(1 << bit_position); | 11032 value &= ~(1 << bit_position); |
| 11026 } | 11033 } |
| 11027 return value; | 11034 return value; |
| 11028 } | 11035 } |
| 11029 }; | 11036 }; |
| 11030 | 11037 |
| 11031 } } // namespace v8::internal | 11038 } } // namespace v8::internal |
| 11032 | 11039 |
| 11033 #endif // V8_OBJECTS_H_ | 11040 #endif // V8_OBJECTS_H_ |
| OLD | NEW |