Skip to content

Commit 6105c99

Browse files
deps: patch V8 to support compilation with MSVC
This patches V8 v12.4 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
1 parent afb9fbf commit 6105c99

17 files changed

+100
-118
lines changed

common.gypi

+3
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@
286286
'VCCLCompilerTool': {
287287
'AdditionalOptions': [
288288
'/Zc:__cplusplus',
289+
# The following option fixes the "error C1060: compiler is out of heap space"
290+
'/Zm1000',
291+
# The following option enables c++20 on Windows. This is needed for V8 v12.4+
289292
'-std:c++20'
290293
],
291294
'BufferSecurityCheck': 'true',

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -2784,7 +2784,7 @@ TNode<IntPtrT> WeakCollectionsBuiltinsAssembler::ValueIndexFromKeyIndex(
27842784
TNode<IntPtrT> key_index) {
27852785
return IntPtrAdd(
27862786
key_index,
2787-
IntPtrConstant(EphemeronHashTable::TodoShape::kEntryValueIndex -
2787+
IntPtrConstant(EphemeronHashTable::ShapeT::kEntryValueIndex -
27882788
EphemeronHashTable::kEntryKeyIndex));
27892789
}
27902790

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -9719,7 +9719,7 @@ void CodeStubAssembler::NameDictionaryLookup(
97199719
break;
97209720
case kFindExisting:
97219721
case kFindExistingOrInsertionIndex:
9722-
if (Dictionary::TodoShape::kMatchNeedsHoleCheck) {
9722+
if (Dictionary::ShapeT::kMatchNeedsHoleCheck) {
97239723
GotoIf(TaggedEqual(current, TheHoleConstant()), &next_probe);
97249724
}
97259725
current = LoadName<Dictionary>(current);

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1577,7 +1577,7 @@ class V8_EXPORT_PRIVATE CodeStubAssembler
15771577
TNode<Smi> LoadFixedArrayBaseLength(TNode<FixedArrayBase> array);
15781578
template <typename Array>
15791579
TNode<Smi> LoadArrayCapacity(TNode<Array> array) {
1580-
return LoadObjectField<Smi>(array, Array::Shape::kCapacityOffset);
1580+
return LoadObjectField<Smi>(array, Array::ShapeT::kCapacityOffset);
15811581
}
15821582
// Load the length of a fixed array base instance.
15831583
TNode<IntPtrT> LoadAndUntagFixedArrayBaseLength(TNode<FixedArrayBase> array);

deps/v8/src/compiler/backend/instruction-selector-adapter.h

+4-3
Original file line numberDiff line numberDiff line change
@@ -855,12 +855,13 @@ struct TurboshaftAdapter : public turboshaft::OperationMatcher {
855855
*traps_on_null = load_->kind.trap_on_null;
856856
#if V8_ENABLE_WEBASSEMBLY
857857
} else {
858-
DCHECK((load_transform_ && !load_transform_->load_kind.trap_on_null)
859858
#if V8_ENABLE_WASM_SIMD256_REVEC
859+
DCHECK((load_transform_ && !load_transform_->load_kind.trap_on_null)
860860
|| (load_transform256_ &&
861-
!load_transform256_->load_kind.trap_on_null)
861+
!load_transform256_->load_kind.trap_on_null));
862+
#else
863+
DCHECK((load_transform_ && !load_transform_->load_kind.trap_on_null));
862864
#endif // V8_ENABLE_WASM_SIMD256_REVEC
863-
);
864865
*traps_on_null = false;
865866
#endif // V8_ENABLE_WEBASSEMBLY
866867
}

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

+15-16
Original file line numberDiff line numberDiff line change
@@ -1161,8 +1161,7 @@ class TurboshaftAssemblerOpInterface
11611161

11621162
template <typename... Args>
11631163
explicit TurboshaftAssemblerOpInterface(Args... args)
1164-
: GenericAssemblerOpInterface<Next>(args...),
1165-
matcher_(Asm().output_graph()) {}
1164+
: matcher_(Asm().output_graph()) {}
11661165

11671166
const OperationMatcher& matcher() const { return matcher_; }
11681167

@@ -2420,11 +2419,11 @@ class TurboshaftAssemblerOpInterface
24202419

24212420
// Helpers to read the most common fields.
24222421
// TODO(nicohartmann@): Strengthen this to `V<HeapObject>`.
2423-
V<Map> LoadMapField(V<Object> object) {
2424-
return LoadField<Map>(object, AccessBuilder::ForMap());
2422+
V<v8::internal::Map> LoadMapField(V<Object> object) {
2423+
return LoadField<v8::internal::Map>(object, AccessBuilder::ForMap());
24252424
}
24262425

2427-
V<Word32> LoadInstanceTypeField(V<Map> map) {
2426+
V<Word32> LoadInstanceTypeField(V<v8::internal::Map> map) {
24282427
return LoadField<Word32>(map, AccessBuilder::ForMapInstanceType());
24292428
}
24302429

@@ -3114,7 +3113,7 @@ class TurboshaftAssemblerOpInterface
31143113
V<Object> CallRuntime_TransitionElementsKind(Isolate* isolate,
31153114
V<Context> context,
31163115
V<HeapObject> object,
3117-
V<Map> target_map) {
3116+
V<v8::internal::Map> target_map) {
31183117
return CallRuntime<typename RuntimeCallDescriptor::TransitionElementsKind>(
31193118
isolate, context, {object, target_map});
31203119
}
@@ -3532,8 +3531,8 @@ class TurboshaftAssemblerOpInterface
35323531

35333532
void TransitionAndStoreArrayElement(
35343533
V<Object> array, V<WordPtr> index, OpIndex value,
3535-
TransitionAndStoreArrayElementOp::Kind kind, MaybeHandle<Map> fast_map,
3536-
MaybeHandle<Map> double_map) {
3534+
TransitionAndStoreArrayElementOp::Kind kind, MaybeHandle<v8::internal::Map> fast_map,
3535+
MaybeHandle<v8::internal::Map> double_map) {
35373536
ReduceIfReachableTransitionAndStoreArrayElement(array, index, value, kind,
35383537
fast_map, double_map);
35393538
}
@@ -3546,17 +3545,17 @@ class TurboshaftAssemblerOpInterface
35463545
}
35473546

35483547
V<Word32> CompareMaps(V<HeapObject> heap_object,
3549-
const ZoneRefSet<Map>& maps) {
3548+
const ZoneRefSet<v8::internal::Map>& maps) {
35503549
return ReduceIfReachableCompareMaps(heap_object, maps);
35513550
}
35523551

35533552
void CheckMaps(V<HeapObject> heap_object, OpIndex frame_state,
3554-
const ZoneRefSet<Map>& maps, CheckMapsFlags flags,
3553+
const ZoneRefSet<v8::internal::Map>& maps, CheckMapsFlags flags,
35553554
const FeedbackSource& feedback) {
35563555
ReduceIfReachableCheckMaps(heap_object, frame_state, maps, flags, feedback);
35573556
}
35583557

3559-
void AssumeMap(V<HeapObject> heap_object, const ZoneRefSet<Map>& maps) {
3558+
void AssumeMap(V<HeapObject> heap_object, const ZoneRefSet<v8::internal::Map>& maps) {
35603559
ReduceIfReachableAssumeMap(heap_object, maps);
35613560
}
35623561

@@ -3665,16 +3664,16 @@ class TurboshaftAssemblerOpInterface
36653664
return ReduceIfReachableAssertNotNull(object, type, trap_id);
36663665
}
36673666

3668-
V<Map> RttCanon(V<FixedArray> rtts, uint32_t type_index) {
3667+
V<v8::internal::Map> RttCanon(V<FixedArray> rtts, uint32_t type_index) {
36693668
return ReduceIfReachableRttCanon(rtts, type_index);
36703669
}
36713670

3672-
V<Word32> WasmTypeCheck(V<Object> object, OptionalV<Map> rtt,
3671+
V<Word32> WasmTypeCheck(V<Object> object, OptionalV<v8::internal::Map> rtt,
36733672
WasmTypeCheckConfig config) {
36743673
return ReduceIfReachableWasmTypeCheck(object, rtt, config);
36753674
}
36763675

3677-
V<Object> WasmTypeCast(V<Object> object, OptionalV<Map> rtt,
3676+
V<Object> WasmTypeCast(V<Object> object, OptionalV<v8::internal::Map> rtt,
36783677
WasmTypeCheckConfig config) {
36793678
return ReduceIfReachableWasmTypeCast(object, rtt, config);
36803679
}
@@ -3719,12 +3718,12 @@ class TurboshaftAssemblerOpInterface
37193718
return ReduceIfReachableArrayLength(array, null_check);
37203719
}
37213720

3722-
V<HeapObject> WasmAllocateArray(V<Map> rtt, ConstOrV<Word32> length,
3721+
V<HeapObject> WasmAllocateArray(V<v8::internal::Map> rtt, ConstOrV<Word32> length,
37233722
const wasm::ArrayType* array_type) {
37243723
return ReduceIfReachableWasmAllocateArray(rtt, resolve(length), array_type);
37253724
}
37263725

3727-
V<HeapObject> WasmAllocateStruct(V<Map> rtt,
3726+
V<HeapObject> WasmAllocateStruct(V<v8::internal::Map> rtt,
37283727
const wasm::StructType* struct_type) {
37293728
return ReduceIfReachableWasmAllocateStruct(rtt, struct_type);
37303729
}

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

+10-40
Original file line numberDiff line numberDiff line change
@@ -1467,53 +1467,23 @@ class MachineOptimizationReducer : public Next {
14671467
if (matcher.MatchConstantShiftRightArithmeticShiftOutZeros(
14681468
left, &x, rep_w, &k1) &&
14691469
matcher.MatchIntegralWordConstant(right, rep_w, &k2) &&
1470-
CountLeadingSignBits(k2, rep_w) > k1) {
1471-
if (matcher.Get(left).saturated_use_count.IsZero()) {
1472-
return __ Comparison(
1473-
x, __ WordConstant(base::bits::Unsigned(k2) << k1, rep_w), kind,
1474-
rep_w);
1475-
} else if constexpr (reducer_list_contains<
1476-
ReducerList, ValueNumberingReducer>::value) {
1477-
// If the shift has uses, we only apply the transformation if the
1478-
// result would be GVNed away.
1479-
OpIndex rhs =
1480-
__ WordConstant(base::bits::Unsigned(k2) << k1, rep_w);
1481-
static_assert(ComparisonOp::input_count == 2);
1482-
static_assert(sizeof(ComparisonOp) == 8);
1483-
base::SmallVector<OperationStorageSlot, 32> storage;
1484-
ComparisonOp* cmp =
1485-
CreateOperation<ComparisonOp>(storage, x, rhs, kind, rep_w);
1486-
if (__ WillGVNOp(*cmp)) {
1487-
return __ Comparison(x, rhs, kind, rep_w);
1488-
}
1489-
}
1470+
CountLeadingSignBits(k2, rep_w) > k1 &&
1471+
matcher.Get(left).saturated_use_count.IsZero()) {
1472+
return __ Comparison(
1473+
x, __ WordConstant(base::bits::Unsigned(k2) << k1, rep_w), kind,
1474+
rep_w);
14901475
}
14911476
// k2 </<= (x >> k1) => (k2 << k1) </<= x if shifts reversible
14921477
// Only perform the transformation if the shift is not used yet, to
14931478
// avoid keeping both the shift and x alive.
14941479
if (matcher.MatchConstantShiftRightArithmeticShiftOutZeros(
14951480
right, &x, rep_w, &k1) &&
14961481
matcher.MatchIntegralWordConstant(left, rep_w, &k2) &&
1497-
CountLeadingSignBits(k2, rep_w) > k1) {
1498-
if (matcher.Get(right).saturated_use_count.IsZero()) {
1499-
return __ Comparison(
1500-
__ WordConstant(base::bits::Unsigned(k2) << k1, rep_w), x, kind,
1501-
rep_w);
1502-
} else if constexpr (reducer_list_contains<
1503-
ReducerList, ValueNumberingReducer>::value) {
1504-
// If the shift has uses, we only apply the transformation if the
1505-
// result would be GVNed away.
1506-
OpIndex lhs =
1507-
__ WordConstant(base::bits::Unsigned(k2) << k1, rep_w);
1508-
static_assert(ComparisonOp::input_count == 2);
1509-
static_assert(sizeof(ComparisonOp) == 8);
1510-
base::SmallVector<OperationStorageSlot, 32> storage;
1511-
ComparisonOp* cmp =
1512-
CreateOperation<ComparisonOp>(storage, lhs, x, kind, rep_w);
1513-
if (__ WillGVNOp(*cmp)) {
1514-
return __ Comparison(lhs, x, kind, rep_w);
1515-
}
1516-
}
1482+
CountLeadingSignBits(k2, rep_w) > k1 &&
1483+
matcher.Get(right).saturated_use_count.IsZero()) {
1484+
return __ Comparison(
1485+
__ WordConstant(base::bits::Unsigned(k2) << k1, rep_w), x, kind,
1486+
rep_w);
15171487
}
15181488
}
15191489
// 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
@@ -3580,7 +3580,7 @@ void Heap::RightTrimArray(Tagged<Array> object, int new_capacity,
35803580
}
35813581

35823582
const int bytes_to_trim =
3583-
(old_capacity - new_capacity) * Array::Shape::kElementSize;
3583+
(old_capacity - new_capacity) * Array::HotfixShape::kElementSize;
35843584

35853585
// Calculate location of new array end.
35863586
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)