Skip to content

Commit 5fd0a3b

Browse files
committed
Save and restore xmm regs across the call to UPCALL_NEW_STACK during __morestack, close #1388.
1 parent 884adf3 commit 5fd0a3b

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/rt/arch/i386/morestack.S

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ MORESTACK:
150150
movl %ecx, 16(%esp)
151151
movl %edx, 12(%esp)
152152

153+
// FIXME (1388): it's possible we also need to save/restore some
154+
// SSE2 registers here, if floats-go-in-regs on x86+SSE2. Unclear.
155+
153156
// FIXME (1226): main is compiled with the split-stack prologue,
154157
// causing it to call __morestack, so we have to jump back out
155158
calll RUST_GET_TASK

src/rt/arch/x86_64/morestack.S

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,19 @@ MORESTACK:
6161
pushq %r8
6262
pushq %r9
6363

64+
pushq $0 // Alignment
65+
pushq $0 // Alignment
66+
67+
subq $128, %rsp
68+
movdqa %xmm0, (%rsp)
69+
movdqa %xmm1, 16(%rsp)
70+
movdqa %xmm2, 32(%rsp)
71+
movdqa %xmm3, 48(%rsp)
72+
movdqa %xmm4, 64(%rsp)
73+
movdqa %xmm5, 80(%rsp)
74+
movdqa %xmm6, 96(%rsp)
75+
movdqa %xmm7, 112(%rsp)
76+
6477
// Calculate the address of the stack arguments.
6578
// We have the base pointer, __morestack's return address,
6679
// and __morestack's caller's return address to skip
@@ -72,7 +85,7 @@ MORESTACK:
7285
movq %r11, %rdx // Size of stack arguments
7386
movq %rax, %rsi // Address of stack arguments
7487
movq %r10, %rdi // The amount of stack needed
75-
88+
7689
#ifdef __APPLE__
7790
call UPCALL_NEW_STACK
7891
#endif
@@ -81,6 +94,19 @@ MORESTACK:
8194
#endif
8295

8396
// Pop the saved arguments
97+
movdqa (%rsp), %xmm0
98+
movdqa 16(%rsp), %xmm1
99+
movdqa 32(%rsp), %xmm2
100+
movdqa 48(%rsp), %xmm3
101+
movdqa 64(%rsp), %xmm4
102+
movdqa 80(%rsp), %xmm5
103+
movdqa 96(%rsp), %xmm6
104+
movdqa 112(%rsp), %xmm7
105+
addq $128, %rsp
106+
107+
popq %r9 // Alignment
108+
popq %r9 // Alignment
109+
84110
popq %r9
85111
popq %r8
86112
popq %rcx

0 commit comments

Comments
 (0)