Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/arch/i386/string Avoid redundant memory access.



details:   https://anonhg.NetBSD.org/src/rev/e05ad1222004
branches:  trunk
changeset: 533835:e05ad1222004
user:      kent <kent%NetBSD.org@localhost>
date:      Wed Jul 10 06:01:51 2002 +0000

description:
Avoid redundant memory access.
Fix diagnostic code for bcopy().

diffstat:

 lib/libc/arch/i386/string/bcopy.S |  50 ++++++++++++++++++++++----------------
 1 files changed, 29 insertions(+), 21 deletions(-)

diffs (112 lines):

diff -r 9c2915c6eac8 -r e05ad1222004 lib/libc/arch/i386/string/bcopy.S
--- a/lib/libc/arch/i386/string/bcopy.S Wed Jul 10 05:56:44 2002 +0000
+++ b/lib/libc/arch/i386/string/bcopy.S Wed Jul 10 06:01:51 2002 +0000
@@ -36,7 +36,7 @@
 #include <machine/asm.h>
 
 #if defined(LIBC_SCCS)
-       RCSID("$NetBSD: bcopy.S,v 1.7 2002/07/04 15:48:40 kent Exp $")
+       RCSID("$NetBSD: bcopy.S,v 1.8 2002/07/10 06:01:51 kent Exp $")
 #endif
 
        /*
@@ -58,71 +58,79 @@
 #if defined(MEMCOPY) || defined(MEMMOVE)
        movl    12(%esp),%edi
        movl    16(%esp),%esi
+       movl    %edi,%eax       /* return value */
 #else
        movl    12(%esp),%esi
        movl    16(%esp),%edi
 #endif
        movl    20(%esp),%ecx
-       movl    %edi,%eax
-       subl    %esi,%eax
-       cmpl    %ecx,%eax       /* overlapping? */
+       movl    %edi,%edx
+       subl    %esi,%edx
+       cmpl    %ecx,%edx       /* overlapping? */
+       movl    %ecx,%edx
        jb      1f
        cld                     /* nope, copy forwards. */
        shrl    $2,%ecx         /* copy by words */
        rep
        movsl
-       movl    20(%esp),%ecx
+       movl    %edx,%ecx
        andl    $3,%ecx         /* any bytes left? */
        rep
        movsb
-#if defined(MEMCOPY) || defined(MEMMOVE)
-       movl    12(%esp),%eax
-#endif
        popl    %edi
        popl    %esi
        ret
 1:
        addl    %ecx,%edi       /* copy backwards. */
        addl    %ecx,%esi
+
 #ifdef _DIAGNOSTIC
-#define _DIAGASSERT    call    _C_LABEL(__diagassert13)
-       cmpl    12(%esp),%edi   /* check pointer wraparound */
+                               /* check pointer wraparound */
+#if defined(MEMCOPY) || defined(MEMMOVE)
+       cmpl    12(%esp),%edi
+#else
+       cmpl    16(%esp),%edi
+#endif
        jae     2f
        pushl   $diagmes1
        pushl   $func
        pushl   $__LINE__-4
-       pushl   $file
-       _DIAGASSERT
-       addl    $16,%esp
        jmp     4f
 2:     
+#if defined(MEMCOPY) || defined(MEMMOVE)
        cmpl    16(%esp),%esi
+#else
+       cmpl    12(%esp),%esi
+#endif
        jae     3f
        pushl   $diagmes2
        pushl   $func
        pushl   $__LINE__-4
+4:     
        pushl   $file
-       _DIAGASSERT
+       call    _C_LABEL(__diagassert13)
        addl    $16,%esp
-       jmp     4f
+#if defined(MEMCOPY) || defined(MEMMOVE)
+       movl    12(%esp),%eax
+#endif
+       popl    %edi
+       popl    %esi
+       ret
 3:
-#endif
+#endif /* _DIAGNOSTIC */
+
        std
        andl    $3,%ecx         /* any fractional bytes? */
        decl    %edi
        decl    %esi
        rep
        movsb
-       movl    20(%esp),%ecx   /* copy remainder by words */
+       movl    %edx,%ecx       /* copy remainder by words */
        shrl    $2,%ecx
        subl    $3,%esi
        subl    $3,%edi
        rep
        movsl
-4:
-#if defined(MEMCOPY) || defined(MEMMOVE)
-       movl    12(%esp),%eax
-#endif
        popl    %edi
        popl    %esi
        cld



Home | Main Index | Thread Index | Old Index