Module Name: src Committed By: thorpej Date: Wed Jul 7 02:44:04 UTC 2021
Modified Files: src/sys/arch/alpha/alpha: locore.s Log Message: Re-arrange alpha_copystr() so that the the error/unlikely cases are forward branches (which will be predicted as not-taken), and that the likely cases are fall-through, with the exception of the loop branch (which is a backward branch, and thus will be predicted as taken). To generate a diff of this commit: cvs rdiff -u -r1.137 -r1.138 src/sys/arch/alpha/alpha/locore.s Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/alpha/alpha/locore.s diff -u src/sys/arch/alpha/alpha/locore.s:1.137 src/sys/arch/alpha/alpha/locore.s:1.138 --- src/sys/arch/alpha/alpha/locore.s:1.137 Sun May 23 01:00:53 2021 +++ src/sys/arch/alpha/alpha/locore.s Wed Jul 7 02:44:04 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.137 2021/05/23 01:00:53 thorpej Exp $ */ +/* $NetBSD: locore.s,v 1.138 2021/07/07 02:44:04 thorpej Exp $ */ /*- * Copyright (c) 1999, 2000, 2019 The NetBSD Foundation, Inc. @@ -67,7 +67,7 @@ #include <machine/asm.h> -__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.137 2021/05/23 01:00:53 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: locore.s,v 1.138 2021/07/07 02:44:04 thorpej Exp $"); #include "assym.h" @@ -900,15 +900,13 @@ LEAF_NOPROFILE(lwp_trampoline, 0) /**************************************************************************/ /* - * XXX XXX XXX: Should be removed? + * alpha_copystr(const void *from, void *to, size_t len, size_t *donep) */ LEAF(alpha_copystr, 4) LDGP(pv) mov a2, t0 /* t0 = i = len */ - bne a2, 1f /* if (len != 0), proceed */ - ldiq t1, 1 /* else bail */ - br zero, 2f + beq a2, 5f /* if (len == 0), bail */ 1: ldq_u t1, 0(a0) /* t1 = *from */ extbl t1, a0, t1 @@ -927,13 +925,16 @@ LEAF(alpha_copystr, 4) 2: beq a3, 3f /* if (lenp != NULL) */ subl t0, a2, t0 /* *lenp = (i - len) */ stq t0, 0(a3) -3: beq t1, 4f /* *from == '\0'; leave quietly */ +3: bne t1, 4f /* *from != '\0'; leave in a huff */ - ldiq v0, ENAMETOOLONG /* *from != '\0'; error. */ + mov zero, v0 /* return 0. */ RET -4: mov zero, v0 /* return 0. */ +4: ldiq v0, ENAMETOOLONG RET + +5: ldiq t1, 1 /* fool the test above... */ + br zero, 2b END(alpha_copystr) NESTED(copyinstr, 4, 16, ra, IM_RA|IM_S0, 0)