Skip to content

Commit 9c356ba

Browse files
targosMylesBorins
authored andcommitted
deps: V8: backport 5e755c6ee6d3
Original commit message: [objects] Move functions to inline headers This moves a series of functions from dictionary.h and hash-table.h to resp. dictionary-inl.h and hash-table-inl.h. The functions that were moved all somehow use other functions that are defined in -inl.h files. This change fixes the Node.js Windows builds. Change-Id: I0bbf0222beb3619a5e6f1fb451bc78691025de65 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1893346 Reviewed-by: Peter Marshall <[email protected]> Commit-Queue: Michaël Zasso <[email protected]> Cr-Commit-Position: refs/heads/master@{#64709} Refs: v8/v8@5e755c6 Backport-PR-URL: #30513 PR-URL: #30020 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Jiawen Geng <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Matteo Collina <[email protected]>
1 parent fe99841 commit 9c356ba

File tree

5 files changed

+110
-62
lines changed

5 files changed

+110
-62
lines changed

common.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
# Reset this number to 0 on major V8 upgrades.
4141
# Increment by one for each non-official patch applied to deps/v8.
42-
'v8_embedder_string': '-node.16',
42+
'v8_embedder_string': '-node.17',
4343

4444
##### V8 defaults for Node.js #####
4545

deps/v8/src/objects/dictionary-inl.h

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77

88
#include "src/objects/dictionary.h"
99

10+
#include "src/execution/isolate-utils-inl.h"
1011
#include "src/numbers/hash-seed-inl.h"
1112
#include "src/objects/hash-table-inl.h"
13+
#include "src/objects/objects-inl.h"
1214
#include "src/objects/oddball.h"
1315
#include "src/objects/property-cell-inl.h"
1416

@@ -27,10 +29,62 @@ template <typename Derived, typename Shape>
2729
Dictionary<Derived, Shape>::Dictionary(Address ptr)
2830
: HashTable<Derived, Shape>(ptr) {}
2931

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+
3059
template <typename Derived, typename Shape>
3160
BaseNameDictionary<Derived, Shape>::BaseNameDictionary(Address ptr)
3261
: Dictionary<Derived, Shape>(ptr) {}
3362

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+
3488
GlobalDictionary::GlobalDictionary(Address ptr)
3589
: BaseNameDictionary<GlobalDictionary, GlobalDictionaryShape>(ptr) {
3690
SLOW_DCHECK(IsGlobalDictionary());
@@ -90,6 +144,25 @@ void Dictionary<Derived, Shape>::SetEntry(Isolate* isolate, int entry,
90144
if (Shape::kHasDetails) DetailsAtPut(isolate, entry, details);
91145
}
92146

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+
93166
Object GlobalDictionaryShape::Unwrap(Object object) {
94167
return PropertyCell::cast(object).name();
95168
}

deps/v8/src/objects/dictionary.h

Lines changed: 11 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,17 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) Dictionary
3131
public:
3232
using Key = typename Shape::Key;
3333
// 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);
4136

4237
// 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);
4639

4740
// 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);
5142

5243
// 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);
5645

5746
// Delete a property from the dictionary.
5847
V8_WARN_UNUSED_RESULT static Handle<Derived> DeleteEntry(
@@ -100,20 +89,11 @@ class BaseDictionaryShape : public BaseShape<Key> {
10089
public:
10190
static const bool kHasDetails = true;
10291
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);
10993

11094
template <typename Dictionary>
11195
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);
11797
};
11898

11999
class NameDictionaryShape : public BaseDictionaryShape<Handle<Name>> {
@@ -141,26 +121,11 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) BaseNameDictionary
141121
static const int kEntryValueIndex = 1;
142122

143123
// 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();
148126

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;
164129

165130
// Creates a new dictionary.
166131
V8_WARN_UNUSED_RESULT static Handle<Derived> New(

deps/v8/src/objects/hash-table-inl.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include "src/objects/hash-table.h"
99

10+
#include "src/execution/isolate-utils-inl.h"
1011
#include "src/heap/heap.h"
1112
#include "src/objects/fixed-array-inl.h"
1213
#include "src/objects/heap-object-inl.h"
@@ -178,6 +179,17 @@ bool HashTable<Derived, Shape>::ToKey(Isolate* isolate, int entry,
178179
return true;
179180
}
180181

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+
181193
template <typename Derived, typename Shape>
182194
void HashTable<Derived, Shape>::set_key(int index, Object value) {
183195
DCHECK(!IsEphemeronHashTable());
@@ -191,6 +203,16 @@ void HashTable<Derived, Shape>::set_key(int index, Object value,
191203
FixedArray::set(index, value, mode);
192204
}
193205

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+
194216
template <typename KeyT>
195217
bool BaseShape<KeyT>::IsKey(ReadOnlyRoots roots, Object key) {
196218
return IsLive(roots, key);

deps/v8/src/objects/hash-table.h

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,8 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable
164164
inline bool ToKey(Isolate* isolate, int entry, Object* out_k);
165165

166166
// 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);
174169

175170
static const int kElementsStartIndex = kPrefixStartIndex + Shape::kPrefixSize;
176171
static const int kEntrySize = Shape::kEntrySize;
@@ -239,14 +234,7 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable
239234
kMaxRegularHeapObjectSize);
240235

241236
// 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);
250238

251239
// Returns _expected_ if one of entries given by the first _probe_ probes is
252240
// equal to _expected_. Otherwise, returns the entry given by the probe

0 commit comments

Comments
 (0)