deps: patch V8 to support compilation with MSVC

This patches V8 v12.2 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: https://github.com/targos/node/pull/13
Refs: https://github.com/targos/node/pull/14
PR-URL: https://github.com/nodejs/node/pull/51362
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
This commit is contained in:
StefanStojanovic authored and Michaël Zasso committed 2024-03-31 15:36:55 +02:00
1 parent 63b58bc17b
commit b9d806a2dd
31 files changed
+129 -131

No files matched your search

+1 -1
View File
@@ -37,7 +37,7 @@
# Reset this number to 0 on major V8 upgrades.
# Increment by one for each non-official patch applied to deps/v8.
'v8_embedder_string': '-node.6',
'v8_embedder_string': '-node.7',
##### V8 defaults for Node.js #####
+3 -4
View File
@@ -2782,10 +2782,9 @@ TNode<Word32T> WeakCollectionsBuiltinsAssembler::ShouldShrink(
TNode<IntPtrT> WeakCollectionsBuiltinsAssembler::ValueIndexFromKeyIndex(
TNode<IntPtrT> key_index) {
return IntPtrAdd(
key_index,
IntPtrConstant(EphemeronHashTable::TodoShape::kEntryValueIndex -
EphemeronHashTable::kEntryKeyIndex));
return IntPtrAdd(key_index,
IntPtrConstant(EphemeronHashTable::ShapeT::kEntryValueIndex -
EphemeronHashTable::kEntryKeyIndex));
}
TF_BUILTIN(WeakMapConstructor, WeakCollectionsBuiltinsAssembler) {
+1 -1
View File
@@ -9455,7 +9455,7 @@ void CodeStubAssembler::NameDictionaryLookup(
CAST(UnsafeLoadFixedArrayElement(dictionary, index));
GotoIf(TaggedEqual(current, undefined), if_not_found);
if (mode == kFindExisting) {
if (Dictionary::TodoShape::kMatchNeedsHoleCheck) {
if (Dictionary::ShapeT::kMatchNeedsHoleCheck) {
GotoIf(TaggedEqual(current, TheHoleConstant()), &next_probe);
}
current = LoadName<Dictionary>(current);
+6
View File
@@ -3934,8 +3934,14 @@ class TSAssembler
: public Assembler<reducer_list<TurboshaftAssemblerOpInterface, Reducers...,
TSReducerBase>> {
public:
#ifdef _WIN32
explicit TSAssembler(Graph& input_graph, Graph& output_graph,
Zone* phase_zone)
: Assembler(input_graph, output_graph, phase_zone) {}
#else
using Assembler<reducer_list<TurboshaftAssemblerOpInterface, Reducers...,
TSReducerBase>>::Assembler;
#endif
};
#include "src/compiler/turboshaft/undef-assembler-macros.inc"
@@ -32,7 +32,8 @@ void CodeEliminationAndSimplificationPhase::Run(Zone* temp_zone) {
// (which, for simplificy, doesn't use the Assembler helper
// methods, but only calls Next::ReduceLoad/Store).
DuplicationOptimizationReducer,
ValueNumberingReducer>::Run(temp_zone);
VariableReducerHotfix,
ValueNumberingReducer>::Run<false>(temp_zone);
}
} // namespace v8::internal::compiler::turboshaft
+25 -10
View File
@@ -36,6 +36,18 @@ struct PaddingSpace {
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
PaddingSpace padding);
template <class Next>
class VariableReducerHotfix : public Next {
public:
TURBOSHAFT_REDUCER_BOILERPLATE()
void SetVariable(Variable var, OpIndex new_index) {}
Variable NewLoopInvariantVariable(MaybeRegisterRepresentation rep) { return Variable(); }
OpIndex GetVariable(Variable var) { return OpIndex(); }
OpIndex GetPredecessorValue(Variable var, int predecessor_index) { return OpIndex(); }
};
template <typename Next>
class ReducerBaseForwarder;
template <typename Next>
@@ -46,6 +58,9 @@ class GraphVisitor : public Next {
template <typename N>
friend class ReducerBaseForwarder;
private:
bool contains_variable_reducer_;
public:
TURBOSHAFT_REDUCER_BOILERPLATE()
@@ -66,7 +81,8 @@ class GraphVisitor : public Next {
// `trace_reduction` is a template parameter to avoid paying for tracing at
// runtime.
template <bool trace_reduction>
void VisitGraph() {
void VisitGraph(bool contains_variable_reducer) {
contains_variable_reducer_ = contains_variable_reducer;
Asm().Analyze();
// Creating initial old-to-new Block mapping.
@@ -177,8 +193,7 @@ class GraphVisitor : public Next {
DCHECK(old_index.valid());
OpIndex result = op_mapping_[old_index];
if constexpr (reducer_list_contains<typename Next::ReducerList,
VariableReducer>::value) {
if (contains_variable_reducer_) {
if (!result.valid()) {
// {op_mapping} doesn't have a mapping for {old_index}. The assembler
// should provide the mapping.
@@ -1294,8 +1309,7 @@ class GraphVisitor : public Next {
DCHECK(Asm().input_graph().BelongsToThisGraph(old_index));
DCHECK_IMPLIES(new_index.valid(),
Asm().output_graph().BelongsToThisGraph(new_index));
if constexpr (reducer_list_contains<typename Next::ReducerList,
VariableReducer>::value) {
if (contains_variable_reducer_) {
if (current_block_needs_variables_) {
MaybeVariable var = GetVariableFor(old_index);
if (!var.has_value()) {
@@ -1393,17 +1407,17 @@ template <template <class> class... Reducers>
class CopyingPhaseImpl {
public:
static void Run(Graph& input_graph, Zone* phase_zone,
bool trace_reductions = false) {
bool contains_variable_reducer, bool trace_reductions = false) {
TSAssembler<GraphVisitor, Reducers...> phase(
input_graph, input_graph.GetOrCreateCompanion(), phase_zone);
#ifdef DEBUG
if (trace_reductions) {
phase.template VisitGraph<true>();
phase.template VisitGraph<true>(contains_variable_reducer);
} else {
phase.template VisitGraph<false>();
phase.template VisitGraph<false>(contains_variable_reducer);
}
#else
phase.template VisitGraph<false>();
phase.template VisitGraph<false>(contains_variable_reducer);
#endif // DEBUG
}
};
@@ -1411,11 +1425,12 @@ class CopyingPhaseImpl {
template <template <typename> typename... Reducers>
class CopyingPhase {
public:
template <bool contains_variable_reducer>
static void Run(Zone* phase_zone) {
PipelineData& data = PipelineData::Get();
Graph& input_graph = data.graph();
CopyingPhaseImpl<Reducers...>::Run(
input_graph, phase_zone, data.info()->turboshaft_trace_reduction());
input_graph, phase_zone, contains_variable_reducer, data.info()->turboshaft_trace_reduction());
}
};
+5 -5
View File
@@ -25,23 +25,23 @@ namespace v8::internal::compiler::turboshaft {
void CsaLoadEliminationPhase::Run(Zone* temp_zone) {
CopyingPhase<VariableReducer, MachineOptimizationReducer,
RequiredOptimizationReducer,
ValueNumberingReducer>::Run(temp_zone);
ValueNumberingReducer>::Run<true>(temp_zone);
CopyingPhase<VariableReducer, LateLoadEliminationReducer,
MachineOptimizationReducer, RequiredOptimizationReducer,
ValueNumberingReducer>::Run(temp_zone);
ValueNumberingReducer>::Run<true>(temp_zone);
}
void CsaLateEscapeAnalysisPhase::Run(Zone* temp_zone) {
CopyingPhase<VariableReducer, LateEscapeAnalysisReducer,
MachineOptimizationReducer, RequiredOptimizationReducer,
ValueNumberingReducer>::Run(temp_zone);
ValueNumberingReducer>::Run<true>(temp_zone);
}
void CsaBranchEliminationPhase::Run(Zone* temp_zone) {
CopyingPhase<VariableReducer, MachineOptimizationReducer,
BranchEliminationReducer, RequiredOptimizationReducer,
ValueNumberingReducer>::Run(temp_zone);
ValueNumberingReducer>::Run<true>(temp_zone);
}
void CsaOptimizePhase::Run(Zone* temp_zone) {
@@ -51,7 +51,7 @@ void CsaOptimizePhase::Run(Zone* temp_zone) {
CopyingPhase<VariableReducer, PretenuringPropagationReducer,
MachineOptimizationReducer, MemoryOptimizationReducer,
RequiredOptimizationReducer,
ValueNumberingReducer>::Run(temp_zone);
ValueNumberingReducer>::Run<true>(temp_zone);
}
} // namespace v8::internal::compiler::turboshaft
@@ -11,7 +11,7 @@ namespace v8::internal::compiler::turboshaft {
void DebugFeatureLoweringPhase::Run(Zone* temp_zone) {
#ifdef V8_ENABLE_DEBUG_CODE
turboshaft::CopyingPhase<turboshaft::DebugFeatureLoweringReducer>::Run(
turboshaft::CopyingPhase<turboshaft::DebugFeatureLoweringReducer>::Run<false>(
temp_zone);
#endif
}
+1 -1
View File
@@ -16,7 +16,7 @@ void Int64LoweringPhase::Run(Zone* temp_zone) {
#if V8_TARGET_ARCH_32_BIT
turboshaft::CopyingPhase<
turboshaft::Int64LoweringReducer, turboshaft::VariableReducer,
turboshaft::RequiredOptimizationReducer>::Run(temp_zone);
turboshaft::RequiredOptimizationReducer>::Run<true>(temp_zone);
#else
UNREACHABLE();
#endif
+1 -1
View File
@@ -23,7 +23,7 @@ void LoopPeelingPhase::Run(Zone* temp_zone) {
turboshaft::VariableReducer,
turboshaft::MachineOptimizationReducer,
turboshaft::RequiredOptimizationReducer,
turboshaft::ValueNumberingReducer>::Run(temp_zone);
turboshaft::ValueNumberingReducer>::Run<true>(temp_zone);
}
} // namespace v8::internal::compiler::turboshaft
+1 -1
View File
@@ -22,7 +22,7 @@ void LoopUnrollingPhase::Run(Zone* temp_zone) {
turboshaft::VariableReducer,
turboshaft::MachineOptimizationReducer,
turboshaft::RequiredOptimizationReducer,
turboshaft::ValueNumberingReducer>::Run(temp_zone);
turboshaft::ValueNumberingReducer>::Run<true>(temp_zone);
PipelineData::Get().clear_loop_unrolling_analyzer();
}
}
+2 -2
View File
@@ -20,11 +20,11 @@ void MachineLoweringPhase::Run(Zone* temp_zone) {
CopyingPhase<DataViewReducer, VariableReducer, MachineLoweringReducer,
FastApiCallReducer, RequiredOptimizationReducer,
SelectLoweringReducer,
MachineOptimizationReducer>::Run(temp_zone);
MachineOptimizationReducer>::Run<true>(temp_zone);
} else {
CopyingPhase<DataViewReducer, VariableReducer, MachineLoweringReducer,
FastApiCallReducer, RequiredOptimizationReducer,
SelectLoweringReducer>::Run(temp_zone);
SelectLoweringReducer>::Run<true>(temp_zone);
}
}
@@ -1333,26 +1333,11 @@ class MachineOptimizationReducer : public Next {
if (matcher.MatchConstantShiftRightArithmeticShiftOutZeros(
left, &x, rep_w, &k1) &&
matcher.MatchIntegralWordConstant(right, rep_w, &k2) &&
CountLeadingSignBits(k2, rep_w) > k1) {
if (matcher.Get(left).saturated_use_count.IsZero()) {
return __ Comparison(
x, __ WordConstant(base::bits::Unsigned(k2) << k1, rep_w), kind,
rep_w);
} else if constexpr (reducer_list_contains<
ReducerList, ValueNumberingReducer>::value) {
// If the shift has uses, we only apply the transformation if the
// result would be GVNed away.
OpIndex rhs =
__ WordConstant(base::bits::Unsigned(k2) << k1, rep_w);
static_assert(ComparisonOp::input_count == 2);
static_assert(sizeof(ComparisonOp) == 8);
base::SmallVector<OperationStorageSlot, 32> storage;
ComparisonOp* cmp =
CreateOperation<ComparisonOp>(storage, x, rhs, kind, rep_w);
if (__ WillGVNOp(*cmp)) {
return __ Comparison(x, rhs, kind, rep_w);
}
}
CountLeadingSignBits(k2, rep_w) > k1 &&
matcher.Get(left).saturated_use_count.IsZero()) {
return __ Comparison(
x, __ WordConstant(base::bits::Unsigned(k2) << k1, rep_w), kind,
rep_w);
}
// k2 </<= (x >> k1) => (k2 << k1) </<= x if shifts reversible
// Only perform the transformation if the shift is not used yet, to
@@ -1360,26 +1345,11 @@ class MachineOptimizationReducer : public Next {
if (matcher.MatchConstantShiftRightArithmeticShiftOutZeros(
right, &x, rep_w, &k1) &&
matcher.MatchIntegralWordConstant(left, rep_w, &k2) &&
CountLeadingSignBits(k2, rep_w) > k1) {
if (matcher.Get(right).saturated_use_count.IsZero()) {
return __ Comparison(
__ WordConstant(base::bits::Unsigned(k2) << k1, rep_w), x, kind,
rep_w);
} else if constexpr (reducer_list_contains<
ReducerList, ValueNumberingReducer>::value) {
// If the shift has uses, we only apply the transformation if the
// result would be GVNed away.
OpIndex lhs =
__ WordConstant(base::bits::Unsigned(k2) << k1, rep_w);
static_assert(ComparisonOp::input_count == 2);
static_assert(sizeof(ComparisonOp) == 8);
base::SmallVector<OperationStorageSlot, 32> storage;
ComparisonOp* cmp =
CreateOperation<ComparisonOp>(storage, lhs, x, kind, rep_w);
if (__ WillGVNOp(*cmp)) {
return __ Comparison(lhs, x, kind, rep_w);
}
}
CountLeadingSignBits(k2, rep_w) > k1 &&
matcher.Get(right).saturated_use_count.IsZero()) {
return __ Comparison(
__ WordConstant(base::bits::Unsigned(k2) << k1, rep_w), x, kind,
rep_w);
}
}
// Map 64bit to 32bit comparisons.
+1 -1
View File
@@ -30,7 +30,7 @@ void OptimizePhase::Run(Zone* temp_zone) {
turboshaft::MemoryOptimizationReducer,
turboshaft::MachineOptimizationReducer,
turboshaft::RequiredOptimizationReducer,
turboshaft::ValueNumberingReducer>::Run(temp_zone);
turboshaft::ValueNumberingReducer>::Run<true>(temp_zone);
}
} // namespace v8::internal::compiler::turboshaft
@@ -10,7 +10,7 @@
namespace v8::internal::compiler::turboshaft {
void SimplifiedLoweringPhase::Run(Zone* temp_zone) {
CopyingPhase<SimplifiedLoweringReducer>::Run(temp_zone);
CopyingPhase<SimplifiedLoweringReducer, VariableReducerHotfix>::Run<false>(temp_zone);
}
} // namespace v8::internal::compiler::turboshaft
@@ -32,10 +32,10 @@ class SimplifiedLoweringReducer : public Next {
OpIndex ig_index, const SpeculativeNumberBinopOp& op) {
DCHECK_EQ(op.kind, SpeculativeNumberBinopOp::Kind::kSafeIntegerAdd);
OpIndex frame_state = Map(op.frame_state());
V<Word32> left = ProcessInput(Map(op.left()), Rep::Word32(),
OpIndex frame_state = MapImpl(op.frame_state());
V<Word32> left = ProcessInput(MapImpl(op.left()), Rep::Word32(),
CheckKind::kSigned32, frame_state);
V<Word32> right = ProcessInput(Map(op.right()), Rep::Word32(),
V<Word32> right = ProcessInput(MapImpl(op.right()), Rep::Word32(),
CheckKind::kSigned32, frame_state);
V<Word32> result = __ OverflowCheckedBinop(
@@ -43,7 +43,7 @@ class SimplifiedLoweringReducer : public Next {
WordRepresentation::Word32());
V<Word32> overflow = __ Projection(result, 1, Rep::Word32());
__ DeoptimizeIf(overflow, Map(op.frame_state()),
__ DeoptimizeIf(overflow, MapImpl(op.frame_state()),
DeoptimizeReason::kOverflow, FeedbackSource{});
return __ Projection(result, 0, Rep::Word32());
}
@@ -52,10 +52,10 @@ class SimplifiedLoweringReducer : public Next {
base::SmallVector<OpIndex, 8> return_values;
for (OpIndex input : ret.return_values()) {
return_values.push_back(
ProcessInput(Map(input), Rep::Tagged(), CheckKind::kNone, {}));
ProcessInput(MapImpl(input), Rep::Tagged(), CheckKind::kNone, {}));
}
__ Return(Map(ret.pop_count()), base::VectorOf(return_values));
__ Return(MapImpl(ret.pop_count()), base::VectorOf(return_values));
return OpIndex::Invalid();
}
@@ -94,7 +94,7 @@ class SimplifiedLoweringReducer : public Next {
}
}
inline OpIndex Map(OpIndex ig_index) { return __ MapToNewGraph(ig_index); }
inline OpIndex MapImpl(OpIndex ig_index) { return __ MapToNewGraph(ig_index); }
};
#include "src/compiler/turboshaft/undef-assembler-macros.inc"
@@ -23,7 +23,7 @@ void StoreStoreEliminationPhase::Run(Zone* temp_zone) {
turboshaft::MachineOptimizationReducer,
turboshaft::RequiredOptimizationReducer,
turboshaft::BranchEliminationReducer,
turboshaft::ValueNumberingReducer>::Run(temp_zone);
turboshaft::ValueNumberingReducer>::Run<true>(temp_zone);
}
} // namespace v8::internal::compiler::turboshaft
+3 -2
View File
@@ -21,9 +21,10 @@ void TypeAssertionsPhase::Run(Zone* temp_zone) {
turboshaft::TypeInferenceReducerArgs::OutputGraphTyping::
kPreserveFromInputGraph};
turboshaft::CopyingPhase<turboshaft::AssertTypesReducer,
turboshaft::CopyingPhase<turboshaft::VariableReducerHotfix,
turboshaft::AssertTypesReducer,
turboshaft::ValueNumberingReducer,
turboshaft::TypeInferenceReducer>::Run(temp_zone);
turboshaft::TypeInferenceReducer>::Run<false>(temp_zone);
}
} // namespace v8::internal::compiler::turboshaft
@@ -23,7 +23,8 @@ void TypedOptimizationsPhase::Run(Zone* temp_zone) {
turboshaft::TypeInferenceReducerArgs::OutputGraphTyping::kNone};
turboshaft::CopyingPhase<turboshaft::TypedOptimizationsReducer,
turboshaft::TypeInferenceReducer>::Run(temp_zone);
turboshaft::VariableReducerHotfix,
turboshaft::TypeInferenceReducer>::Run<false>(temp_zone);
}
} // namespace v8::internal::compiler::turboshaft
@@ -28,7 +28,8 @@ void WasmDeadCodeEliminationPhase::Run(Zone* temp_zone) {
// (which, for simplificy, doesn't use the Assembler helper
// methods, but only calls Next::ReduceLoad/Store).
DuplicationOptimizationReducer,
ValueNumberingReducer>::Run(temp_zone);
VariableReducerHotfix,
ValueNumberingReducer>::Run<false>(temp_zone);
}
} // namespace v8::internal::compiler::turboshaft
+1 -1
View File
@@ -15,7 +15,7 @@ namespace v8::internal::compiler::turboshaft {
void WasmGCOptimizePhase::Run(Zone* temp_zone) {
UnparkedScopeIfNeeded scope(PipelineData::Get().broker(),
v8_flags.turboshaft_trace_reduction);
CopyingPhase<WasmLoadEliminationReducer, WasmGCTypeReducer>::Run(temp_zone);
CopyingPhase<WasmLoadEliminationReducer, WasmGCTypeReducer, VariableReducerHotfix>::Run<false>(temp_zone);
}
} // namespace v8::internal::compiler::turboshaft
+1 -1
View File
@@ -21,7 +21,7 @@ void WasmLoweringPhase::Run(Zone* temp_zone) {
// Also run the MachineOptimizationReducer as it can help the late load
// elimination that follows this phase eliminate more loads.
CopyingPhase<WasmLoweringReducer, VariableReducer, MachineOptimizationReducer,
RequiredOptimizationReducer>::Run(temp_zone);
RequiredOptimizationReducer>::Run<true>(temp_zone);
}
} // namespace v8::internal::compiler::turboshaft
+1 -1
View File
@@ -27,7 +27,7 @@ void WasmOptimizePhase::Run(Zone* temp_zone) {
MemoryOptimizationReducer, VariableReducer,
RequiredOptimizationReducer, BranchEliminationReducer,
LateLoadEliminationReducer,
ValueNumberingReducer>::Run(temp_zone);
ValueNumberingReducer>::Run<true>(temp_zone);
}
} // namespace v8::internal::compiler::turboshaft
+1 -1
View File
@@ -17,7 +17,7 @@ void WasmRevecPhase::Run(Zone* temp_zone) {
PipelineData::Get().set_wasm_revec_analyzer(&analyzer);
UnparkedScopeIfNeeded scope(PipelineData::Get().broker(),
v8_flags.turboshaft_trace_reduction);
CopyingPhase<WasmRevecReducer>::Run(temp_zone);
CopyingPhase<WasmRevecReducer>::Run<false>(temp_zone);
PipelineData::Get().clear_wasm_revec_analyzer();
}
}
+1 -1
View File
@@ -3565,7 +3565,7 @@ void Heap::RightTrimArray(Tagged<Array> object, int new_capacity,
}
const int bytes_to_trim =
(old_capacity - new_capacity) * Array::Shape::kElementSize;
(old_capacity - new_capacity) * Array::HotfixShape::kElementSize;
// Calculate location of new array end.
const int old_size = Array::SizeFor(old_capacity);
+2 -3
View File
@@ -32,8 +32,7 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) Dictionary
using DerivedHashTable = HashTable<Derived, Shape>;
public:
using TodoShape = Shape;
using Key = typename TodoShape::Key;
using Key = typename Shape::Key;
inline Tagged<Object> ValueAt(InternalIndex entry);
inline Tagged<Object> ValueAt(PtrComprCageBase cage_base,
InternalIndex entry);
@@ -126,7 +125,7 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) Dictionary
Key key, Handle<Object> value,
PropertyDetails details);
OBJECT_CONSTRUCTORS(Dictionary, HashTable<Derived, TodoShape>);
OBJECT_CONSTRUCTORS(Dictionary, HashTable<Derived, Shape>);
};
#define EXTERN_DECLARE_DICTIONARY(DERIVED, SHAPE) \
+13 -7
View File
@@ -24,13 +24,13 @@ namespace internal {
#include "torque-generated/src/objects/fixed-array-tq.inc"
// Derived: must have a Smi slot at kCapacityOffset.
template <class Derived, class ShapeT, class Super = HeapObject>
template <class Derived, class Shape, class Super = HeapObject>
class TaggedArrayBase : public Super {
static_assert(std::is_base_of<HeapObject, Super>::value);
OBJECT_CONSTRUCTORS(TaggedArrayBase, Super);
using ElementT = typename ShapeT::ElementT;
static_assert(ShapeT::kElementSize == kTaggedSize);
using ElementT = typename Shape::ElementT;
static_assert(Shape::kElementSize == kTaggedSize);
static_assert(is_subtype_v<ElementT, Object> ||
is_subtype_v<ElementT, MaybeObject>);
@@ -53,7 +53,7 @@ class TaggedArrayBase : public Super {
std::conditional_t<kElementsAreMaybeObject, MaybeObjectSlot, ObjectSlot>;
public:
using Shape = ShapeT;
using ShapeT = Shape;
inline int capacity() const;
inline int capacity(AcquireLoadTag) const;
@@ -183,6 +183,7 @@ class FixedArray : public TaggedArrayBase<FixedArray, TaggedArrayShape> {
OBJECT_CONSTRUCTORS(FixedArray, Super);
public:
using HotfixShape = TaggedArrayShape;
template <class IsolateT>
static inline Handle<FixedArray> New(
IsolateT* isolate, int capacity,
@@ -228,7 +229,7 @@ class FixedArray : public TaggedArrayBase<FixedArray, TaggedArrayShape> {
class BodyDescriptor;
static constexpr int kLengthOffset = Shape::kCapacityOffset;
static constexpr int kLengthOffset = ShapeT::kCapacityOffset;
static constexpr int kMaxLength = FixedArray::kMaxCapacity;
static constexpr int kMaxRegularLength = FixedArray::kMaxRegularCapacity;
@@ -276,7 +277,7 @@ class TrustedFixedArray
class BodyDescriptor;
static constexpr int kLengthOffset =
TrustedFixedArray::Shape::kCapacityOffset;
TrustedFixedArray::ShapeT::kCapacityOffset;
static constexpr int kMaxLength = TrustedFixedArray::kMaxCapacity;
static constexpr int kMaxRegularLength =
TrustedFixedArray::kMaxRegularCapacity;
@@ -333,6 +334,7 @@ class PrimitiveArrayBase : public Super {
public:
using Shape = ShapeT;
using HotfixShape = ShapeT;
static constexpr bool kElementsAreMaybeObject = false;
inline int length() const;
@@ -467,6 +469,8 @@ class WeakFixedArray
OBJECT_CONSTRUCTORS(WeakFixedArray, Super);
public:
using Shape = WeakFixedArrayShape;
using HotfixShape = WeakFixedArrayShape;
template <class IsolateT>
static inline Handle<WeakFixedArray> New(
IsolateT* isolate, int capacity,
@@ -478,7 +482,7 @@ class WeakFixedArray
class BodyDescriptor;
static constexpr int kLengthOffset = Shape::kCapacityOffset;
static constexpr int kLengthOffset = ShapeT::kCapacityOffset;
};
// WeakArrayList is like a WeakFixedArray with static convenience methods for
@@ -614,6 +618,7 @@ class ArrayList : public TaggedArrayBase<ArrayList, ArrayListShape> {
public:
using Shape = ArrayListShape;
using HotfixShape = ArrayListShape;
template <class IsolateT>
static inline Handle<ArrayList> New(
@@ -685,6 +690,7 @@ class ByteArray : public PrimitiveArrayBase<ByteArray, ByteArrayShape> {
public:
using Shape = ByteArrayShape;
using HotfixShape = ByteArrayShape;
template <class IsolateT>
static inline Handle<ByteArray> New(
+6 -6
View File
@@ -170,7 +170,7 @@ template <typename Derived, typename Shape>
template <typename IsolateT>
InternalIndex HashTable<Derived, Shape>::FindEntry(IsolateT* isolate, Key key) {
ReadOnlyRoots roots(isolate);
return FindEntry(isolate, roots, key, TodoShape::Hash(roots, key));
return FindEntry(isolate, roots, key, Shape::Hash(roots, key));
}
// Find entry for key otherwise return kNotFound.
@@ -183,7 +183,7 @@ InternalIndex HashTable<Derived, Shape>::FindEntry(PtrComprCageBase cage_base,
uint32_t count = 1;
Tagged<Object> undefined = roots.undefined_value();
Tagged<Object> the_hole = roots.the_hole_value();
DCHECK_EQ(TodoShape::Hash(roots, key), static_cast<uint32_t>(hash));
DCHECK_EQ(Shape::Hash(roots, key), static_cast<uint32_t>(hash));
// EnsureCapacity will guarantee the hash table is never full.
for (InternalIndex entry = FirstProbe(hash, capacity);;
entry = NextProbe(entry, count++, capacity)) {
@@ -191,8 +191,8 @@ InternalIndex HashTable<Derived, Shape>::FindEntry(PtrComprCageBase cage_base,
// Empty entry. Uses raw unchecked accessors because it is called by the
// string table during bootstrapping.
if (element == undefined) return InternalIndex::NotFound();
if (TodoShape::kMatchNeedsHoleCheck && element == the_hole) continue;
if (TodoShape::IsMatch(key, element)) return entry;
if (Shape::kMatchNeedsHoleCheck && element == the_hole) continue;
if (Shape::IsMatch(key, element)) return entry;
}
}
@@ -216,7 +216,7 @@ bool HashTable<Derived, Shape>::ToKey(ReadOnlyRoots roots, InternalIndex entry,
Tagged<Object>* out_k) {
Tagged<Object> k = KeyAt(entry);
if (!IsKey(roots, k)) return false;
*out_k = TodoShape::Unwrap(k);
*out_k = Shape::Unwrap(k);
return true;
}
@@ -226,7 +226,7 @@ bool HashTable<Derived, Shape>::ToKey(PtrComprCageBase cage_base,
Tagged<Object>* out_k) {
Tagged<Object> k = KeyAt(cage_base, entry);
if (!IsKey(GetReadOnlyRoots(cage_base), k)) return false;
*out_k = TodoShape::Unwrap(k);
*out_k = Shape::Unwrap(k);
return true;
}
+5 -6
View File
@@ -126,15 +126,15 @@ class V8_EXPORT_PRIVATE HashTableBase : public NON_EXPORTED_BASE(FixedArray) {
OBJECT_CONSTRUCTORS(HashTableBase, FixedArray);
};
template <typename Derived, typename ShapeT>
template <typename Derived, typename Shape>
class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable
: public HashTableBase {
public:
// TODO(jgruber): Derive from TaggedArrayBase instead of FixedArray, and
// merge with TaggedArraryBase's Shape class. Once the naming conflict is
// resolved rename all TodoShape occurrences back to Shape.
using TodoShape = ShapeT;
using Key = typename TodoShape::Key;
using ShapeT = Shape;
using Key = typename Shape::Key;
// Returns a new HashTable object.
template <typename IsolateT>
@@ -177,9 +177,8 @@ class EXPORT_TEMPLATE_DECLARE(V8_EXPORT_PRIVATE) HashTable
inline void SetKeyAt(InternalIndex entry, Tagged<Object> value,
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
static const int kElementsStartIndex =
kPrefixStartIndex + TodoShape::kPrefixSize;
static const int kEntrySize = TodoShape::kEntrySize;
static const int kElementsStartIndex = kPrefixStartIndex + Shape::kPrefixSize;
static const int kEntrySize = Shape::kEntrySize;
static_assert(kEntrySize > 0);
static const int kEntryKeyIndex = 0;
static const int kElementsStartOffset =
+21 -21
View File
@@ -5123,11 +5123,11 @@ void HashTable<Derived, Shape>::Rehash(PtrComprCageBase cage_base,
uint32_t from_index = EntryToIndex(i);
Tagged<Object> k = this->get(from_index);
if (!IsKey(roots, k)) continue;
uint32_t hash = TodoShape::HashForObject(roots, k);
uint32_t hash = Shape::HashForObject(roots, k);
uint32_t insertion_index =
EntryToIndex(new_table->FindInsertionEntry(cage_base, roots, hash));
new_table->set_key(insertion_index, get(from_index), mode);
for (int j = 1; j < TodoShape::kEntrySize; j++) {
for (int j = 1; j < Shape::kEntrySize; j++) {
new_table->set(insertion_index + j, get(from_index + j), mode);
}
}
@@ -5140,7 +5140,7 @@ InternalIndex HashTable<Derived, Shape>::EntryForProbe(ReadOnlyRoots roots,
Tagged<Object> k,
int probe,
InternalIndex expected) {
uint32_t hash = TodoShape::HashForObject(roots, k);
uint32_t hash = Shape::HashForObject(roots, k);
uint32_t capacity = this->Capacity();
InternalIndex entry = FirstProbe(hash, capacity);
for (int i = 1; i < probe; i++) {
@@ -5155,17 +5155,17 @@ void HashTable<Derived, Shape>::Swap(InternalIndex entry1, InternalIndex entry2,
WriteBarrierMode mode) {
int index1 = EntryToIndex(entry1);
int index2 = EntryToIndex(entry2);
Tagged<Object> temp[TodoShape::kEntrySize];
Tagged<Object> temp[Shape::kEntrySize];
Derived* self = static_cast<Derived*>(this);
for (int j = 0; j < TodoShape::kEntrySize; j++) {
for (int j = 0; j < Shape::kEntrySize; j++) {
temp[j] = get(index1 + j);
}
self->set_key(index1, get(index2), mode);
for (int j = 1; j < TodoShape::kEntrySize; j++) {
for (int j = 1; j < Shape::kEntrySize; j++) {
set(index1 + j, get(index2 + j), mode);
}
self->set_key(index2, temp[0], mode);
for (int j = 1; j < TodoShape::kEntrySize; j++) {
for (int j = 1; j < Shape::kEntrySize; j++) {
set(index2 + j, temp[j], mode);
}
}
@@ -5327,7 +5327,7 @@ GlobalDictionary::TryFindPropertyCellForConcurrentLookupIterator(
DisallowGarbageCollection no_gc;
PtrComprCageBase cage_base{isolate};
ReadOnlyRoots roots(isolate);
const int32_t hash = TodoShape::Hash(roots, name);
const int32_t hash = ShapeT::Hash(roots, name);
const uint32_t capacity = Capacity();
uint32_t count = 1;
Tagged<Object> undefined = roots.undefined_value();
@@ -5338,8 +5338,8 @@ GlobalDictionary::TryFindPropertyCellForConcurrentLookupIterator(
Tagged<Object> element = KeyAt(cage_base, entry, kRelaxedLoad);
if (isolate->heap()->IsPendingAllocation(element)) return {};
if (element == undefined) return {};
if (TodoShape::kMatchNeedsHoleCheck && element == the_hole) continue;
if (!TodoShape::IsMatch(name, element)) continue;
if (ShapeT::kMatchNeedsHoleCheck && element == the_hole) continue;
if (!ShapeT::IsMatch(name, element)) continue;
CHECK(IsPropertyCell(element, cage_base));
return PropertyCell::cast(element);
}
@@ -5353,7 +5353,7 @@ Handle<StringSet> StringSet::Add(Isolate* isolate, Handle<StringSet> stringset,
Handle<String> name) {
if (!stringset->Has(isolate, name)) {
stringset = EnsureCapacity(isolate, stringset);
uint32_t hash = TodoShape::Hash(ReadOnlyRoots(isolate), *name);
uint32_t hash = ShapeT::Hash(ReadOnlyRoots(isolate), *name);
InternalIndex entry = stringset->FindInsertionEntry(isolate, hash);
stringset->set(EntryToIndex(entry), *name);
stringset->ElementAdded();
@@ -5372,7 +5372,7 @@ Handle<RegisteredSymbolTable> RegisteredSymbolTable::Add(
SLOW_DCHECK(table->FindEntry(isolate, key).is_not_found());
table = EnsureCapacity(isolate, table);
uint32_t hash = TodoShape::Hash(ReadOnlyRoots(isolate), key);
uint32_t hash = ShapeT::Hash(ReadOnlyRoots(isolate), key);
InternalIndex entry = table->FindInsertionEntry(isolate, hash);
table->set(EntryToIndex(entry), *key);
table->set(EntryToValueIndex(entry), *symbol);
@@ -5441,7 +5441,7 @@ int BaseNameDictionary<Derived, Shape>::NextEnumerationIndex(
template <typename Derived, typename Shape>
Handle<Derived> Dictionary<Derived, Shape>::DeleteEntry(
Isolate* isolate, Handle<Derived> dictionary, InternalIndex entry) {
DCHECK(TodoShape::kEntrySize != 3 ||
DCHECK(Shape::kEntrySize != 3 ||
dictionary->DetailsAt(entry).IsConfigurable());
dictionary->ClearEntry(entry);
dictionary->ElementRemoved();
@@ -5462,7 +5462,7 @@ Handle<Derived> Dictionary<Derived, Shape>::AtPut(Isolate* isolate,
// We don't need to copy over the enumeration index.
dictionary->ValueAtPut(entry, *value);
if (TodoShape::kEntrySize == 3) dictionary->DetailsAtPut(entry, details);
if (Shape::kEntrySize == 3) dictionary->DetailsAtPut(entry, details);
return dictionary;
}
@@ -5479,7 +5479,7 @@ void Dictionary<Derived, Shape>::UncheckedAtPut(Isolate* isolate,
} else {
// We don't need to copy over the enumeration index.
dictionary->ValueAtPut(entry, *value);
if (TodoShape::kEntrySize == 3) dictionary->DetailsAtPut(entry, details);
if (Shape::kEntrySize == 3) dictionary->DetailsAtPut(entry, details);
}
}
@@ -5520,19 +5520,19 @@ Handle<Derived> Dictionary<Derived, Shape>::Add(IsolateT* isolate,
PropertyDetails details,
InternalIndex* entry_out) {
ReadOnlyRoots roots(isolate);
uint32_t hash = TodoShape::Hash(roots, key);
uint32_t hash = Shape::Hash(roots, key);
// Validate that the key is absent.
SLOW_DCHECK(dictionary->FindEntry(isolate, key).is_not_found());
// Check whether the dictionary should be extended.
dictionary = Derived::EnsureCapacity(isolate, dictionary);
// Compute the key object.
Handle<Object> k = TodoShape::template AsHandle<key_allocation>(isolate, key);
Handle<Object> k = Shape::template AsHandle<key_allocation>(isolate, key);
InternalIndex entry = dictionary->FindInsertionEntry(isolate, roots, hash);
dictionary->SetEntry(entry, *k, *value, details);
DCHECK(IsNumber(dictionary->KeyAt(isolate, entry)) ||
IsUniqueName(TodoShape::Unwrap(dictionary->KeyAt(isolate, entry))));
IsUniqueName(Shape::Unwrap(dictionary->KeyAt(isolate, entry))));
dictionary->ElementAdded();
if (entry_out) *entry_out = entry;
return dictionary;
@@ -5545,18 +5545,18 @@ void Dictionary<Derived, Shape>::UncheckedAdd(IsolateT* isolate,
Key key, Handle<Object> value,
PropertyDetails details) {
ReadOnlyRoots roots(isolate);
uint32_t hash = TodoShape::Hash(roots, key);
uint32_t hash = Shape::Hash(roots, key);
// Validate that the key is absent and we capacity is sufficient.
SLOW_DCHECK(dictionary->FindEntry(isolate, key).is_not_found());
DCHECK(dictionary->HasSufficientCapacityToAdd(1));
// Compute the key object.
Handle<Object> k = TodoShape::template AsHandle<key_allocation>(isolate, key);
Handle<Object> k = Shape::template AsHandle<key_allocation>(isolate, key);
InternalIndex entry = dictionary->FindInsertionEntry(isolate, roots, hash);
dictionary->SetEntry(entry, *k, *value, details);
DCHECK(IsNumber(dictionary->KeyAt(isolate, entry)) ||
IsUniqueName(TodoShape::Unwrap(dictionary->KeyAt(isolate, entry))));
IsUniqueName(Shape::Unwrap(dictionary->KeyAt(isolate, entry))));
}
template <typename Derived, typename Shape>
+1 -1
View File
@@ -54,7 +54,7 @@ Handle<JSArray> TemplateObjectDescription::GetTemplateObject(
// Check the template weakmap to see if the template object already exists.
Handle<Script> script(Script::cast(shared_info->script(isolate)), isolate);
int32_t hash =
EphemeronHashTable::TodoShape::Hash(ReadOnlyRoots(isolate), script);
EphemeronHashTable::ShapeT::Hash(ReadOnlyRoots(isolate), script);
MaybeHandle<ArrayList> maybe_cached_templates;
if (!IsUndefined(native_context->template_weakmap(), isolate)) {