Skip to content

Commit daf6d57

Browse files
authored
Merge pull request #38317 from mikeash/frame-pointer-mask-symbol-5.5
[5.5][Concurrency] Add an exported symbol on Darwin that contains the frame pointer flag bit for async frames.
2 parents 29c1bf0 + 86f4363 commit daf6d57

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

include/swift/Runtime/Concurrency.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -648,6 +648,18 @@ void swift_task_reportUnexpectedExecutor(
648648
SWIFT_EXPORT_FROM(swift_Concurrency) SWIFT_CC(swift)
649649
JobPriority swift_task_getCurrentThreadPriority(void);
650650

651+
#ifdef __APPLE__
652+
/// A magic symbol whose address is the mask to apply to a frame pointer to
653+
/// signal that it is an async frame. Do not try to read the actual value of
654+
/// this global, it will crash.
655+
///
656+
/// On ARM64_32, the address is only 32 bits, and therefore this value covers
657+
/// the top 32 bits of the in-memory frame pointer. On other 32-bit platforms,
658+
/// the bit is not used and the address is always 0.
659+
SWIFT_EXPORT_FROM(swift_Concurrency)
660+
struct { char c; } swift_async_extendedFramePointerFlags;
661+
#endif
662+
651663
}
652664

653665
#pragma clang diagnostic pop

stdlib/public/Concurrency/Task.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@
3333
#include <dlfcn.h>
3434
#endif
3535

36+
#ifdef __APPLE__
37+
#if __POINTER_WIDTH__ == 64
38+
asm("\n .globl _swift_async_extendedFramePointerFlags" \
39+
"\n _swift_async_extendedFramePointerFlags = 0x1000000000000000");
40+
#elif __ARM64_ARCH_8_32__
41+
asm("\n .globl _swift_async_extendedFramePointerFlags" \
42+
"\n _swift_async_extendedFramePointerFlags = 0x10000000");
43+
#else
44+
asm("\n .globl _swift_async_extendedFramePointerFlags" \
45+
"\n _swift_async_extendedFramePointerFlags = 0x0");
46+
#endif
47+
#endif // __APPLE__
48+
3649
using namespace swift;
3750
using FutureFragment = AsyncTask::FutureFragment;
3851
using TaskGroup = swift::TaskGroup;

0 commit comments

Comments
 (0)