Skip to content

Commit 35b94fe

Browse files
committed
Implement __sd_gc_push_registers for ARM64.
1 parent 5167f9c commit 35b94fe

File tree

4 files changed

+35
-7
lines changed

4 files changed

+35
-7
lines changed

platform/arm64/arm64.mak

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
PLATFORM_ARM64_ASM_SRC = $(wildcard platform/arm64/*.asm)
2+
PLATFORM_ASM_SRC += $(PLATFORM_ARM64_ASM_SRC)
3+
4+
PLATFORM_ARM64_ASM_OBJ = $(PLATFORM_ARM64_ASM_SRC:platform/%.asm=obj/%.o)
5+
PLATFORM_ASM_OBJ += $(PLATFORM_ARM64_ASM_OBJ)
6+
7+
# Add the objects to expected variables.
8+
LIBSDRT_PLATFORM_OBJ += $(PLATFORM_ARM64_ASM_OBJ)
9+
LIBSDMD_PLATFORM_OBJ += $(PLATFORM_ARM64_ASM_OBJ)

platform/arm64/save_regs.asm

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.global ___sd_gc_push_registers
2+
3+
.section __TEXT,__text
4+
5+
___sd_gc_push_registers:
6+
; Standard call ABI. x29 is the frame pointer and x30 the link register.
7+
sub sp, sp, #96
8+
stp x29, x30, [sp, #80]
9+
add x29, sp, #80
10+
; Registers x19-28 are callee saved.
11+
stp x19, x20, [sp, #0]
12+
stp x21, x22, [sp, #16]
13+
stp x23, x24, [sp, #32]
14+
stp x25, x26, [sp, #48]
15+
stp x27, x28, [sp, #64]
16+
; This method is passed a delegate. x0 contains the context as a first argument
17+
; and x1, the second argument is the function pointer. x0 do not need any special
18+
; threatement as it is also the first argument when calling the delegate.
19+
blr x1
20+
; Restore the frame pointer and link register and return.
21+
ldp x29, x30, [sp, #80]
22+
add sp, sp, #96
23+
ret

platform/platform.mak

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ endif
1818

1919
ifeq ($(ARCH),x86_64)
2020
include platform/x64/x64.mak
21+
else ifeq ($(ARCH),arm64)
22+
include platform/arm64/arm64.mak
2123
endif
2224

2325
# FIXME: depfiles.

sdlib/d/gc/stack.d

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@ module d.gc.stack;
22

33
import d.gc.types;
44

5-
version(OSX) {
6-
// For some reason OSX's symbol get a _ prepended.
7-
extern(C) void _sd_gc_push_registers(void delegate());
8-
alias __sd_gc_push_registers = _sd_gc_push_registers;
9-
} else {
10-
extern(C) void __sd_gc_push_registers(void delegate());
11-
}
5+
extern(C) void __sd_gc_push_registers(void delegate());
126

137
@property
148
void* SkipScanStack() {

0 commit comments

Comments
 (0)