|
22 | 22 | #include "swift/Runtime/Metadata.h"
|
23 | 23 | #include "llvm/Support/Compiler.h"
|
24 | 24 |
|
| 25 | +#if defined(__APPLE__) && defined(__MACH__) |
| 26 | +#include <TargetConditionals.h> |
| 27 | +#endif |
| 28 | + |
25 | 29 | // Opaque ISAs need to use object_getClass which is in runtime.h
|
26 | 30 | #if SWIFT_HAS_OPAQUE_ISAS
|
27 | 31 | #include <objc/runtime.h>
|
@@ -84,6 +88,24 @@ class TypeInfo {
|
84 | 88 | #if SWIFT_HAS_ISA_MASKING
|
85 | 89 | SWIFT_RUNTIME_EXPORT
|
86 | 90 | uintptr_t swift_isaMask;
|
| 91 | + |
| 92 | +// Hardcode the mask. We have our own copy of the value, as it's hard to work |
| 93 | +// out the proper includes from libobjc. The values MUST match the ones from |
| 94 | +// libobjc. Debug builds check these values against objc_debug_isa_class_mask |
| 95 | +// from libobjc. |
| 96 | +# if TARGET_OS_SIMULATOR |
| 97 | +// Simulators don't currently use isa masking, but we still want to emit |
| 98 | +// swift_isaMask and the corresponding code in case that changes. libobjc's |
| 99 | +// mask has the bottom bits clear to include pointer alignment, match that |
| 100 | +// value here. |
| 101 | +# define SWIFT_ISA_MASK 0xfffffffffffffff8ULL |
| 102 | +# elif __arm64__ |
| 103 | +# define SWIFT_ISA_MASK 0x0000000ffffffff8ULL |
| 104 | +# elif __x86_64__ |
| 105 | +# define SWIFT_ISA_MASK 0x00007ffffffffff8ULL |
| 106 | +# else |
| 107 | +# error Unknown architecture for masked isa. |
| 108 | +# endif |
87 | 109 | #endif
|
88 | 110 |
|
89 | 111 | #if SWIFT_OBJC_INTEROP
|
@@ -134,7 +156,7 @@ class TypeInfo {
|
134 | 156 |
|
135 | 157 | #if SWIFT_HAS_ISA_MASKING
|
136 | 158 | // Apply the mask.
|
137 |
| - bits &= swift_isaMask; |
| 159 | + bits &= SWIFT_ISA_MASK; |
138 | 160 | #endif
|
139 | 161 |
|
140 | 162 | // The result is a class pointer.
|
|
0 commit comments