Skip to content

Commit 3757158

Browse files
committed
GCC 16 warns about the IsTypeComplete check in allowCompactPointers()
https://bugs.webkit.org/show_bug.cgi?id=328861 Reviewed by Keith Miller. allowCompactPointers() checks IsTypeComplete<T> before the AllowCompactPointers<T*> specialization declared by WTF_ALLOW_COMPACT_POINTERS_TO_INCOMPLETE_TYPE. JSPromiseReaction and NodeRareData are checked before their definition, so GCC 16 warns with -Wsfinae-incomplete. Check the specialization first. The macro must then precede any compact pointer to the type, so move the one for JSCell from MicrotaskQueue.h to JSCJSValue.h, which JSCell.h includes before the class definition. * Source/JavaScriptCore/runtime/JSCJSValue.h: * Source/JavaScriptCore/runtime/MicrotaskQueue.h: * Source/WTF/wtf/FastMalloc.h: (allowCompactPointers): Canonical link: https://commits.webkit.org/324681@main
1 parent c2c55ba commit 3757158

3 files changed

Lines changed: 13 additions & 11 deletions

File tree

‎Source/JavaScriptCore/runtime/JSCJSValue.h‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,17 @@
3535
#include <wtf/Nonmovable.h>
3636
#include <wtf/TriState.h>
3737

38+
namespace JSC {
39+
class JSCell;
40+
}
41+
WTF_ALLOW_COMPACT_POINTERS_TO_INCOMPLETE_TYPE(JSC::JSCell);
42+
3843
namespace JSC {
3944

4045
class AssemblyHelpers;
4146
class DeletePropertySlot;
4247
class JSBigInt;
4348
class CallFrame;
44-
class JSCell;
4549
class JSValueSource;
4650
class VM;
4751
class JSGlobalObject;

‎Source/JavaScriptCore/runtime/MicrotaskQueue.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@
3838
#include <wtf/VectorTraits.h>
3939

4040
namespace JSC {
41-
class JSCell;
4241
class JSMicrotaskDispatcher;
4342
}
44-
WTF_ALLOW_COMPACT_POINTERS_TO_INCOMPLETE_TYPE(JSC::JSCell);
4543

4644
WTF_ALLOW_UNSAFE_BUFFER_USAGE_BEGIN
4745

‎Source/WTF/wtf/FastMalloc.h‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -427,15 +427,15 @@ using __thisIsAlsoHereToForceASemicolonAfterThisMacro UNUSED_TYPE_ALIAS = int
427427
template<typename T>
428428
inline constexpr bool allowCompactPointers()
429429
{
430-
if constexpr (WTF::IsTypeComplete<std::remove_pointer_t<T>>)
430+
// We want to support compact pointers to incomplete types too, so AllowCompactPointers can be
431+
// specialized on their pointer type. This is mostly accomplished using the above
432+
// WTF_ALLOW_COMPACT_POINTERS_TO_INCOMPLETE_TYPE macro, which must precede any compact pointer to the type.
433+
if constexpr (AllowCompactPointers<std::remove_cv_t<std::remove_pointer_t<T>>*>::value)
434+
return true;
435+
else if constexpr (WTF::IsTypeComplete<std::remove_pointer_t<T>>)
431436
return std::remove_pointer_t<T>::allowCompactPointers;
432-
else {
433-
// We want to support compact pointers to incomplete types too, so we have this fallback:
434-
// if a type is incomplete, AllowCompactPointers can be specialized on its pointer type,
435-
// in which case we'll return its value. This is mostly accomplished using the below
436-
// WTF_ALLOW_COMPACT_POINTERS_TO_INCOMPLETE_TYPE macro.
437-
return AllowCompactPointers<std::remove_const_t<std::remove_pointer_t<T>>*>::value;
438-
}
437+
else
438+
return false;
439439
}
440440

441441
using WTF::FastAlignedMalloc;

0 commit comments

Comments
 (0)