Skip to content

Commit 2bff31e

Browse files
authored
Merge pull request #33362 from mikeash/fix-isa-mask-assert3
2 parents ceeceaa + e57961c commit 2bff31e

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

stdlib/public/runtime/Private.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,11 @@ class TypeInfo {
103103
// value here.
104104
# define SWIFT_ISA_MASK 0xfffffffffffffff8ULL
105105
# elif __arm64__
106+
// The ISA mask used when ptrauth is available.
107+
# define SWIFT_ISA_MASK_PTRAUTH 0x007ffffffffffff8ULL
106108
// ARM64 simulators always use the ARM64e mask.
107109
# if __has_feature(ptrauth_calls) || TARGET_OS_SIMULATOR
108-
# define SWIFT_ISA_MASK 0x007ffffffffffff8ULL
110+
# define SWIFT_ISA_MASK SWIFT_ISA_MASK_PTRAUTH
109111
# else
110112
# if TARGET_OS_OSX
111113
# define SWIFT_ISA_MASK 0x00007ffffffffff8ULL

stdlib/public/runtime/SwiftObject.mm

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,17 @@ static id _getClassDescription(Class cls) {
199199
@implementation SwiftObject
200200
+ (void)initialize {
201201
#if SWIFT_HAS_ISA_MASKING && !TARGET_OS_SIMULATOR && !NDEBUG
202-
assert(&objc_absolute_packed_isa_class_mask);
203-
assert((uintptr_t)&objc_absolute_packed_isa_class_mask == SWIFT_ISA_MASK);
202+
uintptr_t libObjCMask = (uintptr_t)&objc_absolute_packed_isa_class_mask;
203+
assert(libObjCMask);
204+
205+
# if __arm64__ && !__has_feature(ptrauth_calls)
206+
// When we're built ARM64 but running on ARM64e hardware, we will get an
207+
// ARM64e libobjc with an ARM64e ISA mask. This mismatch is harmless and we
208+
// shouldn't assert.
209+
assert(libObjCMask == SWIFT_ISA_MASK || libObjCMask == SWIFT_ISA_MASK_PTRAUTH);
210+
# else
211+
assert(libObjCMask == SWIFT_ISA_MASK);
212+
# endif
204213
#endif
205214
}
206215

0 commit comments

Comments
 (0)