Skip to content

Commit deb562d

Browse files
authored
[stdlib] Remove struct SwiftObject_s. (#4501)
[stdlib] Remove struct SwiftObject_s. SWIFT_HEAPOBJECT_NON_OBJC_MEMBERS works just as well with less redundancy.
1 parent 13d5371 commit deb562d

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

stdlib/public/runtime/SwiftObject.h

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,15 @@
2626
#include <objc/NSObject.h>
2727
#endif
2828

29-
namespace swift {
3029

3130
#if SWIFT_OBJC_INTEROP
32-
struct SwiftObject_s {
33-
void *isa __attribute__((__unavailable__));
34-
uint32_t strongRefCount __attribute__((__unavailable__));
35-
uint32_t weakRefCount __attribute__((__unavailable__));
36-
};
37-
38-
static_assert(sizeof(SwiftObject_s) == sizeof(HeapObject),
39-
"SwiftObject and HeapObject must have the same header");
40-
static_assert(std::is_trivially_constructible<SwiftObject_s>::value,
41-
"SwiftObject must be trivially constructible");
42-
static_assert(std::is_trivially_destructible<SwiftObject_s>::value,
43-
"SwiftObject must be trivially destructible");
44-
45-
} // namespace swift
4631

4732
#if __has_attribute(objc_root_class)
4833
__attribute__((__objc_root_class__))
4934
#endif
5035
SWIFT_RUNTIME_EXPORT @interface SwiftObject<NSObject> {
51-
swift::SwiftObject_s header;
36+
Class isa;
37+
SWIFT_HEAPOBJECT_NON_OBJC_MEMBERS;
5238
}
5339

5440
- (BOOL)isEqual:(id)object;
@@ -92,8 +78,8 @@ void swift_getSummary(String *out, OpaqueValue *value, const Metadata *T);
9278
// Convert a Swift String to an NSString.
9379
NSString *convertStringToNSString(String *swiftString);
9480

95-
#endif
96-
9781
}
9882

9983
#endif
84+
85+
#endif

stdlib/public/runtime/SwiftValue.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@ - (id)copyWithZone:(NSZone *)zone;
125125
/* TODO: If we're able to become a SwiftObject subclass in the future,
126126
* change to this:
127127
static constexpr const size_t SwiftValueHeaderOffset
128-
= sizeof(SwiftObject_s);
128+
= sizeof(HeapObject);
129129
static constexpr const size_t SwiftValueMinAlignMask
130-
= alignof(SwiftObject_s) - 1;
130+
= alignof(HeapObject) - 1;
131131
*/
132132

133133
static Class _getSwiftValueClass() {

0 commit comments

Comments
 (0)