From owner-dev-commits-src-all@freebsd.org Tue Feb 9 15:28:07 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 661E5542921; Tue, 9 Feb 2021 15:28:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DZmxM2QqYz58wq; Tue, 9 Feb 2021 15:28:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3B763523B; Tue, 9 Feb 2021 15:28:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 119FS72K048234; Tue, 9 Feb 2021 15:28:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 119FS7uZ048233; Tue, 9 Feb 2021 15:28:07 GMT (envelope-from git) Date: Tue, 9 Feb 2021 15:28:07 GMT Message-Id: <202102091528.119FS7uZ048233@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: b49a0db6628e - main - Revert "amd64: implement strlen in assembly" MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b49a0db6628e6f953504ebc8712ed582471ccd05 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Feb 2021 15:28:07 -0000 The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=b49a0db6628e6f953504ebc8712ed582471ccd05 commit b49a0db6628e6f953504ebc8712ed582471ccd05 Author: Mateusz Guzik AuthorDate: 2021-02-09 15:18:58 +0000 Commit: Mateusz Guzik CommitDate: 2021-02-09 15:23:18 +0000 Revert "amd64: implement strlen in assembly" This reverts commit af366d353b84bdc4e730f0fc563853abc338271c. Trips over '\xa4' byte and terminates early, as found in lib/libc/gen/setdomainname_test:setdomainname_basic testcase However, keep moving libkern/strlen.c out of conf/files. Reported by: lwhsu --- sys/amd64/amd64/support.S | 66 ----------------------------------------------- sys/conf/files.amd64 | 1 + 2 files changed, 1 insertion(+), 66 deletions(-) diff --git a/sys/amd64/amd64/support.S b/sys/amd64/amd64/support.S index a059b520c5d5..b623fba277db 100644 --- a/sys/amd64/amd64/support.S +++ b/sys/amd64/amd64/support.S @@ -697,72 +697,6 @@ ENTRY(fillw) ret END(fillw) -/* - * strlen(string) - * %rdi - * - * Uses the ((x - 0x01....01) & ~x & 0x80....80) trick. - * - * 0x01....01 is replaced with 0x0 - 0x01....01 so that it can be added - * with leaq. - * - * For a description see either: - * - "Hacker's Delight" by Henry S. Warren, Jr. - * - "Optimizing subroutines in assembly language: An optimization guide for x86 platforms" - * by Agner Fog - * - * The latter contains a 32-bit variant of the same algorithm coded in assembly for i386. - */ -ENTRY(strlen) - PUSH_FRAME_POINTER - movabsq $0xfefefefefefefeff,%r8 - movabsq $0x8080808080808080,%r9 - - movq %rdi,%r10 - movq %rdi,%rcx - testb $7,%dil - jz 2f - - /* - * Handle misaligned reads: align to 8 and fill - * the spurious bytes. - */ - andq $~7,%rdi - movq (%rdi),%r11 - shlq $3,%rcx - movq $-1,%rdx - shlq %cl,%rdx - notq %rdx - orq %rdx,%r11 - - leaq (%r11,%r8),%rcx - notq %r11 - andq %r11,%rcx - andq %r9,%rcx - jnz 3f - - /* - * Main loop. - */ - ALIGN_TEXT -1: - leaq 8(%rdi),%rdi -2: - movq (%rdi),%r11 - leaq (%r11,%r8),%rcx - notq %r11 - andq %rcx,%r11 - andq %r9,%rcx - jz 1b -3: - bsfq %rcx,%rcx - shrq $3,%rcx - leaq (%rcx,%rdi),%rax - subq %r10,%rax - POP_FRAME_POINTER - ret -END(strlen) - /*****************************************************************************/ /* copyout and fubyte family */ /*****************************************************************************/ diff --git a/sys/conf/files.amd64 b/sys/conf/files.amd64 index 395f501198f8..98a78a8b1ef9 100644 --- a/sys/conf/files.amd64 +++ b/sys/conf/files.amd64 @@ -390,6 +390,7 @@ isa/syscons_isa.c optional sc isa/vga_isa.c optional vga kern/imgact_aout.c optional compat_aout kern/link_elf_obj.c standard +libkern/strlen.c standard # # IA32 binary support #