Skip to content

Commit 5a98648

Browse files
authored
Merge pull request #21015 from rjmccall/arm64-tbi-future-proofing-5.0
Future-proof the ARM64 ABI by not reserving the entire top byte.
2 parents 1bfaa2f + 478d2b2 commit 5a98648

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

stdlib/public/SwiftShims/System.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,10 @@
136136
/// Darwin reserves the low 4GB of address space.
137137
#define SWIFT_ABI_DARWIN_ARM64_LEAST_VALID_POINTER 0x100000000ULL
138138

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

143144
// Objective-C reserves just the high bit for tagged pointers.
144145
#define SWIFT_ABI_ARM64_OBJC_RESERVED_BITS_MASK 0x8000000000000000ULL

test/IRGen/bridge_object_arm64.sil

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ entry(%c : $C, %w : $Builtin.Word):
3535
// CHECK: [[TAGGED_RESULT:%.*]] = bitcast [[BRIDGE]] %0 to [[C:%objc_object\*]]
3636
// CHECK: br label %tagged-cont
3737
// CHECK: not-tagged-pointer:
38-
// -- 0x00ff_ffff_ffff_fff8
39-
// CHECK: [[MASKED_BITS:%.*]] = and i64 [[BOBITS]], 72057594037927928
38+
// -- 0x0fff_ffff_ffff_fff8
39+
// CHECK: [[MASKED_BITS:%.*]] = and i64 [[BOBITS]], 1152921504606846968
4040
// CHECK: [[MASKED_RESULT:%.*]] = inttoptr i64 [[MASKED_BITS]] to [[C]]
4141
// CHECK: br label %tagged-cont
4242
// CHECK: tagged-cont:

0 commit comments

Comments
 (0)