Commit eeb74f09 authored by Frank Emrich's avatar Frank Emrich Committed by Commit Bot

[dict-proto] make small ordered hash tables use InternalIndex, too

This CL changes the "small" versions of ordered hash tables, like
SmallOrderedNameDictionary and the corresponding handlers, like
OrderedNameDictionaryHandler, to use InternalIndex rather than int
as the type used for indices.

This is part of an effort to make the interfaces of the
ordered and unordered name dictionaries more similar.

Bug: v8:7569
Change-Id: I3b6fe79dfd3c6743f58a04cfe82798fe2ef09e19
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2505720
Commit-Queue: Frank Emrich <emrich@google.com>
Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70876}
parent 5d517131
......@@ -51,9 +51,9 @@ SmallOrderedHashTable<Derived>::SmallOrderedHashTable(Address ptr)
: HeapObject(ptr) {}
template <class Derived>
Object SmallOrderedHashTable<Derived>::KeyAt(int entry) const {
DCHECK_LT(entry, Capacity());
Offset entry_offset = GetDataEntryOffset(entry, Derived::kKeyIndex);
Object SmallOrderedHashTable<Derived>::KeyAt(InternalIndex entry) const {
DCHECK_LT(entry.as_int(), Capacity());
Offset entry_offset = GetDataEntryOffset(entry.as_int(), Derived::kKeyIndex);
return TaggedField<Object>::load(*this, entry_offset);
}
......@@ -129,27 +129,29 @@ inline void OrderedNameDictionary::DetailsAtPut(InternalIndex entry,
this->set(EntryToIndex(entry) + kPropertyDetailsOffset, value.AsSmi());
}
inline Object SmallOrderedNameDictionary::ValueAt(int entry) {
return this->GetDataEntry(entry, kValueIndex);
inline Object SmallOrderedNameDictionary::ValueAt(InternalIndex entry) {
return this->GetDataEntry(entry.as_int(), kValueIndex);
}
// Set the value for entry.
inline void SmallOrderedNameDictionary::ValueAtPut(int entry, Object value) {
this->SetDataEntry(entry, kValueIndex, value);
inline void SmallOrderedNameDictionary::ValueAtPut(InternalIndex entry,
Object value) {
this->SetDataEntry(entry.as_int(), kValueIndex, value);
}
// Returns the property details for the property at entry.
inline PropertyDetails SmallOrderedNameDictionary::DetailsAt(int entry) {
inline PropertyDetails SmallOrderedNameDictionary::DetailsAt(
InternalIndex entry) {
// TODO(gsathya): Optimize the cast away. And store this in the data table.
return PropertyDetails(
Smi::cast(this->GetDataEntry(entry, kPropertyDetailsIndex)));
Smi::cast(this->GetDataEntry(entry.as_int(), kPropertyDetailsIndex)));
}
// Set the details for entry.
inline void SmallOrderedNameDictionary::DetailsAtPut(int entry,
inline void SmallOrderedNameDictionary::DetailsAtPut(InternalIndex entry,
PropertyDetails value) {
// TODO(gsathya): Optimize the cast away. And store this in the data table.
this->SetDataEntry(entry, kPropertyDetailsIndex, value.AsSmi());
this->SetDataEntry(entry.as_int(), kPropertyDetailsIndex, value.AsSmi());
}
inline bool OrderedHashSet::Is(Handle<HeapObject> table) {
......
This diff is collapsed.
......@@ -403,7 +403,7 @@ class SmallOrderedHashTable : public HeapObject {
// we've already reached MaxCapacity.
static MaybeHandle<Derived> Grow(Isolate* isolate, Handle<Derived> table);
int FindEntry(Isolate* isolate, Object key);
InternalIndex FindEntry(Isolate* isolate, Object key);
static Handle<Derived> Shrink(Isolate* isolate, Handle<Derived> table);
// Iterates only fields in the DataTable.
......@@ -450,7 +450,11 @@ class SmallOrderedHashTable : public HeapObject {
int NumberOfBuckets() const { return getByte(NumberOfBucketsOffset(), 0); }
V8_INLINE Object KeyAt(int entry) const;
V8_INLINE Object KeyAt(InternalIndex entry) const;
InternalIndex::Range IterateEntries() {
return InternalIndex::Range(UsedCapacity());
}
DECL_VERIFIER(SmallOrderedHashTable)
......@@ -800,24 +804,26 @@ class V8_EXPORT_PRIVATE OrderedNameDictionaryHandler
static Handle<HeapObject> Shrink(Isolate* isolate, Handle<HeapObject> table);
static Handle<HeapObject> DeleteEntry(Isolate* isolate,
Handle<HeapObject> table, int entry);
static int FindEntry(Isolate* isolate, HeapObject table, Name key);
static void SetEntry(HeapObject table, int entry, Object key, Object value,
PropertyDetails details);
Handle<HeapObject> table,
InternalIndex entry);
static InternalIndex FindEntry(Isolate* isolate, HeapObject table, Name key);
static void SetEntry(HeapObject table, InternalIndex entry, Object key,
Object value, PropertyDetails details);
// Returns the value for entry.
static Object ValueAt(HeapObject table, int entry);
static Object ValueAt(HeapObject table, InternalIndex entry);
// Set the value for entry.
static void ValueAtPut(HeapObject table, int entry, Object value);
static void ValueAtPut(HeapObject table, InternalIndex entry, Object value);
// Returns the property details for the property at entry.
static PropertyDetails DetailsAt(HeapObject table, int entry);
static PropertyDetails DetailsAt(HeapObject table, InternalIndex entry);
// Set the details for entry.
static void DetailsAtPut(HeapObject table, int entry, PropertyDetails value);
static void DetailsAtPut(HeapObject table, InternalIndex entry,
PropertyDetails value);
static Name KeyAt(HeapObject table, int entry);
static Name KeyAt(HeapObject table, InternalIndex entry);
static void SetHash(HeapObject table, int hash);
static int Hash(HeapObject table);
......@@ -825,8 +831,6 @@ class V8_EXPORT_PRIVATE OrderedNameDictionaryHandler
static int NumberOfElements(HeapObject table);
static int Capacity(HeapObject table);
static const int kNotFound = -1;
protected:
static MaybeHandle<OrderedNameDictionary> AdjustRepresentation(
Isolate* isolate, Handle<SmallOrderedNameDictionary> table);
......@@ -841,23 +845,24 @@ class SmallOrderedNameDictionary
DECL_VERIFIER(SmallOrderedNameDictionary)
// Returns the value for entry.
inline Object ValueAt(int entry);
inline Object ValueAt(InternalIndex entry);
static Handle<SmallOrderedNameDictionary> Rehash(
Isolate* isolate, Handle<SmallOrderedNameDictionary> table,
int new_capacity);
V8_EXPORT_PRIVATE static Handle<SmallOrderedNameDictionary> DeleteEntry(
Isolate* isolate, Handle<SmallOrderedNameDictionary> table, int entry);
Isolate* isolate, Handle<SmallOrderedNameDictionary> table,
InternalIndex entry);
// Set the value for entry.
inline void ValueAtPut(int entry, Object value);
inline void ValueAtPut(InternalIndex entry, Object value);
// Returns the property details for the property at entry.
inline PropertyDetails DetailsAt(int entry);
inline PropertyDetails DetailsAt(InternalIndex entry);
// Set the details for entry.
inline void DetailsAtPut(int entry, PropertyDetails value);
inline void DetailsAtPut(InternalIndex entry, PropertyDetails value);
inline void SetHash(int hash);
inline int Hash();
......@@ -875,7 +880,7 @@ class SmallOrderedNameDictionary
Isolate* isolate, Handle<SmallOrderedNameDictionary> table,
Handle<Name> key, Handle<Object> value, PropertyDetails details);
V8_EXPORT_PRIVATE void SetEntry(int entry, Object key, Object value,
V8_EXPORT_PRIVATE void SetEntry(InternalIndex entry, Object key, Object value,
PropertyDetails details);
static inline Handle<Map> GetMap(ReadOnlyRoots roots);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment