Skip to content

Commit

Permalink
libphobos: Handle Darwin Arm and AArch64 in fibre context asm.
Browse files Browse the repository at this point in the history
Tested on AArch64 (Arm64) Darwin on 11.x, 13.x and master,
OK for trunk?
and backports?
thanks
Iain
  • Loading branch information
iains authored and ouuleilei-bot committed Jul 2, 2023
1 parent c2d62cd commit 593d4a5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
9 changes: 8 additions & 1 deletion libphobos/libdruntime/config/aarch64/switchcontext.S
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
*/
.text
.global CSYM(fiber_switchContext)
#ifndef __APPLE__
.type CSYM(fiber_switchContext), %function
#endif
.align 4
CSYM(fiber_switchContext):
.cfi_startproc
Expand Down Expand Up @@ -77,8 +79,9 @@ CSYM(fiber_switchContext):
ldp d15, d14, [sp], #20*8
ret
.cfi_endproc
#ifndef __APPLE__
.size CSYM(fiber_switchContext),.-CSYM(fiber_switchContext)

#endif
/**
* When generating any kind of backtrace (gdb, exception handling) for
* a function called in a Fiber, we need to tell the unwinder to stop
Expand All @@ -93,11 +96,15 @@ CSYM(fiber_switchContext):
.text
.global CSYM(fiber_trampoline)
.p2align 2
#ifndef __APPLE__
.type CSYM(fiber_trampoline), %function
#endif
CSYM(fiber_trampoline):
.cfi_startproc
.cfi_undefined x30
// fiber_entryPoint never returns
bl CSYM(fiber_entryPoint)
.cfi_endproc
#ifndef __APPLE__
.size CSYM(fiber_trampoline),.-CSYM(fiber_trampoline)
#endif
8 changes: 8 additions & 0 deletions libphobos/libdruntime/config/arm/switchcontext.S
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
*/

.text
#ifndef __APPLE__
#if defined(__ARM_PCS_VFP) || (defined(__ARM_PCS) && !defined(__SOFTFP__))
.fpu vfp
#endif
.global CSYM(fiber_switchContext)
.type CSYM(fiber_switchContext), %function
#else
.global CSYM(fiber_switchContext)
#endif
.align 4
CSYM(fiber_switchContext):
.cfi_sections .debug_frame
Expand Down Expand Up @@ -111,8 +115,12 @@ CSYM(fiber_switchContext):
mov lr, #0
// return by writing lr into pc
mov pc, r1
#ifndef __APPLE__
.fnend
.cfi_endproc
.size CSYM(fiber_switchContext),.-CSYM(fiber_switchContext)
#else
.cfi_endproc
#endif

#endif
1 change: 1 addition & 0 deletions libphobos/libdruntime/core/thread/fiber.d
Original file line number Diff line number Diff line change
Expand Up @@ -1785,6 +1785,7 @@ version (OSX)
{
version (X86) version = UnsafeFiberMigration;
version (X86_64) version = UnsafeFiberMigration;
version (AArch64) version = UnsafeFiberMigration;
}

version (UnsafeFiberMigration)
Expand Down

0 comments on commit 593d4a5

Please sign in to comment.