Skip to content

[Runtime] Fix the ISA mask assert for ARM64 running on ARM64e hardware. #33362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion stdlib/public/runtime/Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ class TypeInfo {
// value here.
# define SWIFT_ISA_MASK 0xfffffffffffffff8ULL
# elif __arm64__
// The ISA mask used when ptrauth is available.
# define SWIFT_ISA_MASK_PTRAUTH 0x007ffffffffffff8ULL
// ARM64 simulators always use the ARM64e mask.
# if __has_feature(ptrauth_calls) || TARGET_OS_SIMULATOR
# define SWIFT_ISA_MASK 0x007ffffffffffff8ULL
# define SWIFT_ISA_MASK SWIFT_ISA_MASK_PTRAUTH
# else
# if TARGET_OS_OSX
# define SWIFT_ISA_MASK 0x00007ffffffffff8ULL
Expand Down
13 changes: 11 additions & 2 deletions stdlib/public/runtime/SwiftObject.mm
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,17 @@ static id _getClassDescription(Class cls) {
@implementation SwiftObject
+ (void)initialize {
#if SWIFT_HAS_ISA_MASKING && !TARGET_OS_SIMULATOR && !NDEBUG
assert(&objc_absolute_packed_isa_class_mask);
assert((uintptr_t)&objc_absolute_packed_isa_class_mask == SWIFT_ISA_MASK);
uintptr_t libObjCMask = (uintptr_t)&objc_absolute_packed_isa_class_mask;
assert(libObjCMask);

# if __arm64__ && !__has_feature(ptrauth_calls)
// When we're built ARM64 but running on ARM64e hardware, we will get an
Copy link
Contributor

@tschuett tschuett Aug 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we have built for???

// ARM64e libobjc with an ARM64e ISA mask. This mismatch is harmless and we
// shouldn't assert.
assert(libObjCMask == SWIFT_ISA_MASK || libObjCMask == SWIFT_ISA_MASK_PTRAUTH);
# else
assert(libObjCMask == SWIFT_ISA_MASK);
# endif
#endif
}

Expand Down