Index: src/objects.h |
diff --git a/src/objects.h b/src/objects.h |
index a125f5b91d11a2c8febc7e0b5b3deb194059d5f2..82518dacd3d613a7ce1769a45190e4cde1da42fb 100644 |
--- a/src/objects.h |
+++ b/src/objects.h |
@@ -3482,13 +3482,22 @@ class HashTableBase : public FixedArray { |
} |
static const int kNumberOfElementsIndex = 0; |
+ static const int kNumberOfElementsOffset = kHeaderSize; |
static const int kNumberOfDeletedElementsIndex = 1; |
+ static const int kNumberOfDeletedElementsOffset = |
+ kNumberOfElementsOffset + kPointerSize; |
static const int kCapacityIndex = 2; |
+ static const int kCapacityOffset = |
+ kNumberOfDeletedElementsOffset + kPointerSize; |
static const int kPrefixStartIndex = 3; |
+ static const int kPrefixStartOffset = kCapacityOffset + kPointerSize; |
Igor Sheludko
2016/10/21 15:01:10
I think you can remove these *Offset constants.
Camillo Bruni
2016/10/21 16:27:32
thought I did ;)
|
// Constant used for denoting a absent entry. |
static const int kNotFound = -1; |
+ // Minimum capacity for newly created hash tables. |
+ static const int kMinCapacity = 4; |
+ |
protected: |
// Update the number of elements in the hash table. |
inline void SetNumberOfElements(int nof); |
@@ -3566,8 +3575,11 @@ class HashTable : public HashTableBase { |
static const int kEntryKeyIndex = 0; |
static const int kElementsStartOffset = |
kHeaderSize + kElementsStartIndex * kPointerSize; |
- static const int kCapacityOffset = |
- kHeaderSize + kCapacityIndex * kPointerSize; |
+ // Maximal capacity of HashTable. Based on maximal length of underlying |
+ // FixedArray. Staying below kMaxCapacity also ensures that EntryToIndex |
+ // cannot overflow. |
+ static const int kMaxCapacity = |
+ (FixedArray::kMaxLength - kElementsStartIndex) / kEntrySize; |
Camillo Bruni
2016/10/21 13:37:15
Note: I change kElementsStartOffset to kElementsSt
|
// Returns the index for an entry (of the key) |
static inline int EntryToIndex(int entry) { |
@@ -3604,12 +3616,6 @@ class HashTable : public HashTableBase { |
set(kCapacityIndex, Smi::FromInt(capacity)); |
} |
- // Maximal capacity of HashTable. Based on maximal length of underlying |
- // FixedArray. Staying below kMaxCapacity also ensures that EntryToIndex |
- // cannot overflow. |
- static const int kMaxCapacity = |
- (FixedArray::kMaxLength - kElementsStartOffset) / kEntrySize; |
- |
private: |
// Returns _expected_ if one of entries given by the first _probe_ probes is |
// equal to _expected_. Otherwise, returns the entry given by the probe |
@@ -3838,6 +3844,13 @@ class Dictionary: public HashTable<Derived, Shape, Key> { |
static Handle<FixedArray> BuildIterationIndicesArray( |
Handle<Derived> dictionary); |
+ // Generate new enumeration indices to avoid enumeration index overflow. |
+ // Returns iteration indices array for the |dictionary|. |
+ static Handle<FixedArray> GenerateNewEnumerationIndices( |
+ Handle<Derived> dictionary); |
+ static const int kMaxNumberKeyIndex = DerivedHashTable::kPrefixStartIndex; |
+ static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1; |
+ |
protected: |
// Generic at put operation. |
MUST_USE_RESULT static Handle<Derived> AtPut( |
@@ -3848,13 +3861,6 @@ class Dictionary: public HashTable<Derived, Shape, Key> { |
// Add entry to dictionary. Returns entry value. |
static int AddEntry(Handle<Derived> dictionary, Key key, Handle<Object> value, |
PropertyDetails details, uint32_t hash); |
- |
- // Generate new enumeration indices to avoid enumeration index overflow. |
- // Returns iteration indices array for the |dictionary|. |
- static Handle<FixedArray> GenerateNewEnumerationIndices( |
- Handle<Derived> dictionary); |
- static const int kMaxNumberKeyIndex = DerivedHashTable::kPrefixStartIndex; |
- static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1; |
}; |
@@ -3926,6 +3932,7 @@ class NameDictionary |
static const int kEntryValueIndex = 1; |
static const int kEntryDetailsIndex = 2; |
+ static const int kInitialCapacity = 2; |
}; |