diff options
author | Stefan Fritsch <sf@cvs.openbsd.org> | 2012-11-18 12:17:41 +0000 |
---|---|---|
committer | Stefan Fritsch <sf@cvs.openbsd.org> | 2012-11-18 12:17:41 +0000 |
commit | 0e94671412c59a1bcf6f69279a1bea633ec682de (patch) | |
tree | a908d0a2164d4496baef91cb6130349dfd5223c3 /sys | |
parent | 0a199aba1829fff8571512d74a89b4b13ff57082 (diff) |
Small memcpy optimizations
On x86, the xchg operation between reg and mem has an implicit lock
prefix, i.e. on MP, it is a relatively expensive atomic operation.
This is not needed here.
Instead of swapping arguments on the stack, load them in reverse order
and jump further into bcopy (idea by kettenis@).
ok kettenis@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/i386/i386/locore.s | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/sys/arch/i386/i386/locore.s b/sys/arch/i386/i386/locore.s index f2f42b22202..ff1516df7cb 100644 --- a/sys/arch/i386/i386/locore.s +++ b/sys/arch/i386/i386/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.144 2012/11/10 09:45:05 mglocker Exp $ */ +/* $OpenBSD: locore.s,v 1.145 2012/11/18 12:17:40 sf Exp $ */ /* $NetBSD: locore.s,v 1.145 1996/05/03 19:41:19 christos Exp $ */ /*- @@ -789,6 +789,7 @@ ENTRY(bcopy) pushl %edi movl 12(%esp),%esi movl 16(%esp),%edi +docopy: movl 20(%esp),%ecx movl %edi,%eax subl %esi,%eax @@ -827,13 +828,15 @@ ENTRY(bcopy) ret /* - * Emulate memcpy() by swapping the first two arguments and calling bcopy() + * Emulate memcpy() by loading the first two arguments in reverse order + * and jumping into bcopy() */ ENTRY(memcpy) - movl 4(%esp),%ecx - xchg 8(%esp),%ecx - movl %ecx,4(%esp) - jmp _C_LABEL(bcopy) + pushl %esi + pushl %edi + movl 12(%esp),%edi + movl 16(%esp),%esi + jmp docopy /*****************************************************************************/ |