File tree Expand file tree Collapse file tree 2 files changed +36
-3
lines changed Expand file tree Collapse file tree 2 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -417,6 +417,13 @@ class RefCountBitsT {
417
417
setField (PureSwiftDealloc, value);
418
418
}
419
419
420
+ SWIFT_ALWAYS_INLINE
421
+ static constexpr BitsType immortalBits () {
422
+ return (BitsType (2 ) << Offsets::StrongExtraRefCountShift) |
423
+ (BitsType (Offsets::IsImmortalMask)) |
424
+ (BitsType (1 ) << Offsets::UseSlowRCShift);
425
+ }
426
+
420
427
SWIFT_ALWAYS_INLINE
421
428
RefCountBitsT () = default;
422
429
@@ -431,9 +438,7 @@ class RefCountBitsT {
431
438
SWIFT_ALWAYS_INLINE
432
439
constexpr
433
440
RefCountBitsT (Immortal_t immortal)
434
- : bits((BitsType(2 ) << Offsets::StrongExtraRefCountShift) |
435
- (BitsType(Offsets::IsImmortalMask)) |
436
- (BitsType(1 ) << Offsets::UseSlowRCShift))
441
+ : bits(immortalBits())
437
442
{ }
438
443
439
444
SWIFT_ALWAYS_INLINE
Original file line number Diff line number Diff line change @@ -53,6 +53,34 @@ swift::_SwiftEmptyArrayStorage swift::_swiftEmptyArrayStorage = {
53
53
}
54
54
};
55
55
56
+ __asm__ (" .globl __swiftImmortalRefCount\n " );
57
+
58
+ #if __POINTER_WIDTH__ == 64
59
+
60
+ // TODO: is there a way to avoid hard coding this constant in the inline
61
+ // assembly string?
62
+ static_assert (swift::InlineRefCountBits::immortalBits() == 0x80000004ffffffffull,
63
+ "immortal refcount bits changed: correct the inline asm below");
64
+ __asm__ (" .set __swiftImmortalRefCount, 0x80000004ffffffff\n " );
65
+
66
+ #elif __POINTER_WIDTH__ == 32
67
+
68
+ // TODO: is there a way to avoid hard coding this constant in the inline
69
+ // assembly string?
70
+ static_assert (swift::InlineRefCountBits::immortalBits() == 0x800004fful,
71
+ "immortal refcount bits changed: correct the inline asm below");
72
+ __asm__ (" .set __swiftImmortalRefCount, 0x800004ff\n " );
73
+
74
+ #else
75
+ #error ("unsupported pointer width")
76
+ #endif
77
+
78
+ // Static arrays can only contain trivial elements. Therefore we can reuse
79
+ // the metadata of the empty array buffer. The important thing is that its
80
+ // deinit is a no-op and does not actually destroy any elements.
81
+ __asm__ (" .globl __swiftStaticArrayMetadata\n " );
82
+ __asm__ (" .set __swiftStaticArrayMetadata, _$ss19__EmptyArrayStorageCN\n " );
83
+
56
84
SWIFT_RUNTIME_STDLIB_API
57
85
swift::_SwiftEmptyDictionarySingleton swift::_swiftEmptyDictionarySingleton = {
58
86
// HeapObject header;
You can’t perform that action at this time.
0 commit comments