Skip to content

Future-proof the ARM64 ABI by not reserving the entire top byte. #21015

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
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
5 changes: 3 additions & 2 deletions stdlib/public/SwiftShims/System.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,10 @@
/// Darwin reserves the low 4GB of address space.
#define SWIFT_ABI_DARWIN_ARM64_LEAST_VALID_POINTER 0x100000000ULL

// TBI guarantees the top byte of pointers is unused.
// TBI guarantees the top byte of pointers is unused, but ARMv8.5-A
// claims the bottom four bits of that for memory tagging.
// Heap objects are eight-byte aligned.
#define SWIFT_ABI_ARM64_SWIFT_SPARE_BITS_MASK 0xFF00000000000007ULL
#define SWIFT_ABI_ARM64_SWIFT_SPARE_BITS_MASK 0xF000000000000007ULL

// Objective-C reserves just the high bit for tagged pointers.
#define SWIFT_ABI_ARM64_OBJC_RESERVED_BITS_MASK 0x8000000000000000ULL
Expand Down
4 changes: 2 additions & 2 deletions test/IRGen/bridge_object_arm64.sil
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ entry(%c : $C, %w : $Builtin.Word):
// CHECK: [[TAGGED_RESULT:%.*]] = bitcast [[BRIDGE]] %0 to [[C:%objc_object\*]]
// CHECK: br label %tagged-cont
// CHECK: not-tagged-pointer:
// -- 0x00ff_ffff_ffff_fff8
// CHECK: [[MASKED_BITS:%.*]] = and i64 [[BOBITS]], 72057594037927928
// -- 0x0fff_ffff_ffff_fff8
// CHECK: [[MASKED_BITS:%.*]] = and i64 [[BOBITS]], 1152921504606846968
// CHECK: [[MASKED_RESULT:%.*]] = inttoptr i64 [[MASKED_BITS]] to [[C]]
// CHECK: br label %tagged-cont
// CHECK: tagged-cont:
Expand Down