Skip to content

Commit

Permalink
deps: fix building v8 on macos 13 and Apple Clang 14
Browse files Browse the repository at this point in the history
  • Loading branch information
joyeecheung authored and nodejs-github-bot committed Dec 23, 2024
1 parent 5079bef commit 06930b8
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ class StringEscapeAnalysisReducer : public Next {
}

private:
ElidedStringPart(Kind kind, V<String> index) : data(index), kind(kind) {}
ElidedStringPart(Kind kind, V<String> index) : data{index}, kind(kind) {}
};

void Analyze() {
Expand Down
15 changes: 6 additions & 9 deletions deps/v8/src/heap/heap-visitor-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,26 +93,23 @@ Tagged<T> HeapVisitor<ConcreteVisitor>::Cast(Tagged<HeapObject> object,
}

template <typename ConcreteVisitor>
size_t HeapVisitor<ConcreteVisitor>::Visit(Tagged<HeapObject> object)
requires(!ConcreteVisitor::UsePrecomputedObjectSize())
{
template <typename T, typename>
size_t HeapVisitor<ConcreteVisitor>::Visit(Tagged<HeapObject> object) {
return Visit(object->map(cage_base()), object);
}

template <typename ConcreteVisitor>
template <typename T, typename>
size_t HeapVisitor<ConcreteVisitor>::Visit(Tagged<Map> map,
Tagged<HeapObject> object)
requires(!ConcreteVisitor::UsePrecomputedObjectSize())
{
Tagged<HeapObject> object) {
return Visit(map, object, MaybeObjectSize());
}

template <typename ConcreteVisitor>
template <typename T, typename>
size_t HeapVisitor<ConcreteVisitor>::Visit(Tagged<Map> map,
Tagged<HeapObject> object,
int object_size)
requires(ConcreteVisitor::UsePrecomputedObjectSize())
{
int object_size) {
return Visit(map, object, MaybeObjectSize(object_size));
}

Expand Down
15 changes: 9 additions & 6 deletions deps/v8/src/heap/heap-visitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,18 @@ class HeapVisitor : public ObjectVisitorWithCageBases {
inline explicit HeapVisitor(Isolate* isolate);
inline explicit HeapVisitor(Heap* heap);

V8_INLINE size_t Visit(Tagged<HeapObject> object)
requires(!ConcreteVisitor::UsePrecomputedObjectSize());
template <typename T = ConcreteVisitor,
typename = std::enable_if_t<!T::UsePrecomputedObjectSize()>>
V8_INLINE size_t Visit(Tagged<HeapObject> object);

V8_INLINE size_t Visit(Tagged<Map> map, Tagged<HeapObject> object)
requires(!ConcreteVisitor::UsePrecomputedObjectSize());
template <typename T = ConcreteVisitor,
typename = std::enable_if_t<!T::UsePrecomputedObjectSize()>>
V8_INLINE size_t Visit(Tagged<Map> map, Tagged<HeapObject> object);

template <typename T = ConcreteVisitor,
typename = std::enable_if_t<T::UsePrecomputedObjectSize()>>
V8_INLINE size_t Visit(Tagged<Map> map, Tagged<HeapObject> object,
int object_size)
requires(ConcreteVisitor::UsePrecomputedObjectSize());
int object_size);

protected:
V8_INLINE size_t Visit(Tagged<Map> map, Tagged<HeapObject> object,
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/heap/mark-compact.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3862,7 +3862,7 @@ void MarkCompactCollector::ClearWeakCollections() {

template <typename TObjectAndSlot, typename TMaybeSlot>
void MarkCompactCollector::ClearWeakReferences(
WeakObjects::WeakObjectWorklist<TObjectAndSlot>::Local& worklist,
typename WeakObjects::WeakObjectWorklist<TObjectAndSlot>::Local& worklist,
Tagged<HeapObjectReference> cleared_weak_ref) {
TObjectAndSlot slot;
while (worklist.Pop(&slot)) {
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/heap/mark-compact.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ class MarkCompactCollector final {
// Common implementation of the above two.
template <typename TObjectAndSlot, typename TMaybeSlot>
void ClearWeakReferences(
WeakObjects::WeakObjectWorklist<TObjectAndSlot>::Local& worklist,
typename WeakObjects::WeakObjectWorklist<TObjectAndSlot>::Local& worklist,
Tagged<HeapObjectReference> cleared_weak_ref);

// Goes through the list of encountered non-trivial weak references and
Expand Down
54 changes: 32 additions & 22 deletions deps/v8/src/json/json-stringifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2072,7 +2072,7 @@ template <typename Char>
template <typename StringT>
FastJsonStringifierResult FastJsonStringifier<Char>::SerializeObjectKey(
Tagged<String> obj, bool comma, const DisallowGarbageCollection& no_gc) {
using StringChar = StringT::Char;
using StringChar = typename StringT::Char;
if constexpr (is_one_byte && sizeof(StringChar) == 2) {
return CHANGE_ENCODING;
} else {
Expand All @@ -2098,7 +2098,7 @@ template <typename StringT, bool deferred_key>
FastJsonStringifierResult FastJsonStringifier<Char>::SerializeString(
Tagged<HeapObject> obj, bool comma, Tagged<String> key,
const DisallowGarbageCollection& no_gc) {
using StringChar = StringT::Char;
using StringChar = typename StringT::Char;
if constexpr (is_one_byte && sizeof(StringChar) == 2) {
return CHANGE_ENCODING;
} else {
Expand Down Expand Up @@ -2277,36 +2277,39 @@ FastJsonStringifierResult FastJsonStringifier<Char>::SerializeJSObject(
break;
case UNDEFINED:
break;
case UNCHANGED:
stack_.emplace_back(ContinuationRecord::kObject, obj,
i.as_uint32() + 1);
case UNCHANGED: {
ContinuationRecord rec1{ContinuationRecord::kObject, obj, i.as_uint32() + 1};
stack_.emplace_back(std::move(rec1));
// property can be an object or array. We don't need to distinguish
// as index is 0 anyways.
stack_.emplace_back(ContinuationRecord::kObject, property, 0);
ContinuationRecord rec2{ContinuationRecord::kObject, property, 0};
stack_.emplace_back(std::move(rec2));
result = SerializeObjectKey(key_name, comma, no_gc);
if constexpr (is_one_byte) {
if (V8_UNLIKELY(result != SUCCESS)) {
DCHECK_EQ(result, CHANGE_ENCODING);
stack_.emplace_back(ContinuationRecord::kObjectKey, key_name,
comma);
ContinuationRecord rec3{ContinuationRecord::kObjectKey, key_name, comma};
stack_.emplace_back(std::move(rec3));
return result;
}
}
return result;
case CHANGE_ENCODING:
}
case CHANGE_ENCODING: {
DCHECK(is_one_byte);
stack_.emplace_back(ContinuationRecord::kObject, obj,
i.as_uint32() + 1);
stack_.emplace_back(ContinuationRecord::kResumeFromOther, property,
0);
ContinuationRecord rec1{ContinuationRecord::kObject, obj, i.as_uint32() + 1};
stack_.emplace_back(std::move(rec1));
ContinuationRecord rec2{ContinuationRecord::kResumeFromOther, property, 0};
stack_.emplace_back(std::move(rec2));
result = SerializeObjectKey(key_name, comma, no_gc);
if (V8_UNLIKELY(result != SUCCESS)) {
stack_.emplace_back(ContinuationRecord::kObjectKey, key_name,
comma);
ContinuationRecord rec3{ContinuationRecord::kObjectKey, key_name, comma};
stack_.emplace_back(std::move(rec3));
return result;
}
DCHECK(IsString(property));
return result;
}
case SLOW_PATH:
case EXCEPTION:
return result;
Expand Down Expand Up @@ -2449,15 +2452,21 @@ FastJsonStringifierResult FastJsonStringifier<Char>::SerializeFixedArrayElement(
case UNDEFINED:
AppendCStringLiteral("null");
return SUCCESS;
case CHANGE_ENCODING:
case CHANGE_ENCODING: {
DCHECK(IsString(obj));
stack_.emplace_back(ContinuationRecord::kArray, array, i + 1);
stack_.emplace_back(ContinuationRecord::kResumeFromOther, obj, 0);
ContinuationRecord rec1{ContinuationRecord::kArray, array, i + 1};
stack_.emplace_back(std::move(rec1));
ContinuationRecord rec2{ContinuationRecord::kResumeFromOther, obj, 0};
stack_.emplace_back(std::move(rec2));
return result;
case UNCHANGED:
stack_.emplace_back(ContinuationRecord::kArray, array, i + 1);
stack_.emplace_back(ContinuationRecord::kResumeFromOther, obj, 0);
}
case UNCHANGED: {
ContinuationRecord rec1{ContinuationRecord::kArray, array, i + 1};
stack_.emplace_back(std::move(rec1));
ContinuationRecord rec2{ContinuationRecord::kResumeFromOther, obj, 0};
stack_.emplace_back(std::move(rec2));
return result;
}
default:
return result;
}
Expand Down Expand Up @@ -2534,7 +2543,8 @@ FastJsonStringifierResult FastJsonStringifier<Char>::SerializeObject(
if constexpr (is_one_byte) {
if (result == CHANGE_ENCODING) {
DCHECK(IsString(object));
stack_.emplace_back(ContinuationRecord::kResumeFromOther, object, 0);
ContinuationRecord rec{ContinuationRecord::kResumeFromOther, object, 0};
stack_.emplace_back(std::move(rec));
return result;
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion deps/v8/src/maglev/maglev-ir.h
Original file line number Diff line number Diff line change
Expand Up @@ -4025,7 +4025,7 @@ class CheckedNumberOrOddballToFloat64OrHoleyFloat64

private:
using TaggedToFloat64ConversionTypeOffset =
Base::template NextBitField<TaggedToFloat64ConversionType, 2>;
typename Base::template NextBitField<TaggedToFloat64ConversionType, 2>;
};

class CheckedNumberOrOddballToFloat64
Expand Down
4 changes: 2 additions & 2 deletions deps/v8/src/objects/objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -604,11 +604,11 @@ class Object : public AllStatic {
ConvertToInteger(Isolate* isolate, HandleType<Object> input);
template <template <typename> typename HandleType>
requires(std::is_convertible_v<HandleType<Object>, DirectHandle<Object>>)
V8_WARN_UNUSED_RESULT static HandleType<Number>::MaybeType ConvertToInt32(
V8_WARN_UNUSED_RESULT static typename HandleType<Number>::MaybeType ConvertToInt32(
Isolate* isolate, HandleType<Object> input);
template <template <typename> typename HandleType>
requires(std::is_convertible_v<HandleType<Object>, DirectHandle<Object>>)
V8_WARN_UNUSED_RESULT static HandleType<Number>::MaybeType ConvertToUint32(
V8_WARN_UNUSED_RESULT static typename HandleType<Number>::MaybeType ConvertToUint32(
Isolate* isolate, HandleType<Object> input);
V8_EXPORT_PRIVATE V8_WARN_UNUSED_RESULT static MaybeHandle<Number>
ConvertToLength(Isolate* isolate, DirectHandle<Object> input);
Expand Down
46 changes: 23 additions & 23 deletions deps/v8/src/objects/smi.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,29 @@ namespace internal {
// Smi stands for small integer.
class Smi : public AllStatic {
public:
// Returns whether value can be represented in a Smi.
template <typename T>
static inline bool constexpr IsValid(T value)
requires(std::is_integral_v<T> && std::is_signed_v<T>)
{
DCHECK_EQ(Internals::IsValidSmi(value),
value >= kMinValue && value <= kMaxValue);
return Internals::IsValidSmi(value);
}
template <typename T>
static inline bool constexpr IsValid(T value)
requires(std::is_integral_v<T> && std::is_unsigned_v<T>)
{
DCHECK_EQ(Internals::IsValidSmi(value), value <= kMaxValue);
return Internals::IsValidSmi(value);
}

// Convert a value to a Smi object.
static inline constexpr Tagged<Smi> FromInt(int value) {
DCHECK(Smi::IsValid(value));
return Tagged<Smi>(Internals::IntegralToSmi(value));
}

static inline constexpr Tagged<Smi> ToUint32Smi(Tagged<Smi> smi) {
if (smi.value() <= 0) return Smi::FromInt(0);
return Smi::FromInt(static_cast<uint32_t>(smi.value()));
Expand All @@ -34,12 +57,6 @@ class Smi : public AllStatic {
return Tagged<Smi>(object.ptr()).value();
}

// Convert a value to a Smi object.
static inline constexpr Tagged<Smi> FromInt(int value) {
DCHECK(Smi::IsValid(value));
return Tagged<Smi>(Internals::IntegralToSmi(value));
}

static inline constexpr Tagged<Smi> FromIntptr(intptr_t value) {
DCHECK(Smi::IsValid(value));
int smi_shift_bits = kSmiTagSize + kSmiShiftSize;
Expand All @@ -62,23 +79,6 @@ class Smi : public AllStatic {
return FromInt(static_cast<int>(value));
}

// Returns whether value can be represented in a Smi.
template <typename T>
static inline bool constexpr IsValid(T value)
requires(std::is_integral_v<T> && std::is_signed_v<T>)
{
DCHECK_EQ(Internals::IsValidSmi(value),
value >= kMinValue && value <= kMaxValue);
return Internals::IsValidSmi(value);
}
template <typename T>
static inline bool constexpr IsValid(T value)
requires(std::is_integral_v<T> && std::is_unsigned_v<T>)
{
DCHECK_EQ(Internals::IsValidSmi(value), value <= kMaxValue);
return Internals::IsValidSmi(value);
}

// Compare two Smis x, y as if they were converted to strings and then
// compared lexicographically. Returns:
// -1 if x < y.
Expand Down
6 changes: 3 additions & 3 deletions deps/v8/src/sandbox/external-entity-table.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ class V8_EXPORT_PRIVATE ExternalEntityTable
: public SegmentedTable<Entry, size> {
protected:
using Base = SegmentedTable<Entry, size>;
using FreelistHead = Base::FreelistHead;
using Segment = Base::Segment;
using WriteIterator = Base::WriteIterator;
using FreelistHead = typename Base::FreelistHead;
using Segment = typename Base::Segment;
using WriteIterator = typename Base::WriteIterator;
static constexpr size_t kSegmentSize = Base::kSegmentSize;
static constexpr size_t kEntriesPerSegment = Base::kEntriesPerSegment;
static constexpr size_t kEntrySize = Base::kEntrySize;
Expand Down

0 comments on commit 06930b8

Please sign in to comment.