From 6f293356b5b2fa7e4cdab3625703db4bbaae3fbc Mon Sep 17 00:00:00 2001 From: StefanStojanovic Date: Wed, 22 Nov 2023 11:43:34 +0100 Subject: [PATCH 1/3] partial revert https://github.com/v8/v8/commit/cb9bdcf313ee57338a520cceaa8901ef004fbf6b --- .../src/builtins/builtins-collections-gen.cc | 7 ++-- deps/v8/src/codegen/code-stub-assembler.cc | 2 +- deps/v8/src/objects/dictionary.h | 5 +-- deps/v8/src/objects/fixed-array.h | 13 +++--- deps/v8/src/objects/hash-table-inl.h | 12 +++--- deps/v8/src/objects/hash-table.h | 11 +++-- deps/v8/src/objects/objects.cc | 42 +++++++++---------- deps/v8/src/objects/template-objects.cc | 2 +- 8 files changed, 46 insertions(+), 48 deletions(-) diff --git a/deps/v8/src/builtins/builtins-collections-gen.cc b/deps/v8/src/builtins/builtins-collections-gen.cc index 26b33d8555..7ba6a1fa39 100644 --- a/deps/v8/src/builtins/builtins-collections-gen.cc +++ b/deps/v8/src/builtins/builtins-collections-gen.cc @@ -2582,10 +2582,9 @@ TNode WeakCollectionsBuiltinsAssembler::ShouldShrink( TNode WeakCollectionsBuiltinsAssembler::ValueIndexFromKeyIndex( TNode key_index) { - return IntPtrAdd( - key_index, - IntPtrConstant(EphemeronHashTable::TodoShape::kEntryValueIndex - - EphemeronHashTable::kEntryKeyIndex)); + return IntPtrAdd(key_index, + IntPtrConstant(EphemeronHashTable::ShapeT::kEntryValueIndex - + EphemeronHashTable::kEntryKeyIndex)); } TF_BUILTIN(WeakMapConstructor, WeakCollectionsBuiltinsAssembler) { diff --git a/deps/v8/src/codegen/code-stub-assembler.cc b/deps/v8/src/codegen/code-stub-assembler.cc index 29185ccccc..f8f1c128f8 100644 --- a/deps/v8/src/codegen/code-stub-assembler.cc +++ b/deps/v8/src/codegen/code-stub-assembler.cc @@ -9424,7 +9424,7 @@ void CodeStubAssembler::NameDictionaryLookup( CAST(UnsafeLoadFixedArrayElement(dictionary, index)); GotoIf(TaggedEqual(current, undefined), if_not_found); if (mode == kFindExisting) { - if (Dictionary::TodoShape::kMatchNeedsHoleCheck) { + if (Dictionary::ShapeT::kMatchNeedsHoleCheck) { GotoIf(TaggedEqual(current, TheHoleConstant()), &next_probe); } current = LoadName(current); diff --git a/deps/v8/src/objects/dictionary.h b/deps/v8/src/objects/dictionary.h index 58924206ea..9cfef9e0b1 100644 --- a/deps/v8/src/objects/dictionary.h +++ b/deps/v8/src/objects/dictionary.h @@ -32,8 +32,7 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) Dictionary using DerivedHashTable = HashTable; public: - using TodoShape = Shape; - using Key = typename TodoShape::Key; + using Key = typename Shape::Key; inline Tagged ValueAt(InternalIndex entry); inline Tagged ValueAt(PtrComprCageBase cage_base, InternalIndex entry); @@ -126,7 +125,7 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) Dictionary Key key, Handle value, PropertyDetails details); - OBJECT_CONSTRUCTORS(Dictionary, HashTable); + OBJECT_CONSTRUCTORS(Dictionary, HashTable); }; #define EXTERN_DECLARE_DICTIONARY(DERIVED, SHAPE) \ diff --git a/deps/v8/src/objects/fixed-array.h b/deps/v8/src/objects/fixed-array.h index b13916f3d6..91f366a805 100644 --- a/deps/v8/src/objects/fixed-array.h +++ b/deps/v8/src/objects/fixed-array.h @@ -23,12 +23,12 @@ namespace internal { #include "torque-generated/src/objects/fixed-array-tq.inc" // Derived: must have a Smi slot at kCapacityOffset. -template +template class TaggedArrayBase : public HeapObject { OBJECT_CONSTRUCTORS(TaggedArrayBase, HeapObject); - using ElementT = typename ShapeT::ElementT; - static_assert(ShapeT::kElementSize == kTaggedSize); + using ElementT = typename Shape::ElementT; + static_assert(Shape::kElementSize == kTaggedSize); static_assert(is_subtype_v || is_subtype_v); @@ -51,7 +51,7 @@ class TaggedArrayBase : public HeapObject { std::conditional_t; public: - using Shape = ShapeT; + using ShapeT = Shape; inline int capacity() const; inline int capacity(AcquireLoadTag) const; @@ -225,7 +225,7 @@ class FixedArray : public TaggedArrayBase { class BodyDescriptor; - static constexpr int kLengthOffset = FixedArray::Shape::kCapacityOffset; + static constexpr int kLengthOffset = FixedArray::ShapeT::kCapacityOffset; static constexpr int kMaxLength = FixedArray::kMaxCapacity; static constexpr int kMaxRegularLength = FixedArray::kMaxRegularCapacity; @@ -418,6 +418,7 @@ class WeakFixedArray OBJECT_CONSTRUCTORS(WeakFixedArray, Super); public: + using Shape = WeakFixedArrayShape; template static inline Handle New( IsolateT* isolate, int capacity, @@ -429,7 +430,7 @@ class WeakFixedArray class BodyDescriptor; - static constexpr int kLengthOffset = Shape::kCapacityOffset; + static constexpr int kLengthOffset = ShapeT::kCapacityOffset; }; // WeakArrayList is like a WeakFixedArray with static convenience methods for diff --git a/deps/v8/src/objects/hash-table-inl.h b/deps/v8/src/objects/hash-table-inl.h index 6d37e7d674..c3451d2fc2 100644 --- a/deps/v8/src/objects/hash-table-inl.h +++ b/deps/v8/src/objects/hash-table-inl.h @@ -170,7 +170,7 @@ template template InternalIndex HashTable::FindEntry(IsolateT* isolate, Key key) { ReadOnlyRoots roots(isolate); - return FindEntry(isolate, roots, key, TodoShape::Hash(roots, key)); + return FindEntry(isolate, roots, key, Shape::Hash(roots, key)); } // Find entry for key otherwise return kNotFound. @@ -183,7 +183,7 @@ InternalIndex HashTable::FindEntry(PtrComprCageBase cage_base, uint32_t count = 1; Tagged undefined = roots.undefined_value(); Tagged the_hole = roots.the_hole_value(); - DCHECK_EQ(TodoShape::Hash(roots, key), static_cast(hash)); + DCHECK_EQ(Shape::Hash(roots, key), static_cast(hash)); // EnsureCapacity will guarantee the hash table is never full. for (InternalIndex entry = FirstProbe(hash, capacity);; entry = NextProbe(entry, count++, capacity)) { @@ -191,8 +191,8 @@ InternalIndex HashTable::FindEntry(PtrComprCageBase cage_base, // Empty entry. Uses raw unchecked accessors because it is called by the // string table during bootstrapping. if (element == undefined) return InternalIndex::NotFound(); - if (TodoShape::kMatchNeedsHoleCheck && element == the_hole) continue; - if (TodoShape::IsMatch(key, element)) return entry; + if (Shape::kMatchNeedsHoleCheck && element == the_hole) continue; + if (Shape::IsMatch(key, element)) return entry; } } @@ -216,7 +216,7 @@ bool HashTable::ToKey(ReadOnlyRoots roots, InternalIndex entry, Tagged* out_k) { Tagged k = KeyAt(entry); if (!IsKey(roots, k)) return false; - *out_k = TodoShape::Unwrap(k); + *out_k = Shape::Unwrap(k); return true; } @@ -226,7 +226,7 @@ bool HashTable::ToKey(PtrComprCageBase cage_base, Tagged* out_k) { Tagged k = KeyAt(cage_base, entry); if (!IsKey(GetReadOnlyRoots(cage_base), k)) return false; - *out_k = TodoShape::Unwrap(k); + *out_k = Shape::Unwrap(k); return true; } diff --git a/deps/v8/src/objects/hash-table.h b/deps/v8/src/objects/hash-table.h index 6b25f043e8..6742b2573d 100644 --- a/deps/v8/src/objects/hash-table.h +++ b/deps/v8/src/objects/hash-table.h @@ -126,15 +126,15 @@ class V8_EXPORT_PRIVATE HashTableBase : public NON_EXPORTED_BASE(FixedArray) { OBJECT_CONSTRUCTORS(HashTableBase, FixedArray); }; -template +template class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable : public HashTableBase { public: // TODO(jgruber): Derive from TaggedArrayBase instead of FixedArray, and // merge with TaggedArraryBase's Shape class. Once the naming conflict is // resolved rename all TodoShape occurrences back to Shape. - using TodoShape = ShapeT; - using Key = typename TodoShape::Key; + using ShapeT = Shape; + using Key = typename Shape::Key; // Returns a new HashTable object. template @@ -177,9 +177,8 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable inline void SetKeyAt(InternalIndex entry, Tagged value, WriteBarrierMode mode = UPDATE_WRITE_BARRIER); - static const int kElementsStartIndex = - kPrefixStartIndex + TodoShape::kPrefixSize; - static const int kEntrySize = TodoShape::kEntrySize; + static const int kElementsStartIndex = kPrefixStartIndex + Shape::kPrefixSize; + static const int kEntrySize = Shape::kEntrySize; static_assert(kEntrySize > 0); static const int kEntryKeyIndex = 0; static const int kElementsStartOffset = diff --git a/deps/v8/src/objects/objects.cc b/deps/v8/src/objects/objects.cc index a231d33158..ea18ee28eb 100644 --- a/deps/v8/src/objects/objects.cc +++ b/deps/v8/src/objects/objects.cc @@ -5106,11 +5106,11 @@ void HashTable::Rehash(PtrComprCageBase cage_base, uint32_t from_index = EntryToIndex(i); Tagged k = this->get(from_index); if (!IsKey(roots, k)) continue; - uint32_t hash = TodoShape::HashForObject(roots, k); + uint32_t hash = Shape::HashForObject(roots, k); uint32_t insertion_index = EntryToIndex(new_table->FindInsertionEntry(cage_base, roots, hash)); new_table->set_key(insertion_index, get(from_index), mode); - for (int j = 1; j < TodoShape::kEntrySize; j++) { + for (int j = 1; j < Shape::kEntrySize; j++) { new_table->set(insertion_index + j, get(from_index + j), mode); } } @@ -5123,7 +5123,7 @@ InternalIndex HashTable::EntryForProbe(ReadOnlyRoots roots, Tagged k, int probe, InternalIndex expected) { - uint32_t hash = TodoShape::HashForObject(roots, k); + uint32_t hash = Shape::HashForObject(roots, k); uint32_t capacity = this->Capacity(); InternalIndex entry = FirstProbe(hash, capacity); for (int i = 1; i < probe; i++) { @@ -5138,17 +5138,17 @@ void HashTable::Swap(InternalIndex entry1, InternalIndex entry2, WriteBarrierMode mode) { int index1 = EntryToIndex(entry1); int index2 = EntryToIndex(entry2); - Tagged temp[TodoShape::kEntrySize]; + Tagged temp[Shape::kEntrySize]; Derived* self = static_cast(this); - for (int j = 0; j < TodoShape::kEntrySize; j++) { + for (int j = 0; j < Shape::kEntrySize; j++) { temp[j] = get(index1 + j); } self->set_key(index1, get(index2), mode); - for (int j = 1; j < TodoShape::kEntrySize; j++) { + for (int j = 1; j < Shape::kEntrySize; j++) { set(index1 + j, get(index2 + j), mode); } self->set_key(index2, temp[0], mode); - for (int j = 1; j < TodoShape::kEntrySize; j++) { + for (int j = 1; j < Shape::kEntrySize; j++) { set(index2 + j, temp[j], mode); } } @@ -5310,7 +5310,7 @@ GlobalDictionary::TryFindPropertyCellForConcurrentLookupIterator( DisallowGarbageCollection no_gc; PtrComprCageBase cage_base{isolate}; ReadOnlyRoots roots(isolate); - const int32_t hash = TodoShape::Hash(roots, name); + const int32_t hash = ShapeT::Hash(roots, name); const uint32_t capacity = Capacity(); uint32_t count = 1; Tagged undefined = roots.undefined_value(); @@ -5321,8 +5321,8 @@ GlobalDictionary::TryFindPropertyCellForConcurrentLookupIterator( Tagged element = KeyAt(cage_base, entry, kRelaxedLoad); if (isolate->heap()->IsPendingAllocation(element)) return {}; if (element == undefined) return {}; - if (TodoShape::kMatchNeedsHoleCheck && element == the_hole) continue; - if (!TodoShape::IsMatch(name, element)) continue; + if (ShapeT::kMatchNeedsHoleCheck && element == the_hole) continue; + if (!ShapeT::IsMatch(name, element)) continue; CHECK(IsPropertyCell(element, cage_base)); return PropertyCell::cast(element); } @@ -5336,7 +5336,7 @@ Handle StringSet::Add(Isolate* isolate, Handle stringset, Handle name) { if (!stringset->Has(isolate, name)) { stringset = EnsureCapacity(isolate, stringset); - uint32_t hash = TodoShape::Hash(ReadOnlyRoots(isolate), *name); + uint32_t hash = ShapeT::Hash(ReadOnlyRoots(isolate), *name); InternalIndex entry = stringset->FindInsertionEntry(isolate, hash); stringset->set(EntryToIndex(entry), *name); stringset->ElementAdded(); @@ -5355,7 +5355,7 @@ Handle RegisteredSymbolTable::Add( SLOW_DCHECK(table->FindEntry(isolate, key).is_not_found()); table = EnsureCapacity(isolate, table); - uint32_t hash = TodoShape::Hash(ReadOnlyRoots(isolate), key); + uint32_t hash = ShapeT::Hash(ReadOnlyRoots(isolate), key); InternalIndex entry = table->FindInsertionEntry(isolate, hash); table->set(EntryToIndex(entry), *key); table->set(EntryToValueIndex(entry), *symbol); @@ -5424,7 +5424,7 @@ int BaseNameDictionary::NextEnumerationIndex( template Handle Dictionary::DeleteEntry( Isolate* isolate, Handle dictionary, InternalIndex entry) { - DCHECK(TodoShape::kEntrySize != 3 || + DCHECK(Shape::kEntrySize != 3 || dictionary->DetailsAt(entry).IsConfigurable()); dictionary->ClearEntry(entry); dictionary->ElementRemoved(); @@ -5445,7 +5445,7 @@ Handle Dictionary::AtPut(Isolate* isolate, // We don't need to copy over the enumeration index. dictionary->ValueAtPut(entry, *value); - if (TodoShape::kEntrySize == 3) dictionary->DetailsAtPut(entry, details); + if (Shape::kEntrySize == 3) dictionary->DetailsAtPut(entry, details); return dictionary; } @@ -5462,7 +5462,7 @@ void Dictionary::UncheckedAtPut(Isolate* isolate, } else { // We don't need to copy over the enumeration index. dictionary->ValueAtPut(entry, *value); - if (TodoShape::kEntrySize == 3) dictionary->DetailsAtPut(entry, details); + if (Shape::kEntrySize == 3) dictionary->DetailsAtPut(entry, details); } } @@ -5503,19 +5503,19 @@ Handle Dictionary::Add(IsolateT* isolate, PropertyDetails details, InternalIndex* entry_out) { ReadOnlyRoots roots(isolate); - uint32_t hash = TodoShape::Hash(roots, key); + uint32_t hash = Shape::Hash(roots, key); // Validate that the key is absent. SLOW_DCHECK(dictionary->FindEntry(isolate, key).is_not_found()); // Check whether the dictionary should be extended. dictionary = Derived::EnsureCapacity(isolate, dictionary); // Compute the key object. - Handle k = TodoShape::template AsHandle(isolate, key); + Handle k = Shape::template AsHandle(isolate, key); InternalIndex entry = dictionary->FindInsertionEntry(isolate, roots, hash); dictionary->SetEntry(entry, *k, *value, details); DCHECK(IsNumber(dictionary->KeyAt(isolate, entry)) || - IsUniqueName(TodoShape::Unwrap(dictionary->KeyAt(isolate, entry)))); + IsUniqueName(Shape::Unwrap(dictionary->KeyAt(isolate, entry)))); dictionary->ElementAdded(); if (entry_out) *entry_out = entry; return dictionary; @@ -5528,18 +5528,18 @@ void Dictionary::UncheckedAdd(IsolateT* isolate, Key key, Handle value, PropertyDetails details) { ReadOnlyRoots roots(isolate); - uint32_t hash = TodoShape::Hash(roots, key); + uint32_t hash = Shape::Hash(roots, key); // Validate that the key is absent and we capacity is sufficient. SLOW_DCHECK(dictionary->FindEntry(isolate, key).is_not_found()); DCHECK(dictionary->HasSufficientCapacityToAdd(1)); // Compute the key object. - Handle k = TodoShape::template AsHandle(isolate, key); + Handle k = Shape::template AsHandle(isolate, key); InternalIndex entry = dictionary->FindInsertionEntry(isolate, roots, hash); dictionary->SetEntry(entry, *k, *value, details); DCHECK(IsNumber(dictionary->KeyAt(isolate, entry)) || - IsUniqueName(TodoShape::Unwrap(dictionary->KeyAt(isolate, entry)))); + IsUniqueName(Shape::Unwrap(dictionary->KeyAt(isolate, entry)))); } template diff --git a/deps/v8/src/objects/template-objects.cc b/deps/v8/src/objects/template-objects.cc index 003a02d301..d1146ad389 100644 --- a/deps/v8/src/objects/template-objects.cc +++ b/deps/v8/src/objects/template-objects.cc @@ -54,7 +54,7 @@ Handle TemplateObjectDescription::GetTemplateObject( // Check the template weakmap to see if the template object already exists. Handle