From c3ad51703ce506c5c3b1b7f80a8ca78c37aba2b4 Mon Sep 17 00:00:00 2001 From: Venkatesh Srinivas Date: Sun, 27 Nov 2011 09:57:36 -0800 Subject: [PATCH] libc -- Remove assembler i386 strlen() routine. On a number of processors, it is slower than the obvious C version. (400,000,000 loops, times in sec) On a 2.66 GHz Core 2: asm C 10-by string 22.9 9.5 68-by string 77.2 19.8 175-by string 173.7 40.6 On a 2.0 GHz Athlon64 3000+: asm C 10-by string 11.3 9.9 68-by string 34.7 34.7 175-by string 78.7 77.6 On a 2.2 GHz Core i7 (nehalem): asm C 10-by string 13.4 5.2 68-by string 33.8 29.5 175-by string 71.6 67.4 --- lib/libc/i386/string/Makefile.inc | 3 +- lib/libc/i386/string/strlen.S | 55 ------------------------------- 2 files changed, 1 insertion(+), 57 deletions(-) delete mode 100644 lib/libc/i386/string/strlen.S diff --git a/lib/libc/i386/string/Makefile.inc b/lib/libc/i386/string/Makefile.inc index 17b8219559..1f2ed530d8 100644 --- a/lib/libc/i386/string/Makefile.inc +++ b/lib/libc/i386/string/Makefile.inc @@ -1,7 +1,6 @@ # @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 # $FreeBSD: src/lib/libc/i386/string/Makefile.inc,v 1.9 1999/08/27 23:59:29 peter Exp $ -# $DragonFly: src/lib/libc/i386/string/Makefile.inc,v 1.2 2003/06/17 04:26:43 dillon Exp $ MDSRCS+=bcmp.S bcopy.S bzero.S ffs.S ffsl.S fls.S flsl.S index.S memchr.S \ memcmp.S memcpy.S memmove.S memset.S rindex.S strcat.S strchr.S \ - strcmp.S strcpy.S strlen.S strncmp.S strrchr.S swab.S + strcmp.S strcpy.S strncmp.S strrchr.S swab.S diff --git a/lib/libc/i386/string/strlen.S b/lib/libc/i386/string/strlen.S deleted file mode 100644 index 506ea7d51d..0000000000 --- a/lib/libc/i386/string/strlen.S +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 1993 Winning Strategies, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Winning Strategies, Inc. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * $FreeBSD: src/lib/libc/i386/string/strlen.S,v 1.5 1999/08/27 23:59:34 peter Exp $ - * $DragonFly: src/lib/libc/i386/string/strlen.S,v 1.3 2003/12/06 03:11:36 drhodus Exp $ - */ - -#include "DEFS.h" - -/* - * strlen (s) - * compute the length of the string s. - * - * Written by: - * J.T. Conklin (jtc@wimsey.com), Winning Strategies, Inc. - */ - -ENTRY(strlen) - pushl %edi - movl 8(%esp),%edi /* string address */ - cld /* set search forward */ - xorl %eax,%eax /* set search for null terminator */ - movl $-1,%ecx /* set search for lots of characters */ - repne /* search! */ - scasb - notl %ecx /* get length by taking complement */ - leal -1(%ecx),%eax /* and subtracting one */ - popl %edi - ret -- 2.41.0