Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(964)

Unified Diff: src/objects.h

Issue 2430273007: [runtime] Object.create(null) creates a slow object (Closed)
Patch Set: adding tests Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index a125f5b91d11a2c8febc7e0b5b3deb194059d5f2..30e1175d66fbc0ad786851795f539168efc3c94a 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -3482,9 +3482,15 @@ class HashTableBase : public FixedArray {
}
static const int kNumberOfElementsIndex = 0;
+ static const int kNumberOfElementsOffset = kHeaderSize;
Igor Sheludko 2016/10/21 07:48:27 I think it is better to use OffsetOfElementAt() to
Camillo Bruni 2016/10/21 13:37:15 done.
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;
// Constant used for denoting a absent entry.
static const int kNotFound = -1;
@@ -3566,8 +3572,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;
// Returns the index for an entry (of the key)
static inline int EntryToIndex(int entry) {
@@ -3604,12 +3613,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 +3841,16 @@ 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 kMaxNumberKeyOffset = DerivedHashTable::kPrefixStartOffset;
Igor Sheludko 2016/10/21 07:48:27 Same here.
Camillo Bruni 2016/10/21 13:37:15 done.
+ static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1;
+ static const int kNextEnumerationIndexOffset =
+ kMaxNumberKeyOffset + kPointerSize;
+
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;
};

Powered by Google App Engine
This is Rietveld 408576698