From 1ea4b01edae914abff1a5e9e613589a70c660473 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sat, 16 Jul 2016 12:28:07 -0700 Subject: [PATCH] Use mostly the same registers for consistency The exception to this is %eax is used not %edi on x86 because its caller-save --- src/arch/x86.rs | 4 ++-- src/arch/x86_64.rs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/arch/x86.rs b/src/arch/x86.rs index 5514f4d..686751d 100644 --- a/src/arch/x86.rs +++ b/src/arch/x86.rs @@ -81,7 +81,7 @@ pub unsafe fn swap(arg: usize, old_sp: &mut StackPointer, new_sp: &StackPointer) # Remember stack pointer of the old context, in case %rdx==%rsi. movl %esp, %ebx # Load stack pointer of the new context. - movl (%edi), %esp + movl (%edx), %esp # Save stack pointer of the old context. movl %ebx, (%esi) @@ -95,7 +95,7 @@ pub unsafe fn swap(arg: usize, old_sp: &mut StackPointer, new_sp: &StackPointer) : "={eax}" (ret) : "{eax}" (arg) "{esi}" (old_sp) - "{edi}" (new_sp) + "{edx}" (new_sp) : "eax", "ebx", "ecx", "edx", "esi", "edi", //"ebp", "esp", "mmx0", "mmx1", "mmx2", "mmx3", "mmx4", "mmx5", "mmx6", "mmx7", "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", diff --git a/src/arch/x86_64.rs b/src/arch/x86_64.rs index f2c8ee4..5f9559b 100644 --- a/src/arch/x86_64.rs +++ b/src/arch/x86_64.rs @@ -58,17 +58,17 @@ pub unsafe fn swap(arg: usize, old_sp: &mut StackPointer, new_sp: &StackPointer) 1: # Remember stack pointer of the old context, in case %rdx==%rsi. - movq %rsp, %rax + movq %rsp, %rbx # Load stack pointer of the new context. movq (%rdx), %rsp # Save stack pointer of the old context. - movq %rax, (%rsi) + movq %rbx, (%rsi) # Pop instruction pointer of the new context (placed onto stack by # the call above) and jump there; don't use `ret` to avoid return # address mispredictions (~8ns on Ivy Bridge). - popq %rax - jmpq *%rax + popq %rbx + jmpq *%rbx 2: "# : "={rdi}" (ret)