| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent fe99841 commit 9c356ba
5 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.16', | ||
| 42 | + 'v8_embedder_string': '-node.17', | ||
| 43 | 43 | ||
| 44 | 44 | ##### V8 defaults for Node.js ##### | |
| 45 | 45 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,8 +7,10 @@ | |||
| 7 | 7 | ||
| 8 | 8 | #include "src/objects/dictionary.h" | |
| 9 | 9 | ||
| 10 | + #include "src/execution/isolate-utils-inl.h" | ||
| 10 | 11 | #include "src/numbers/hash-seed-inl.h" | |
| 11 | 12 | #include "src/objects/hash-table-inl.h" | |
| 13 | + #include "src/objects/objects-inl.h" | ||
| 12 | 14 | #include "src/objects/oddball.h" | |
| 13 | 15 | #include "src/objects/property-cell-inl.h" | |
| 14 | 16 | ||
@@ -27,10 +29,62 @@ template <typename Derived, typename Shape> | |||
| 27 | 29 | Dictionary<Derived, Shape>::Dictionary(Address ptr) | |
| 28 | 30 | : HashTable<Derived, Shape>(ptr) {} | |
| 29 | 31 | ||
| 32 | + template <typename Derived, typename Shape> | ||
| 33 | + Object Dictionary<Derived, Shape>::ValueAt(int entry) { | ||
| 34 | + Isolate* isolate = GetIsolateForPtrCompr(*this); | ||
| 35 | + return ValueAt(isolate, entry); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + template <typename Derived, typename Shape> | ||
| 39 | + Object Dictionary<Derived, Shape>::ValueAt(Isolate* isolate, int entry) { | ||
| 40 | + return this->get(isolate, DerivedHashTable::EntryToIndex(entry) + 1); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + template <typename Derived, typename Shape> | ||
| 44 | + void Dictionary<Derived, Shape>::ValueAtPut(int entry, Object value) { | ||
| 45 | + this->set(DerivedHashTable::EntryToIndex(entry) + 1, value); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + template <typename Derived, typename Shape> | ||
| 49 | + PropertyDetails Dictionary<Derived, Shape>::DetailsAt(int entry) { | ||
| 50 | + return Shape::DetailsAt(Derived::cast(*this), entry); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + template <typename Derived, typename Shape> | ||
| 54 | + void Dictionary<Derived, Shape>::DetailsAtPut(Isolate* isolate, int entry, | ||
| 55 | + PropertyDetails value) { | ||
| 56 | + Shape::DetailsAtPut(isolate, Derived::cast(*this), entry, value); | ||
| 57 | + } | ||
| 58 | + | ||
| 30 | 59 | template <typename Derived, typename Shape> | |
| 31 | 60 | BaseNameDictionary<Derived, Shape>::BaseNameDictionary(Address ptr) | |
| 32 | 61 | : Dictionary<Derived, Shape>(ptr) {} | |
| 33 | 62 | ||
| 63 | + template <typename Derived, typename Shape> | ||
| 64 | + void BaseNameDictionary<Derived, Shape>::SetNextEnumerationIndex(int index) { | ||
| 65 | + DCHECK_NE(0, index); | ||
| 66 | + this->set(kNextEnumerationIndexIndex, Smi::FromInt(index)); | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + template <typename Derived, typename Shape> | ||
| 70 | + int BaseNameDictionary<Derived, Shape>::NextEnumerationIndex() { | ||
| 71 | + return Smi::ToInt(this->get(kNextEnumerationIndexIndex)); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + template <typename Derived, typename Shape> | ||
| 75 | + void BaseNameDictionary<Derived, Shape>::SetHash(int hash) { | ||
| 76 | + DCHECK(PropertyArray::HashField::is_valid(hash)); | ||
| 77 | + this->set(kObjectHashIndex, Smi::FromInt(hash)); | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + template <typename Derived, typename Shape> | ||
| 81 | + int BaseNameDictionary<Derived, Shape>::Hash() const { | ||
| 82 | + Object hash_obj = this->get(kObjectHashIndex); | ||
| 83 | + int hash = Smi::ToInt(hash_obj); | ||
| 84 | + DCHECK(PropertyArray::HashField::is_valid(hash)); | ||
| 85 | + return hash; | ||
| 86 | + } | ||
| 87 | + | ||
| 34 | 88 | GlobalDictionary::GlobalDictionary(Address ptr) | |
| 35 | 89 | : BaseNameDictionary<GlobalDictionary, GlobalDictionaryShape>(ptr) { | |
| 36 | 90 | SLOW_DCHECK(IsGlobalDictionary()); | |
@@ -90,6 +144,25 @@ void Dictionary<Derived, Shape>::SetEntry(Isolate* isolate, int entry, | |||
| 90 | 144 | if (Shape::kHasDetails) DetailsAtPut(isolate, entry, details); | |
| 91 | 145 | } | |
| 92 | 146 | ||
| 147 | + template <typename Key> | ||
| 148 | + template <typename Dictionary> | ||
| 149 | + PropertyDetails BaseDictionaryShape<Key>::DetailsAt(Dictionary dict, | ||
| 150 | + int entry) { | ||
| 151 | + STATIC_ASSERT(Dictionary::kEntrySize == 3); | ||
| 152 | + DCHECK_GE(entry, 0); // Not found is -1, which is not caught by get(). | ||
| 153 | + return PropertyDetails(Smi::cast(dict.get(Dictionary::EntryToIndex(entry) + | ||
| 154 | + Dictionary::kEntryDetailsIndex))); | ||
| 155 | + } | ||
| 156 | + | ||
| 157 | + template <typename Key> | ||
| 158 | + template <typename Dictionary> | ||
| 159 | + void BaseDictionaryShape<Key>::DetailsAtPut(Isolate* isolate, Dictionary dict, | ||
| 160 | + int entry, PropertyDetails value) { | ||
| 161 | + STATIC_ASSERT(Dictionary::kEntrySize == 3); | ||
| 162 | + dict.set(Dictionary::EntryToIndex(entry) + Dictionary::kEntryDetailsIndex, | ||
| 163 | + value.AsSmi()); | ||
| 164 | + } | ||
| 165 | + | ||
| 93 | 166 | Object GlobalDictionaryShape::Unwrap(Object object) { | |
| 94 | 167 | return PropertyCell::cast(object).name(); | |
| 95 | 168 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,28 +31,17 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) Dictionary | |||
| 31 | 31 | public: | |
| 32 | 32 | using Key = typename Shape::Key; | |
| 33 | 33 | // Returns the value at entry. | |
| 34 | - Object ValueAt(int entry) { | ||
| 35 | - Isolate* isolate = GetIsolateForPtrCompr(*this); | ||
| 36 | - return ValueAt(isolate, entry); | ||
| 37 | - } | ||
| 38 | - Object ValueAt(Isolate* isolate, int entry) { | ||
| 39 | - return this->get(isolate, DerivedHashTable::EntryToIndex(entry) + 1); | ||
| 40 | - } | ||
| 34 | + inline Object ValueAt(int entry); | ||
| 35 | + inline Object ValueAt(Isolate* isolate, int entry); | ||
| 41 | 36 | ||
| 42 | 37 | // Set the value for entry. | |
| 43 | - void ValueAtPut(int entry, Object value) { | ||
| 44 | - this->set(DerivedHashTable::EntryToIndex(entry) + 1, value); | ||
| 45 | - } | ||
| 38 | + inline void ValueAtPut(int entry, Object value); | ||
| 46 | 39 | ||
| 47 | 40 | // Returns the property details for the property at entry. | |
| 48 | - PropertyDetails DetailsAt(int entry) { | ||
| 49 | - return Shape::DetailsAt(Derived::cast(*this), entry); | ||
| 50 | - } | ||
| 41 | + inline PropertyDetails DetailsAt(int entry); | ||
| 51 | 42 | ||
| 52 | 43 | // Set the details for entry. | |
| 53 | - void DetailsAtPut(Isolate* isolate, int entry, PropertyDetails value) { | ||
| 54 | - Shape::DetailsAtPut(isolate, Derived::cast(*this), entry, value); | ||
| 55 | - } | ||
| 44 | + inline void DetailsAtPut(Isolate* isolate, int entry, PropertyDetails value); | ||
| 56 | 45 | ||
| 57 | 46 | // Delete a property from the dictionary. | |
| 58 | 47 | V8_WARN_UNUSED_RESULT static Handle<Derived> DeleteEntry( | |
@@ -100,20 +89,11 @@ class BaseDictionaryShape : public BaseShape<Key> { | |||
| 100 | 89 | public: | |
| 101 | 90 | static const bool kHasDetails = true; | |
| 102 | 91 | template <typename Dictionary> | |
| 103 | - static inline PropertyDetails DetailsAt(Dictionary dict, int entry) { | ||
| 104 | - STATIC_ASSERT(Dictionary::kEntrySize == 3); | ||
| 105 | - DCHECK_GE(entry, 0); // Not found is -1, which is not caught by get(). | ||
| 106 | - return PropertyDetails(Smi::cast(dict.get(Dictionary::EntryToIndex(entry) + | ||
| 107 | - Dictionary::kEntryDetailsIndex))); | ||
| 108 | - } | ||
| 92 | + static inline PropertyDetails DetailsAt(Dictionary dict, int entry); | ||
| 109 | 93 | ||
| 110 | 94 | template <typename Dictionary> | |
| 111 | 95 | static inline void DetailsAtPut(Isolate* isolate, Dictionary dict, int entry, | |
| 112 | - PropertyDetails value) { | ||
| 113 | - STATIC_ASSERT(Dictionary::kEntrySize == 3); | ||
| 114 | - dict.set(Dictionary::EntryToIndex(entry) + Dictionary::kEntryDetailsIndex, | ||
| 115 | - value.AsSmi()); | ||
| 116 | - } | ||
| 96 | + PropertyDetails value); | ||
| 117 | 97 | }; | |
| 118 | 98 | ||
| 119 | 99 | class NameDictionaryShape : public BaseDictionaryShape<Handle<Name>> { | |
@@ -141,26 +121,11 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) BaseNameDictionary | |||
| 141 | 121 | static const int kEntryValueIndex = 1; | |
| 142 | 122 | ||
| 143 | 123 | // Accessors for next enumeration index. | |
| 144 | - void SetNextEnumerationIndex(int index) { | ||
| 145 | - DCHECK_NE(0, index); | ||
| 146 | - this->set(kNextEnumerationIndexIndex, Smi::FromInt(index)); | ||
| 147 | - } | ||
| 124 | + inline void SetNextEnumerationIndex(int index); | ||
| 125 | + inline int NextEnumerationIndex(); | ||
| 148 | 126 | ||
| 149 | - int NextEnumerationIndex() { | ||
| 150 | - return Smi::ToInt(this->get(kNextEnumerationIndexIndex)); | ||
| 151 | - } | ||
| 152 | - | ||
| 153 | - void SetHash(int hash) { | ||
| 154 | - DCHECK(PropertyArray::HashField::is_valid(hash)); | ||
| 155 | - this->set(kObjectHashIndex, Smi::FromInt(hash)); | ||
| 156 | - } | ||
| 157 | - | ||
| 158 | - int Hash() const { | ||
| 159 | - Object hash_obj = this->get(kObjectHashIndex); | ||
| 160 | - int hash = Smi::ToInt(hash_obj); | ||
| 161 | - DCHECK(PropertyArray::HashField::is_valid(hash)); | ||
| 162 | - return hash; | ||
| 163 | - } | ||
| 127 | + inline void SetHash(int hash); | ||
| 128 | + inline int Hash() const; | ||
| 164 | 129 | ||
| 165 | 130 | // Creates a new dictionary. | |
| 166 | 131 | V8_WARN_UNUSED_RESULT static Handle<Derived> New( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,7 @@ | |||
| 7 | 7 | ||
| 8 | 8 | #include "src/objects/hash-table.h" | |
| 9 | 9 | ||
| 10 | + #include "src/execution/isolate-utils-inl.h" | ||
| 10 | 11 | #include "src/heap/heap.h" | |
| 11 | 12 | #include "src/objects/fixed-array-inl.h" | |
| 12 | 13 | #include "src/objects/heap-object-inl.h" | |
@@ -178,6 +179,17 @@ bool HashTable<Derived, Shape>::ToKey(Isolate* isolate, int entry, | |||
| 178 | 179 | return true; | |
| 179 | 180 | } | |
| 180 | 181 | ||
| 182 | + template <typename Derived, typename Shape> | ||
| 183 | + Object HashTable<Derived, Shape>::KeyAt(int entry) { | ||
| 184 | + Isolate* isolate = GetIsolateForPtrCompr(*this); | ||
| 185 | + return KeyAt(isolate, entry); | ||
| 186 | + } | ||
| 187 | + | ||
| 188 | + template <typename Derived, typename Shape> | ||
| 189 | + Object HashTable<Derived, Shape>::KeyAt(Isolate* isolate, int entry) { | ||
| 190 | + return get(isolate, EntryToIndex(entry) + kEntryKeyIndex); | ||
| 191 | + } | ||
| 192 | + | ||
| 181 | 193 | template <typename Derived, typename Shape> | |
| 182 | 194 | void HashTable<Derived, Shape>::set_key(int index, Object value) { | |
| 183 | 195 | DCHECK(!IsEphemeronHashTable()); | |
@@ -191,6 +203,16 @@ void HashTable<Derived, Shape>::set_key(int index, Object value, | |||
| 191 | 203 | FixedArray::set(index, value, mode); | |
| 192 | 204 | } | |
| 193 | 205 | ||
| 206 | + template <typename Derived, typename Shape> | ||
| 207 | + void HashTable<Derived, Shape>::SetCapacity(int capacity) { | ||
| 208 | + // To scale a computed hash code to fit within the hash table, we | ||
| 209 | + // use bit-wise AND with a mask, so the capacity must be positive | ||
| 210 | + // and non-zero. | ||
| 211 | + DCHECK_GT(capacity, 0); | ||
| 212 | + DCHECK_LE(capacity, kMaxCapacity); | ||
| 213 | + set(kCapacityIndex, Smi::FromInt(capacity)); | ||
| 214 | + } | ||
| 215 | + | ||
| 194 | 216 | template <typename KeyT> | |
| 195 | 217 | bool BaseShape<KeyT>::IsKey(ReadOnlyRoots roots, Object key) { | |
| 196 | 218 | return IsLive(roots, key); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -164,13 +164,8 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable | |||
| 164 | 164 | inline bool ToKey(Isolate* isolate, int entry, Object* out_k); | |
| 165 | 165 | ||
| 166 | 166 | // Returns the key at entry. | |
| 167 | - Object KeyAt(int entry) { | ||
| 168 | - Isolate* isolate = GetIsolateForPtrCompr(*this); | ||
| 169 | - return KeyAt(isolate, entry); | ||
| 170 | - } | ||
| 171 | - Object KeyAt(Isolate* isolate, int entry) { | ||
| 172 | - return get(isolate, EntryToIndex(entry) + kEntryKeyIndex); | ||
| 173 | - } | ||
| 167 | + inline Object KeyAt(int entry); | ||
| 168 | + inline Object KeyAt(Isolate* isolate, int entry); | ||
| 174 | 169 | ||
| 175 | 170 | static const int kElementsStartIndex = kPrefixStartIndex + Shape::kPrefixSize; | |
| 176 | 171 | static const int kEntrySize = Shape::kEntrySize; | |
@@ -239,14 +234,7 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable | |||
| 239 | 234 | kMaxRegularHeapObjectSize); | |
| 240 | 235 | ||
| 241 | 236 | // Sets the capacity of the hash table. | |
| 242 | - void SetCapacity(int capacity) { | ||
| 243 | - // To scale a computed hash code to fit within the hash table, we | ||
| 244 | - // use bit-wise AND with a mask, so the capacity must be positive | ||
| 245 | - // and non-zero. | ||
| 246 | - DCHECK_GT(capacity, 0); | ||
| 247 | - DCHECK_LE(capacity, kMaxCapacity); | ||
| 248 | - set(kCapacityIndex, Smi::FromInt(capacity)); | ||
| 249 | - } | ||
| 237 | + inline void SetCapacity(int capacity); | ||
| 250 | 238 | ||
| 251 | 239 | // Returns _expected_ if one of entries given by the first _probe_ probes is | |
| 252 | 240 | // equal to _expected_. Otherwise, returns the entry given by the probe | |
| Back | FazBrowse Home | New Git URL |
0 commit comments