Skip to content

Commit 51bacb4

Browse files
committed
---
yaml --- r: 347755 b: refs/heads/master c: 41939fa h: refs/heads/master i: 347753: ddce842 347751: 94318a1
1 parent ee4e029 commit 51bacb4

File tree

3 files changed

+31
-14
lines changed

3 files changed

+31
-14
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 4b79f7f8920939154ec420395bda87125cb88887
2+
refs/heads/master: 41939fa1afe74c6f7d3fcfbf3c291dcfadb25f18
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/stdlib/public/runtime/Private.h

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
#include "swift/Runtime/Metadata.h"
2323
#include "llvm/Support/Compiler.h"
2424

25+
#if defined(__APPLE__) && defined(__MACH__)
26+
#include <TargetConditionals.h>
27+
#endif
28+
2529
// Opaque ISAs need to use object_getClass which is in runtime.h
2630
#if SWIFT_HAS_OPAQUE_ISAS
2731
#include <objc/runtime.h>
@@ -84,6 +88,24 @@ class TypeInfo {
8488
#if SWIFT_HAS_ISA_MASKING
8589
SWIFT_RUNTIME_EXPORT
8690
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
87109
#endif
88110

89111
#if SWIFT_OBJC_INTEROP
@@ -134,7 +156,7 @@ class TypeInfo {
134156

135157
#if SWIFT_HAS_ISA_MASKING
136158
// Apply the mask.
137-
bits &= swift_isaMask;
159+
bits &= SWIFT_ISA_MASK;
138160
#endif
139161

140162
// The result is a class pointer.

trunk/stdlib/public/runtime/SwiftObject.mm

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,7 @@
5858
OBJC_EXPORT __attribute__((__weak_import__))
5959
const uintptr_t objc_debug_isa_class_mask;
6060

61-
static uintptr_t computeISAMask() {
62-
// The versions of the Objective-C runtime which use non-pointer
63-
// ISAs also export this symbol.
64-
if (auto runtimeSymbol = &objc_debug_isa_class_mask)
65-
return *runtimeSymbol;
66-
return ~uintptr_t(0);
67-
}
68-
69-
SWIFT_ALLOWED_RUNTIME_GLOBAL_CTOR_BEGIN
70-
uintptr_t swift::swift_isaMask = computeISAMask();
71-
SWIFT_ALLOWED_RUNTIME_GLOBAL_CTOR_END
61+
uintptr_t swift::swift_isaMask = SWIFT_ISA_MASK;
7262
#endif
7363

7464
const ClassMetadata *swift::_swift_getClass(const void *object) {
@@ -204,7 +194,12 @@ Class _swift_classOfObjCHeapObject(OpaqueValue *value) {
204194

205195

206196
@implementation SwiftObject
207-
+ (void)initialize {}
197+
+ (void)initialize {
198+
#if SWIFT_HAS_ISA_MASKING
199+
assert(&objc_debug_isa_class_mask);
200+
assert(objc_debug_isa_class_mask == SWIFT_ISA_MASK);
201+
#endif
202+
}
208203

209204
+ (instancetype)allocWithZone:(struct _NSZone *)zone {
210205
assert(zone == nullptr);

0 commit comments

Comments
 (0)