| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8a2b62e commit e6125cd
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,7 +39,7 @@ | |||
| 39 | 39 | ||
| 40 | 40 | # Reset this number to 0 on major V8 upgrades. | |
| 41 | 41 | # Increment by one for each non-official patch applied to deps/v8. | |
| 42 | - 'v8_embedder_string': '-node.28', | ||
| 42 | + 'v8_embedder_string': '-node.29', | ||
| 43 | 43 | ||
| 44 | 44 | ##### V8 defaults for Node.js ##### | |
| 45 | 45 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -61,13 +61,13 @@ BaseNameDictionary<Derived, Shape>::BaseNameDictionary(Address ptr) | |||
| 61 | 61 | : Dictionary<Derived, Shape>(ptr) {} | |
| 62 | 62 | ||
| 63 | 63 | template <typename Derived, typename Shape> | |
| 64 | - void BaseNameDictionary<Derived, Shape>::SetNextEnumerationIndex(int index) { | ||
| 65 | - DCHECK_NE(0, index); | ||
| 64 | + void BaseNameDictionary<Derived, Shape>::set_next_enumeration_index(int index) { | ||
| 65 | + DCHECK_LT(0, index); | ||
| 66 | 66 | this->set(kNextEnumerationIndexIndex, Smi::FromInt(index)); | |
| 67 | 67 | } | |
| 68 | 68 | ||
| 69 | 69 | template <typename Derived, typename Shape> | |
| 70 | - int BaseNameDictionary<Derived, Shape>::NextEnumerationIndex() { | ||
| 70 | + int BaseNameDictionary<Derived, Shape>::next_enumeration_index() { | ||
| 71 | 71 | return Smi::ToInt(this->get(kNextEnumerationIndexIndex)); | |
| 72 | 72 | } | |
| 73 | 73 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -120,10 +120,6 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) BaseNameDictionary | |||
| 120 | 120 | static const int kObjectHashIndex = kNextEnumerationIndexIndex + 1; | |
| 121 | 121 | static const int kEntryValueIndex = 1; | |
| 122 | 122 | ||
| 123 | - // Accessors for next enumeration index. | ||
| 124 | - inline void SetNextEnumerationIndex(int index); | ||
| 125 | - inline int NextEnumerationIndex(); | ||
| 126 | - | ||
| 127 | 123 | inline void SetHash(int hash); | |
| 128 | 124 | inline int Hash() const; | |
| 129 | 125 | ||
@@ -138,6 +134,13 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) BaseNameDictionary | |||
| 138 | 134 | V8_WARN_UNUSED_RESULT static ExceptionStatus CollectKeysTo( | |
| 139 | 135 | Handle<Derived> dictionary, KeyAccumulator* keys); | |
| 140 | 136 | ||
| 137 | + // Allocate the next enumeration index. Possibly updates all enumeration | ||
| 138 | + // indices in the table. | ||
| 139 | + static int NextEnumerationIndex(Isolate* isolate, Handle<Derived> dictionary); | ||
| 140 | + // Accessors for next enumeration index. | ||
| 141 | + inline int next_enumeration_index(); | ||
| 142 | + inline void set_next_enumeration_index(int index); | ||
| 143 | + | ||
| 141 | 144 | // Return the key indices sorted by its enumeration index. | |
| 142 | 145 | static Handle<FixedArray> IterationIndices(Isolate* isolate, | |
| 143 | 146 | Handle<Derived> dictionary); | |
@@ -149,10 +152,6 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) BaseNameDictionary | |||
| 149 | 152 | Handle<FixedArray> storage, KeyCollectionMode mode, | |
| 150 | 153 | KeyAccumulator* accumulator); | |
| 151 | 154 | ||
| 152 | - // Ensure enough space for n additional elements. | ||
| 153 | - static Handle<Derived> EnsureCapacity(Isolate* isolate, | ||
| 154 | - Handle<Derived> dictionary, int n); | ||
| 155 | - | ||
| 156 | 155 | V8_WARN_UNUSED_RESULT static Handle<Derived> AddNoUpdateNextEnumerationIndex( | |
| 157 | 156 | Isolate* isolate, Handle<Derived> dictionary, Key key, | |
| 158 | 157 | Handle<Object> value, PropertyDetails details, int* entry_out = nullptr); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -201,7 +201,7 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable | |||
| 201 | 201 | ||
| 202 | 202 | // Ensure enough space for n additional elements. | |
| 203 | 203 | V8_WARN_UNUSED_RESULT static Handle<Derived> EnsureCapacity( | |
| 204 | - Isolate* isolate, Handle<Derived> table, int n, | ||
| 204 | + Isolate* isolate, Handle<Derived> table, int n = 1, | ||
| 205 | 205 | AllocationType allocation = AllocationType::kYoung); | |
| 206 | 206 | ||
| 207 | 207 | // Returns true if this table has sufficient capacity for adding n elements. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2908,7 +2908,7 @@ void MigrateFastToSlow(Isolate* isolate, Handle<JSObject> object, | |||
| 2908 | 2908 | } | |
| 2909 | 2909 | ||
| 2910 | 2910 | // Copy the next enumeration index from instance descriptor. | |
| 2911 | - dictionary->SetNextEnumerationIndex(real_size + 1); | ||
| 2911 | + dictionary->set_next_enumeration_index(real_size + 1); | ||
| 2912 | 2912 | ||
| 2913 | 2913 | // From here on we cannot fail and we shouldn't GC anymore. | |
| 2914 | 2914 | DisallowHeapAllocation no_allocation; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -363,7 +363,7 @@ class ObjectDescriptor { | |||
| 363 | 363 | ||
| 364 | 364 | void Finalize(Isolate* isolate) { | |
| 365 | 365 | if (HasDictionaryProperties()) { | |
| 366 | - properties_dictionary_template_->SetNextEnumerationIndex( | ||
| 366 | + properties_dictionary_template_->set_next_enumeration_index( | ||
| 367 | 367 | next_enumeration_index_); | |
| 368 | 368 | computed_properties_ = FixedArray::ShrinkOrEmpty( | |
| 369 | 369 | isolate, computed_properties_, current_computed_index_); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -634,8 +634,8 @@ void LookupIterator::PrepareTransitionToDataProperty( | |||
| 634 | 634 | transition_ = cell; | |
| 635 | 635 | // Assign an enumeration index to the property and update | |
| 636 | 636 | // SetNextEnumerationIndex. | |
| 637 | - int index = dictionary->NextEnumerationIndex(); | ||
| 638 | - dictionary->SetNextEnumerationIndex(index + 1); | ||
| 637 | + int index = GlobalDictionary::NextEnumerationIndex(isolate_, dictionary); | ||
| 638 | + dictionary->set_next_enumeration_index(index + 1); | ||
| 639 | 639 | property_details_ = PropertyDetails( | |
| 640 | 640 | kData, attributes, PropertyCellType::kUninitialized, index); | |
| 641 | 641 | PropertyCellType new_type = | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6677,7 +6677,7 @@ void StringTable::EnsureCapacityForDeserialization(Isolate* isolate, | |||
| 6677 | 6677 | int expected) { | |
| 6678 | 6678 | Handle<StringTable> table = isolate->factory()->string_table(); | |
| 6679 | 6679 | // We need a key instance for the virtual hash function. | |
| 6680 | - table = StringTable::EnsureCapacity(isolate, table, expected); | ||
| 6680 | + table = EnsureCapacity(isolate, table, expected); | ||
| 6681 | 6681 | isolate->heap()->SetRootStringTable(*table); | |
| 6682 | 6682 | } | |
| 6683 | 6683 | ||
@@ -6729,7 +6729,7 @@ Handle<String> StringTable::LookupKey(Isolate* isolate, StringTableKey* key) { | |||
| 6729 | 6729 | ||
| 6730 | 6730 | table = StringTable::CautiousShrink(isolate, table); | |
| 6731 | 6731 | // Adding new string. Grow table if needed. | |
| 6732 | - table = StringTable::EnsureCapacity(isolate, table, 1); | ||
| 6732 | + table = EnsureCapacity(isolate, table); | ||
| 6733 | 6733 | isolate->heap()->SetRootStringTable(*table); | |
| 6734 | 6734 | ||
| 6735 | 6735 | return AddKeyNoResize(isolate, key); | |
@@ -6870,7 +6870,7 @@ Handle<StringSet> StringSet::New(Isolate* isolate) { | |||
| 6870 | 6870 | Handle<StringSet> StringSet::Add(Isolate* isolate, Handle<StringSet> stringset, | |
| 6871 | 6871 | Handle<String> name) { | |
| 6872 | 6872 | if (!stringset->Has(isolate, name)) { | |
| 6873 | - stringset = EnsureCapacity(isolate, stringset, 1); | ||
| 6873 | + stringset = EnsureCapacity(isolate, stringset); | ||
| 6874 | 6874 | uint32_t hash = ShapeT::Hash(isolate, *name); | |
| 6875 | 6875 | int entry = stringset->FindInsertionEntry(hash); | |
| 6876 | 6876 | stringset->set(EntryToIndex(entry), *name); | |
@@ -6888,7 +6888,7 @@ Handle<ObjectHashSet> ObjectHashSet::Add(Isolate* isolate, | |||
| 6888 | 6888 | Handle<Object> key) { | |
| 6889 | 6889 | int32_t hash = key->GetOrCreateHash(isolate).value(); | |
| 6890 | 6890 | if (!set->Has(isolate, key, hash)) { | |
| 6891 | - set = EnsureCapacity(isolate, set, 1); | ||
| 6891 | + set = EnsureCapacity(isolate, set); | ||
| 6892 | 6892 | int entry = set->FindInsertionEntry(hash); | |
| 6893 | 6893 | set->set(EntryToIndex(entry), *key); | |
| 6894 | 6894 | set->ElementAdded(); | |
@@ -7084,7 +7084,7 @@ Handle<CompilationCacheTable> CompilationCacheTable::PutScript( | |||
| 7084 | 7084 | src = String::Flatten(isolate, src); | |
| 7085 | 7085 | StringSharedKey key(src, shared, language_mode, kNoSourcePosition); | |
| 7086 | 7086 | Handle<Object> k = key.AsHandle(isolate); | |
| 7087 | - cache = EnsureCapacity(isolate, cache, 1); | ||
| 7087 | + cache = EnsureCapacity(isolate, cache); | ||
| 7088 | 7088 | int entry = cache->FindInsertionEntry(key.Hash()); | |
| 7089 | 7089 | cache->set(EntryToIndex(entry), *k); | |
| 7090 | 7090 | cache->set(EntryToIndex(entry) + 1, *value); | |
@@ -7116,7 +7116,7 @@ Handle<CompilationCacheTable> CompilationCacheTable::PutEval( | |||
| 7116 | 7116 | } | |
| 7117 | 7117 | } | |
| 7118 | 7118 | ||
| 7119 | - cache = EnsureCapacity(isolate, cache, 1); | ||
| 7119 | + cache = EnsureCapacity(isolate, cache); | ||
| 7120 | 7120 | int entry = cache->FindInsertionEntry(key.Hash()); | |
| 7121 | 7121 | Handle<Object> k = | |
| 7122 | 7122 | isolate->factory()->NewNumber(static_cast<double>(key.Hash())); | |
@@ -7130,7 +7130,7 @@ Handle<CompilationCacheTable> CompilationCacheTable::PutRegExp( | |||
| 7130 | 7130 | Isolate* isolate, Handle<CompilationCacheTable> cache, Handle<String> src, | |
| 7131 | 7131 | JSRegExp::Flags flags, Handle<FixedArray> value) { | |
| 7132 | 7132 | RegExpKey key(src, flags); | |
| 7133 | - cache = EnsureCapacity(isolate, cache, 1); | ||
| 7133 | + cache = EnsureCapacity(isolate, cache); | ||
| 7134 | 7134 | int entry = cache->FindInsertionEntry(key.Hash()); | |
| 7135 | 7135 | // We store the value in the key slot, and compare the search key | |
| 7136 | 7136 | // to the stored value with a custon IsMatch function during lookups. | |
@@ -7192,15 +7192,16 @@ Handle<Derived> BaseNameDictionary<Derived, Shape>::New( | |||
| 7192 | 7192 | Handle<Derived> dict = Dictionary<Derived, Shape>::New( | |
| 7193 | 7193 | isolate, at_least_space_for, allocation, capacity_option); | |
| 7194 | 7194 | dict->SetHash(PropertyArray::kNoHashSentinel); | |
| 7195 | - dict->SetNextEnumerationIndex(PropertyDetails::kInitialIndex); | ||
| 7195 | + dict->set_next_enumeration_index(PropertyDetails::kInitialIndex); | ||
| 7196 | 7196 | return dict; | |
| 7197 | 7197 | } | |
| 7198 | 7198 | ||
| 7199 | 7199 | template <typename Derived, typename Shape> | |
| 7200 | - Handle<Derived> BaseNameDictionary<Derived, Shape>::EnsureCapacity( | ||
| 7201 | - Isolate* isolate, Handle<Derived> dictionary, int n) { | ||
| 7202 | - // Check whether there are enough enumeration indices to add n elements. | ||
| 7203 | - if (!PropertyDetails::IsValidIndex(dictionary->NextEnumerationIndex() + n)) { | ||
| 7200 | + int BaseNameDictionary<Derived, Shape>::NextEnumerationIndex( | ||
| 7201 | + Isolate* isolate, Handle<Derived> dictionary) { | ||
| 7202 | + int index = dictionary->next_enumeration_index(); | ||
| 7203 | + // Check whether the next enumeration index is valid. | ||
| 7204 | + if (!PropertyDetails::IsValidIndex(index)) { | ||
| 7204 | 7205 | // If not, we generate new indices for the properties. | |
| 7205 | 7206 | int length = dictionary->NumberOfElements(); | |
| 7206 | 7207 | ||
@@ -7221,11 +7222,12 @@ Handle<Derived> BaseNameDictionary<Derived, Shape>::EnsureCapacity( | |||
| 7221 | 7222 | dictionary->DetailsAtPut(isolate, index, new_details); | |
| 7222 | 7223 | } | |
| 7223 | 7224 | ||
| 7224 | - // Set the next enumeration index. | ||
| 7225 | - dictionary->SetNextEnumerationIndex(PropertyDetails::kInitialIndex + | ||
| 7226 | - length); | ||
| 7225 | + index = PropertyDetails::kInitialIndex + length; | ||
| 7227 | 7226 | } | |
| 7228 | - return HashTable<Derived, Shape>::EnsureCapacity(isolate, dictionary, n); | ||
| 7227 | + | ||
| 7228 | + // Don't update the next enumeration index here, since we might be looking at | ||
| 7229 | + // an immutable empty dictionary. | ||
| 7230 | + return index; | ||
| 7229 | 7231 | } | |
| 7230 | 7232 | ||
| 7231 | 7233 | template <typename Derived, typename Shape> | |
@@ -7274,13 +7276,13 @@ Handle<Derived> BaseNameDictionary<Derived, Shape>::Add( | |||
| 7274 | 7276 | DCHECK_EQ(0, details.dictionary_index()); | |
| 7275 | 7277 | // Assign an enumeration index to the property and update | |
| 7276 | 7278 | // SetNextEnumerationIndex. | |
| 7277 | - int index = dictionary->NextEnumerationIndex(); | ||
| 7279 | + int index = Derived::NextEnumerationIndex(isolate, dictionary); | ||
| 7278 | 7280 | details = details.set_index(index); | |
| 7279 | 7281 | dictionary = AddNoUpdateNextEnumerationIndex(isolate, dictionary, key, value, | |
| 7280 | 7282 | details, entry_out); | |
| 7281 | 7283 | // Update enumeration index here in order to avoid potential modification of | |
| 7282 | 7284 | // the canonical empty dictionary which lives in read only space. | |
| 7283 | - dictionary->SetNextEnumerationIndex(index + 1); | ||
| 7285 | + dictionary->set_next_enumeration_index(index + 1); | ||
| 7284 | 7286 | return dictionary; | |
| 7285 | 7287 | } | |
| 7286 | 7288 | ||
@@ -7294,7 +7296,7 @@ Handle<Derived> Dictionary<Derived, Shape>::Add(Isolate* isolate, | |||
| 7294 | 7296 | // Valdate key is absent. | |
| 7295 | 7297 | SLOW_DCHECK((dictionary->FindEntry(isolate, key) == Dictionary::kNotFound)); | |
| 7296 | 7298 | // Check whether the dictionary should be extended. | |
| 7297 | - dictionary = Derived::EnsureCapacity(isolate, dictionary, 1); | ||
| 7299 | + dictionary = Derived::EnsureCapacity(isolate, dictionary); | ||
| 7298 | 7300 | ||
| 7299 | 7301 | // Compute the key object. | |
| 7300 | 7302 | Handle<Object> k = Shape::AsHandle(isolate, key); | |
@@ -7644,7 +7646,7 @@ Handle<Derived> ObjectHashTableBase<Derived, Shape>::Put(Isolate* isolate, | |||
| 7644 | 7646 | } | |
| 7645 | 7647 | ||
| 7646 | 7648 | // Check whether the hash table should be extended. | |
| 7647 | - table = Derived::EnsureCapacity(isolate, table, 1); | ||
| 7649 | + table = Derived::EnsureCapacity(isolate, table); | ||
| 7648 | 7650 | table->AddEntry(table->FindInsertionEntry(hash), *key, *value); | |
| 7649 | 7651 | return table; | |
| 7650 | 7652 | } | |
@@ -7892,8 +7894,8 @@ Handle<PropertyCell> PropertyCell::PrepareForValue( | |||
| 7892 | 7894 | // Preserve the enumeration index unless the property was deleted or never | |
| 7893 | 7895 | // initialized. | |
| 7894 | 7896 | if (cell->value().IsTheHole(isolate)) { | |
| 7895 | - index = dictionary->NextEnumerationIndex(); | ||
| 7896 | - dictionary->SetNextEnumerationIndex(index + 1); | ||
| 7897 | + index = GlobalDictionary::NextEnumerationIndex(isolate, dictionary); | ||
| 7898 | + dictionary->set_next_enumeration_index(index + 1); | ||
| 7897 | 7899 | } else { | |
| 7898 | 7900 | index = original_details.dictionary_index(); | |
| 7899 | 7901 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments