From owner-svn-src-all@freebsd.org Thu Nov 22 16:27:31 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C2894114BB00; Thu, 22 Nov 2018 16:27:31 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 665C17C281; Thu, 22 Nov 2018 16:27:31 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3FC4712483; Thu, 22 Nov 2018 16:27:31 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wAMGRVZS074339; Thu, 22 Nov 2018 16:27:31 GMT (envelope-from marius@FreeBSD.org) Received: (from marius@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wAMGRV3G074338; Thu, 22 Nov 2018 16:27:31 GMT (envelope-from marius@FreeBSD.org) Message-Id: <201811221627.wAMGRV3G074338@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: marius set sender to marius@FreeBSD.org using -f From: Marius Strobl Date: Thu, 22 Nov 2018 16:27:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org Subject: svn commit: r340768 - releng/12.0/sys/sparc64/sparc64 X-SVN-Group: releng X-SVN-Commit-Author: marius X-SVN-Commit-Paths: releng/12.0/sys/sparc64/sparc64 X-SVN-Commit-Revision: 340768 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 665C17C281 X-Spamd-Result: default: False [1.10 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_SPAM_SHORT(0.17)[0.169,0]; NEURAL_SPAM_MEDIUM(0.51)[0.514,0]; NEURAL_SPAM_LONG(0.42)[0.420,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-Rspamd-Server: mx1.freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 22 Nov 2018 16:27:32 -0000 Author: marius Date: Thu Nov 22 16:27:30 2018 New Revision: 340768 URL: https://svnweb.freebsd.org/changeset/base/340768 Log: MFC: r340656, MF12: r340759 Given that the idea of D15374 was to "make memmove a first class citizen", provide a _MEMMOVE extension of _MEMCPY that deals with overlap based on the previous bcopy(9) implementation and use the former for bcopy(9) and memmove(9). This addresses my D15374 review comment, avoiding extra MOVs in case of memmove(9) and trashing the stack pointer. Approved by: re (kib) Modified: releng/12.0/sys/sparc64/sparc64/support.S Directory Properties: releng/12.0/ (props changed) Modified: releng/12.0/sys/sparc64/sparc64/support.S ============================================================================== --- releng/12.0/sys/sparc64/sparc64/support.S Thu Nov 22 16:15:24 2018 (r340767) +++ releng/12.0/sys/sparc64/sparc64/support.S Thu Nov 22 16:27:30 2018 (r340768) @@ -207,6 +207,30 @@ __FBSDID("$FreeBSD$"); 6: /* + * Extension of _MEMCPY dealing with overlap, but unaware of ASIs. + * Used for bcopy() and memmove(). + */ +#define _MEMMOVE(dst, src, len) \ + /* Check for overlap, and copy backwards if so. */ \ + sub dst, src, %g1 ; \ + cmp %g1, len ; \ + bgeu,a,pt %xcc, 2f ; \ + nop ; \ + /* Copy backwards. */ \ + add src, len, src ; \ + add dst, len, dst ; \ +1: deccc 1, len ; \ + bl,pn %xcc, 3f ; \ + dec 1, src ; \ + ldub [src], %g1 ; \ + dec 1, dst ; \ + ba %xcc, 1b ; \ + stb %g1, [dst] ; \ +2: /* Do the fast version. */ \ + _MEMCPY(dst, src, len, EMPTY, EMPTY, EMPTY, EMPTY) ; \ +3: + +/* * void ascopy(u_long asi, vm_offset_t src, vm_offset_t dst, size_t len) */ ENTRY(ascopy) @@ -265,49 +289,14 @@ ENTRY(bcmp) END(bcmp) /* - * void *memmove(void *dst, const void *src, size_t len) * void bcopy(const void *src, void *dst, size_t len) */ -ENTRY(memmove) - /* - * Swap src/dst for memmove/bcopy differences - */ - mov %o0, %o6 - mov %o1, %o0 - mov %o6, %o1 -ALTENTRY(bcopy) - /* - * Check for overlap, and copy backwards if so. - */ - sub %o1, %o0, %g1 - cmp %g1, %o2 - bgeu,a,pt %xcc, 3f +ENTRY(bcopy) + _MEMMOVE(%o1, %o0, %o2) + retl nop +END(bcopy) - /* - * Copy backwards. - */ - add %o0, %o2, %o0 - add %o1, %o2, %o1 -1: deccc 1, %o2 - bl,a,pn %xcc, 2f - nop - dec 1, %o0 - ldub [%o0], %g1 - dec 1, %o1 - ba %xcc, 1b - stb %g1, [%o1] -2: retl - mov %o6, %o0 - - /* - * Do the fast version. - */ -3: _MEMCPY(%o1, %o0, %o2, EMPTY, EMPTY, EMPTY, EMPTY) - retl - mov %o6, %o0 -END(memmove) - /* * void bzero(void *b, size_t len) */ @@ -335,6 +324,16 @@ ENTRY(memcpy) retl nop END(memcpy) + +/* + * void *memmove(void *dst, const void *src, size_t len) + */ +ENTRY(memmove) + mov %o0, %o3 + _MEMMOVE(%o3, %o1, %o2) + retl + nop +END(memmove) /* * void *memset(void *b, int c, size_t len)