Preserve all return registers on x86_64 trampoline

Summary:
public

Only the first quad-word and floating point return registers were being preserved,
make sure to preserve the 2nd ones as well (`%rdx` and `%xmm1`)

Reviewed By: jspahrsummers

Differential Revision: D2727523

fb-gh-sync-id: d8176512d2dfb5f664f634ecaaf34510515506ea
This commit is contained in:
Tadeu Zagallo 2015-12-07 06:39:16 -08:00 committed by facebook-github-bot-7
parent 69ce5ab5b8
commit 02ded6d0bb
1 changed files with 11 additions and 16 deletions

View File

@ -142,21 +142,14 @@ SYMBOL_NAME(RCTProfileTrampoline):
// call the actual function and save the return value
callq *%r11
pushq %rax
subq $0x10+8, %rsp //16-bytes xmm register + 8-bytes for alignment
movdqa %xmm0, (%rsp)
// align stack
pushq %r12
movq %rsp, %r12
andq $-0x10, %rsp
pushq %rdx
subq $0x20, %rsp // 2 16-bytes xmm register
movdqa %xmm0, 0x00(%rsp)
movdqa %xmm1, 0x10(%rsp)
// void RCTProfileTrampolineEnd(void) in RCTProfile.m - just ends this profile
callq SYMBOL_NAME(RCTProfileTrampolineEnd)
// unalign stack and restore %r12
movq %r12, %rsp
popq %r12
/**
* Restore the initial value of the callee saved registers, saved in the
* memory allocated.
@ -167,7 +160,7 @@ SYMBOL_NAME(RCTProfileTrampoline):
movq 0x8(%r14), %r14
/**
* Save caller address and actual function return (previously in the allocated
* save caller address and actual function return (previously in the allocated
* memory) and align the stack
*/
pushq %rcx
@ -183,12 +176,14 @@ SYMBOL_NAME(RCTProfileTrampoline):
popq %r12
/**
* pop the caller address to %rcx and the actual function return value to
* %rax, so it's the return value of RCTProfileTrampoline
* pop the caller address to %rcx and the actual function return value(s)
* so it's the return value of RCTProfileTrampoline
*/
popq %rcx
movdqa (%rsp), %xmm0
addq $0x10+8, %rsp
movdqa 0x00(%rsp), %xmm0
movdqa 0x10(%rsp), %xmm1
addq $0x20, %rsp
popq %rdx
popq %rax
// jump to caller