From 70be530f7f4bc8c53d6585242eb4fd0c22f84a3e Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 15 Feb 2022 09:40:17 -0800 Subject: [PATCH] Tidy up comments in the x86 syscall code. --- src/imp/linux_raw/arch/inline/x86.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/imp/linux_raw/arch/inline/x86.rs b/src/imp/linux_raw/arch/inline/x86.rs index f2113e9c4..0cbdece57 100644 --- a/src/imp/linux_raw/arch/inline/x86.rs +++ b/src/imp/linux_raw/arch/inline/x86.rs @@ -416,8 +416,10 @@ pub(in crate::imp) unsafe fn syscall5( a4: ArgReg<'_, A4>, ) -> RetReg { let r0; - // As in syscall 4, use xchg to handle a3. a4 should go in edi, and - // we can use that register as an operand. + // As in `syscall4`, use xchg to handle a3. a4 should go in edi, and we can + // use that register as an operand. Unlike in `indirect_syscall5`, we don't + // have a `callee` operand taking up a register, so we have enough + // registers and don't need to use a slice. asm!( ".ifnes \"{a3}\",\"esi\"", "xchg esi, {a3}", @@ -448,6 +450,7 @@ pub(in crate::imp) unsafe fn syscall5_readonly( a4: ArgReg<'_, A4>, ) -> RetReg { let r0; + // See the comments in `syscall5`. asm!( ".ifnes \"{a3}\",\"esi\"", "xchg esi, {a3}", @@ -479,14 +482,7 @@ pub(in crate::imp) unsafe fn syscall6( a5: ArgReg<'_, A5>, ) -> RetReg { let r0; - // Oof. a3 should go in esi, and a5 should go in ebp, and `asm!` won't - // let us use either of those registers as operands. And we can't request - // stack slots. And there are no other registers free. Use eax as a - // temporary pointer to a slice, since it gets clobbered as the return - // value anyway. - // - // This is another reason that syscalls should be compiler intrinsics - // rather than inline asm. + // See the comments in `indirect_syscall6`. asm!( "push ebp", "push esi", @@ -518,6 +514,7 @@ pub(in crate::imp) unsafe fn syscall6_readonly( a5: ArgReg<'_, A5>, ) -> RetReg { let r0; + // See the comments in `indirect_syscall6`. asm!( "push ebp", "push esi",