From 02ded6d0bb4f507db2cf637d49d291be3a38a3eb Mon Sep 17 00:00:00 2001 From: Tadeu Zagallo Date: Mon, 7 Dec 2015 06:39:16 -0800 Subject: [PATCH] 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 --- React/Profiler/RCTProfileTrampoline-x86_64.S | 27 ++++++++------------ 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/React/Profiler/RCTProfileTrampoline-x86_64.S b/React/Profiler/RCTProfileTrampoline-x86_64.S index 02fa010a48..6d9c93fb7c 100644 --- a/React/Profiler/RCTProfileTrampoline-x86_64.S +++ b/React/Profiler/RCTProfileTrampoline-x86_64.S @@ -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