Skip to content

Commit c563a1c

Browse files
StefanStojanovicmarco-ippolito
authored andcommitted
deps: patch V8 to support compilation with MSVC
This patches V8 v12.3 for Windows, by fixing multiple compilation errors caused by V8 being a Clang-oriented project. There are various types of errors fixed by this going from changing `using` directives and renaming to overcoming the differences in which Clang and MSVC see templates and metaprogramming. The changes introduced here are strictly meant as a patch only, so they shouldn't be pushed upstream. Refs: targos#13 Refs: targos#14 Refs: targos#15 PR-URL: #52293 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Richard Lau <rlau@redhat.com>
1 parent 11e94b9 commit c563a1c

17 files changed

+106
-121
lines changed

common.gypi

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
# Reset this number to 0 on major V8 upgrades.
3939
# Increment by one for each non-official patch applied to deps/v8.
40-
'v8_embedder_string': '-node.6',
40+
'v8_embedder_string': '-node.7',
4141

4242
##### V8 defaults for Node.js #####
4343

deps/v8/src/builtins/builtins-collections-gen.cc

+3-4
Original file line numberDiff line numberDiff line change
@@ -2782,10 +2782,9 @@ TNode<Word32T> WeakCollectionsBuiltinsAssembler::ShouldShrink(
27822782

27832783
TNode<IntPtrT> WeakCollectionsBuiltinsAssembler::ValueIndexFromKeyIndex(
27842784
TNode<IntPtrT> key_index) {
2785-
return IntPtrAdd(
2786-
key_index,
2787-
IntPtrConstant(EphemeronHashTable::TodoShape::kEntryValueIndex -
2788-
EphemeronHashTable::kEntryKeyIndex));
2785+
return IntPtrAdd(key_index,
2786+
IntPtrConstant(EphemeronHashTable::ShapeT::kEntryValueIndex -
2787+
EphemeronHashTable::kEntryKeyIndex));
27892788
}
27902789

27912790
TF_BUILTIN(WeakMapConstructor, WeakCollectionsBuiltinsAssembler) {

deps/v8/src/codegen/code-stub-assembler.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -9505,7 +9505,7 @@ void CodeStubAssembler::NameDictionaryLookup(
95059505
CAST(UnsafeLoadFixedArrayElement(dictionary, index));
95069506
GotoIf(TaggedEqual(current, undefined), if_not_found_with_insertion_index);
95079507
if (mode == kFindExisting) {
9508-
if (Dictionary::TodoShape::kMatchNeedsHoleCheck) {
9508+
if (Dictionary::ShapeT::kMatchNeedsHoleCheck) {
95099509
GotoIf(TaggedEqual(current, TheHoleConstant()), &next_probe);
95109510
}
95119511
current = LoadName<Dictionary>(current);

deps/v8/src/codegen/code-stub-assembler.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1547,7 +1547,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
15471547
TNode<Smi> LoadFixedArrayBaseLength(TNode<FixedArrayBase> array);
15481548
template <typename Array>
15491549
TNode<Smi> LoadArrayCapacity(TNode<Array> array) {
1550-
return LoadObjectField<Smi>(array, Array::Shape::kCapacityOffset);
1550+
return LoadObjectField<Smi>(array, Array::ShapeT::kCapacityOffset);
15511551
}
15521552
// Load the length of a fixed array base instance.
15531553
TNode<IntPtrT> LoadAndUntagFixedArrayBaseLength(TNode<FixedArrayBase> array);

deps/v8/src/compiler/turboshaft/assembler.h

+23-18
Original file line numberDiff line numberDiff line change
@@ -1121,8 +1121,7 @@ class TurboshaftAssemblerOpInterface
11211121

11221122
template <typename... Args>
11231123
explicit TurboshaftAssemblerOpInterface(Args... args)
1124-
: GenericAssemblerOpInterface<Next>(args...),
1125-
matcher_(Asm().output_graph()) {}
1124+
: matcher_(Asm().output_graph()) {}
11261125

11271126
const OperationMatcher& matcher() const { return matcher_; }
11281127

@@ -2245,11 +2244,11 @@ class TurboshaftAssemblerOpInterface
22452244

22462245
// Helpers to read the most common fields.
22472246
// TODO(nicohartmann@): Strengthen this to `V<HeapObject>`.
2248-
V<Map> LoadMapField(V<Object> object) {
2249-
return LoadField<Map>(object, AccessBuilder::ForMap());
2247+
V<v8::internal::Map> LoadMapField(V<Object> object) {
2248+
return LoadField<v8::internal::Map>(object, AccessBuilder::ForMap());
22502249
}
22512250

2252-
V<Word32> LoadInstanceTypeField(V<Map> map) {
2251+
V<Word32> LoadInstanceTypeField(V<v8::internal::Map> map) {
22532252
return LoadField<Word32>(map, AccessBuilder::ForMapInstanceType());
22542253
}
22552254

@@ -2849,7 +2848,7 @@ class TurboshaftAssemblerOpInterface
28492848
V<Object> CallRuntime_TransitionElementsKind(Isolate* isolate,
28502849
V<Context> context,
28512850
V<HeapObject> object,
2852-
V<Map> target_map) {
2851+
V<v8::internal::Map> target_map) {
28532852
return CallRuntime<typename RuntimeCallDescriptor::TransitionElementsKind>(
28542853
isolate, context, {object, target_map});
28552854
}
@@ -3267,8 +3266,8 @@ class TurboshaftAssemblerOpInterface
32673266

32683267
void TransitionAndStoreArrayElement(
32693268
V<Object> array, V<WordPtr> index, OpIndex value,
3270-
TransitionAndStoreArrayElementOp::Kind kind, MaybeHandle<Map> fast_map,
3271-
MaybeHandle<Map> double_map) {
3269+
TransitionAndStoreArrayElementOp::Kind kind, MaybeHandle<v8::internal::Map> fast_map,
3270+
MaybeHandle<v8::internal::Map> double_map) {
32723271
ReduceIfReachableTransitionAndStoreArrayElement(array, index, value, kind,
32733272
fast_map, double_map);
32743273
}
@@ -3281,17 +3280,17 @@ class TurboshaftAssemblerOpInterface
32813280
}
32823281

32833282
V<Word32> CompareMaps(V<HeapObject> heap_object,
3284-
const ZoneRefSet<Map>& maps) {
3283+
const ZoneRefSet<v8::internal::Map>& maps) {
32853284
return ReduceIfReachableCompareMaps(heap_object, maps);
32863285
}
32873286

32883287
void CheckMaps(V<HeapObject> heap_object, OpIndex frame_state,
3289-
const ZoneRefSet<Map>& maps, CheckMapsFlags flags,
3288+
const ZoneRefSet<v8::internal::Map>& maps, CheckMapsFlags flags,
32903289
const FeedbackSource& feedback) {
32913290
ReduceIfReachableCheckMaps(heap_object, frame_state, maps, flags, feedback);
32923291
}
32933292

3294-
void AssumeMap(V<HeapObject> heap_object, const ZoneRefSet<Map>& maps) {
3293+
void AssumeMap(V<HeapObject> heap_object, const ZoneRefSet<v8::internal::Map>& maps) {
32953294
ReduceIfReachableAssumeMap(heap_object, maps);
32963295
}
32973296

@@ -3400,16 +3399,16 @@ class TurboshaftAssemblerOpInterface
34003399
return ReduceIfReachableAssertNotNull(object, type, trap_id);
34013400
}
34023401

3403-
V<Map> RttCanon(V<FixedArray> rtts, uint32_t type_index) {
3402+
V<v8::internal::Map> RttCanon(V<FixedArray> rtts, uint32_t type_index) {
34043403
return ReduceIfReachableRttCanon(rtts, type_index);
34053404
}
34063405

3407-
V<Word32> WasmTypeCheck(V<Tagged> object, OptionalV<Map> rtt,
3406+
V<Word32> WasmTypeCheck(V<Tagged> object, OptionalV<v8::internal::Map> rtt,
34083407
WasmTypeCheckConfig config) {
34093408
return ReduceIfReachableWasmTypeCheck(object, rtt, config);
34103409
}
34113410

3412-
V<Tagged> WasmTypeCast(V<Tagged> object, OptionalV<Map> rtt,
3411+
V<Tagged> WasmTypeCast(V<Tagged> object, OptionalV<v8::internal::Map> rtt,
34133412
WasmTypeCheckConfig config) {
34143413
return ReduceIfReachableWasmTypeCast(object, rtt, config);
34153414
}
@@ -3454,12 +3453,12 @@ class TurboshaftAssemblerOpInterface
34543453
return ReduceIfReachableArrayLength(array, null_check);
34553454
}
34563455

3457-
V<HeapObject> WasmAllocateArray(V<Map> rtt, ConstOrV<Word32> length,
3456+
V<HeapObject> WasmAllocateArray(V<v8::internal::Map> rtt, ConstOrV<Word32> length,
34583457
const wasm::ArrayType* array_type) {
34593458
return ReduceIfReachableWasmAllocateArray(rtt, resolve(length), array_type);
34603459
}
34613460

3462-
V<HeapObject> WasmAllocateStruct(V<Map> rtt,
3461+
V<HeapObject> WasmAllocateStruct(V<v8::internal::Map> rtt,
34633462
const wasm::StructType* struct_type) {
34643463
return ReduceIfReachableWasmAllocateStruct(rtt, struct_type);
34653464
}
@@ -4044,8 +4043,14 @@ class TSAssembler
40444043
: public Assembler<reducer_list<TurboshaftAssemblerOpInterface, Reducers...,
40454044
TSReducerBase>> {
40464045
public:
4047-
using Assembler<reducer_list<TurboshaftAssemblerOpInterface, Reducers...,
4048-
TSReducerBase>>::Assembler;
4046+
#ifdef _WIN32
4047+
explicit TSAssembler(Graph& input_graph, Graph& output_graph,
4048+
Zone* phase_zone)
4049+
: Assembler(input_graph, output_graph, phase_zone) {}
4050+
#else
4051+
using Assembler<reducer_list<TurboshaftAssemblerOpInterface, Reducers...,
4052+
TSReducerBase>>::Assembler;
4053+
#endif
40494054
};
40504055

40514056
#include "src/compiler/turboshaft/undef-assembler-macros.inc"

deps/v8/src/compiler/turboshaft/machine-optimization-reducer.h

+10-40
Original file line numberDiff line numberDiff line change
@@ -1349,53 +1349,23 @@ class MachineOptimizationReducer : public Next {
13491349
if (matcher.MatchConstantShiftRightArithmeticShiftOutZeros(
13501350
left, &x, rep_w, &k1) &&
13511351
matcher.MatchIntegralWordConstant(right, rep_w, &k2) &&
1352-
CountLeadingSignBits(k2, rep_w) > k1) {
1353-
if (matcher.Get(left).saturated_use_count.IsZero()) {
1354-
return __ Comparison(
1355-
x, __ WordConstant(base::bits::Unsigned(k2) << k1, rep_w), kind,
1356-
rep_w);
1357-
} else if constexpr (reducer_list_contains<
1358-
ReducerList, ValueNumberingReducer>::value) {
1359-
// If the shift has uses, we only apply the transformation if the
1360-
// result would be GVNed away.
1361-
OpIndex rhs =
1362-
__ WordConstant(base::bits::Unsigned(k2) << k1, rep_w);
1363-
static_assert(ComparisonOp::input_count == 2);
1364-
static_assert(sizeof(ComparisonOp) == 8);
1365-
base::SmallVector<OperationStorageSlot, 32> storage;
1366-
ComparisonOp* cmp =
1367-
CreateOperation<ComparisonOp>(storage, x, rhs, kind, rep_w);
1368-
if (__ WillGVNOp(*cmp)) {
1369-
return __ Comparison(x, rhs, kind, rep_w);
1370-
}
1371-
}
1352+
CountLeadingSignBits(k2, rep_w) > k1 &&
1353+
matcher.Get(left).saturated_use_count.IsZero()) {
1354+
return __ Comparison(
1355+
x, __ WordConstant(base::bits::Unsigned(k2) << k1, rep_w), kind,
1356+
rep_w);
13721357
}
13731358
// k2 </<= (x >> k1) => (k2 << k1) </<= x if shifts reversible
13741359
// Only perform the transformation if the shift is not used yet, to
13751360
// avoid keeping both the shift and x alive.
13761361
if (matcher.MatchConstantShiftRightArithmeticShiftOutZeros(
13771362
right, &x, rep_w, &k1) &&
13781363
matcher.MatchIntegralWordConstant(left, rep_w, &k2) &&
1379-
CountLeadingSignBits(k2, rep_w) > k1) {
1380-
if (matcher.Get(right).saturated_use_count.IsZero()) {
1381-
return __ Comparison(
1382-
__ WordConstant(base::bits::Unsigned(k2) << k1, rep_w), x, kind,
1383-
rep_w);
1384-
} else if constexpr (reducer_list_contains<
1385-
ReducerList, ValueNumberingReducer>::value) {
1386-
// If the shift has uses, we only apply the transformation if the
1387-
// result would be GVNed away.
1388-
OpIndex lhs =
1389-
__ WordConstant(base::bits::Unsigned(k2) << k1, rep_w);
1390-
static_assert(ComparisonOp::input_count == 2);
1391-
static_assert(sizeof(ComparisonOp) == 8);
1392-
base::SmallVector<OperationStorageSlot, 32> storage;
1393-
ComparisonOp* cmp =
1394-
CreateOperation<ComparisonOp>(storage, lhs, x, kind, rep_w);
1395-
if (__ WillGVNOp(*cmp)) {
1396-
return __ Comparison(lhs, x, kind, rep_w);
1397-
}
1398-
}
1364+
CountLeadingSignBits(k2, rep_w) > k1 &&
1365+
matcher.Get(right).saturated_use_count.IsZero()) {
1366+
return __ Comparison(
1367+
__ WordConstant(base::bits::Unsigned(k2) << k1, rep_w), x, kind,
1368+
rep_w);
13991369
}
14001370
}
14011371
// Map 64bit to 32bit comparisons.

deps/v8/src/compiler/turboshaft/simplified-lowering-reducer.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ class SimplifiedLoweringReducer : public Next {
3232
OpIndex ig_index, const SpeculativeNumberBinopOp& op) {
3333
DCHECK_EQ(op.kind, SpeculativeNumberBinopOp::Kind::kSafeIntegerAdd);
3434

35-
OpIndex frame_state = Map(op.frame_state());
36-
V<Word32> left = ProcessInput(Map(op.left()), Rep::Word32(),
35+
OpIndex frame_state = MapImpl(op.frame_state());
36+
V<Word32> left = ProcessInput(MapImpl(op.left()), Rep::Word32(),
3737
CheckKind::kSigned32, frame_state);
38-
V<Word32> right = ProcessInput(Map(op.right()), Rep::Word32(),
38+
V<Word32> right = ProcessInput(MapImpl(op.right()), Rep::Word32(),
3939
CheckKind::kSigned32, frame_state);
4040

4141
V<Word32> result = __ OverflowCheckedBinop(
4242
left, right, OverflowCheckedBinopOp::Kind::kSignedAdd,
4343
WordRepresentation::Word32());
4444

4545
V<Word32> overflow = __ Projection(result, 1, Rep::Word32());
46-
__ DeoptimizeIf(overflow, Map(op.frame_state()),
46+
__ DeoptimizeIf(overflow, MapImpl(op.frame_state()),
4747
DeoptimizeReason::kOverflow, FeedbackSource{});
4848
return __ Projection(result, 0, Rep::Word32());
4949
}
@@ -52,10 +52,10 @@ class SimplifiedLoweringReducer : public Next {
5252
base::SmallVector<OpIndex, 8> return_values;
5353
for (OpIndex input : ret.return_values()) {
5454
return_values.push_back(
55-
ProcessInput(Map(input), Rep::Tagged(), CheckKind::kNone, {}));
55+
ProcessInput(MapImpl(input), Rep::Tagged(), CheckKind::kNone, {}));
5656
}
5757

58-
__ Return(Map(ret.pop_count()), base::VectorOf(return_values));
58+
__ Return(MapImpl(ret.pop_count()), base::VectorOf(return_values));
5959
return OpIndex::Invalid();
6060
}
6161

@@ -94,7 +94,7 @@ class SimplifiedLoweringReducer : public Next {
9494
}
9595
}
9696

97-
inline OpIndex Map(OpIndex ig_index) { return __ MapToNewGraph(ig_index); }
97+
inline OpIndex MapImpl(OpIndex ig_index) { return __ MapToNewGraph(ig_index); }
9898
};
9999

100100
#include "src/compiler/turboshaft/undef-assembler-macros.inc"

deps/v8/src/compiler/turboshaft/variable-reducer.h

+2
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ namespace v8::internal::compiler::turboshaft {
5555
// with constant inputs introduced by `VariableReducer` need to be eliminated.
5656
template <class AfterNext>
5757
class VariableReducer : public RequiredOptimizationReducer<AfterNext> {
58+
protected:
5859
using Next = RequiredOptimizationReducer<AfterNext>;
5960
using Snapshot = SnapshotTable<OpIndex, VariableData>::Snapshot;
6061

62+
private:
6163
struct GetActiveLoopVariablesIndex {
6264
IntrusiveSetIndex& operator()(Variable var) const {
6365
return var.data().active_loop_variables_index;

deps/v8/src/heap/heap.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -3570,7 +3570,7 @@ void Heap::RightTrimArray(Tagged<Array> object, int new_capacity,
35703570
}
35713571

35723572
const int bytes_to_trim =
3573-
(old_capacity - new_capacity) * Array::Shape::kElementSize;
3573+
(old_capacity - new_capacity) * Array::HotfixShape::kElementSize;
35743574

35753575
// Calculate location of new array end.
35763576
const int old_size = Array::SizeFor(old_capacity);

deps/v8/src/objects/dictionary.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) Dictionary
3232
using DerivedHashTable = HashTable<Derived, Shape>;
3333

3434
public:
35-
using TodoShape = Shape;
36-
using Key = typename TodoShape::Key;
35+
using Key = typename Shape::Key;
3736
inline Tagged<Object> ValueAt(InternalIndex entry);
3837
inline Tagged<Object> ValueAt(PtrComprCageBase cage_base,
3938
InternalIndex entry);
@@ -126,7 +125,7 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) Dictionary
126125
Key key, Handle<Object> value,
127126
PropertyDetails details);
128127

129-
OBJECT_CONSTRUCTORS(Dictionary, HashTable<Derived, TodoShape>);
128+
OBJECT_CONSTRUCTORS(Dictionary, HashTable<Derived, Shape>);
130129
};
131130

132131
#define EXTERN_DECLARE_DICTIONARY(DERIVED, SHAPE) \

0 commit comments

Comments
 (0)