diff options
author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2023-08-25 13:28:33 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-25 13:28:33 +1200 |
commit | 40d774bec68de3f252c0b252d9d0303a67bee0cb (patch) | |
tree | 52bbc29762bdef7fb17ab1471ddbe1f9dc5447f8 /coroutine | |
parent | 97a97d6d6cb68516555000b650cd69715587e53b (diff) |
Avoid memory dependency between instructions. (#8284)
Notes
Notes:
Merged-By: ioquatix <samuel@codeotaku.com>
Diffstat (limited to 'coroutine')
-rw-r--r-- | coroutine/amd64/Context.S | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/coroutine/amd64/Context.S b/coroutine/amd64/Context.S index d50732adbc..056c276a31 100644 --- a/coroutine/amd64/Context.S +++ b/coroutine/amd64/Context.S @@ -13,29 +13,35 @@ .globl PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer) PREFIXED_SYMBOL(SYMBOL_PREFIX,coroutine_transfer): - # Save caller state - pushq %rbp - pushq %rbx - pushq %r12 - pushq %r13 - pushq %r14 - pushq %r15 - - # Save caller stack pointer + # Make space on the stack for 6 registers: + subq $48, %rsp + + # Save caller state: + movq %rbp, 40(%rsp) + movq %rbx, 32(%rsp) + movq %r12, 24(%rsp) + movq %r13, 16(%rsp) + movq %r14, 8(%rsp) + movq %r15, (%rsp) + + # Save caller stack pointer: movq %rsp, (%rdi) - # Restore callee stack pointer + # Restore callee stack pointer: movq (%rsi), %rsp # Restore callee state - popq %r15 - popq %r14 - popq %r13 - popq %r12 - popq %rbx - popq %rbp - - # Put the first argument into the return value + movq 40(%rsp), %rbp + movq 32(%rsp), %rbx + movq 24(%rsp), %r12 + movq 16(%rsp), %r13 + movq 8(%rsp), %r14 + movq (%rsp), %r15 + + # Adjust stack pointer back: + addq $48, %rsp + + # Put the first argument into the return value: movq %rdi, %rax # We pop the return address and jump to it |