[DTrace-devel] [PATCH 13/14] Clean up comments and remove unneeded code in strcmp.S

Kris Van Hees kris.van.hees at oracle.com
Sat Feb 18 06:54:52 UTC 2023


On Thu, Nov 03, 2022 at 03:52:25PM -0400, eugene.loh--- via DTrace-devel wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
> 
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>

Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>

> ---
>  bpf/strcmp.S | 40 +++++++++++++---------------------------
>  1 file changed, 13 insertions(+), 27 deletions(-)
> 
> diff --git a/bpf/strcmp.S b/bpf/strcmp.S
> index 2b8f196f..cf5e48e6 100644
> --- a/bpf/strcmp.S
> +++ b/bpf/strcmp.S
> @@ -81,19 +81,19 @@ dt_strcmp_not :
>   *     // (this gives us the first byte that differs in the two strings)
>   *     dt_strcmp_xor(tmp1, tmp2, r8);
>   *     dt_strcmp_not(tmp1, r8);
> - *     r0 = bpf_probe_read_str(tmp2, r8, tmp1);
> + *     r0 = bpf_probe_read_str(tmp1, r8, tmp1);
>   *     r0 -= 1;
>   *
>   *     // based on this location, judge if the strings are >, <, or ==
>   *     if (r0 > r6) goto Lsame;
>   *     if (r0 > r7) goto Lsame;
>   *
> - *     s += r0;
> - *     t += r0;
> + *     r6 = &s[r0];
> + *     r7 = &tmp2[r0];
>   *
> - *     if (l_is_dptr) { } else { bpf_probe_read(tmp1, 1, s); s = tmp1; }
> - *     if (s[0] > t[0]) return +1;
> - *     return -1;
> + *     if (flags & 1) { } else { bpf_probe_read(tmp1, 1, r6); r6 = tmp1; }
> + *     r6 = *r6;
> + *     r7 = *r7;
>   *
>   *     // if all chars are the same, break tie on string length
>   * Lsame:
> @@ -166,38 +166,24 @@ dt_strcmp :
>  	jgt	%r0, %r7, .Lsame	/* if (r0 > r7) goto Lsame */
>  
>  	ldxdw	%r6, [%fp+-8]
> -	add	%r6, %r0		/* s += r0 */
> -	ldxdw	%r7, [%fp+-16]
> -	add	%r7, %r0		/* t += r0 */
> +	add	%r6, %r0		/* r6 = &s[r0] */
> +	ldxdw	%r7, [%fp+-32]
> +	add	%r7, %r0		/* r7 = &tmp2[r0] */
>  
>  	jset	%r9, 1, .Ls_is_dptr
>  	ldxdw	%r1, [%fp+-24]
>  	mov	%r2, 1
>  	mov	%r3, %r6
> -	mov	%r6, %r1		/* s = tmp1 (after the helper call) */
> -	call	BPF_FUNC_probe_read	/* bpf_probe_read(tmp1, 1, s) */
> +	mov	%r6, %r1		/* r6 = tmp1 (after the helper call) */
> +	call	BPF_FUNC_probe_read	/* bpf_probe_read(tmp1, 1, r6) */
>  .Ls_is_dptr:
>  
> -	jset	%r9, 2, .Lt_is_dptr
> -	ldxdw	%r1, [%fp+-32]
> -	mov	%r2, 1
> -	mov	%r3, %r7
> -	mov	%r7, %r1		/* t = tmp2 (after the helper call) */
> -	call	BPF_FUNC_probe_read	/* bpf_probe_read(tmp2, 1, t) */
> -.Lt_is_dptr:
> -
> -	ldxb	%r6, [%r6+0]		/* s[0] */
> +	ldxb	%r6, [%r6+0]		/* r6 = *r6 */
>  	and	%r6, 0xff
>  
> -	ldxb	%r7, [%r7+0]		/* t[0] */
> +	ldxb	%r7, [%r7+0]		/* r7 = *r7 */
>  	and	%r7, 0xff
>  
> -	jle	%r6, %r7, 2		/* if (s[0] > t[0]) return +1 */
> -	mov	%r0, 1
> -	exit
> -	mov	%r0, -1
> -	exit
> -
>  .Lsame:
>  	jle	%r6, %r7, 2		/* if (r6 > r7) return +1 */
>  	mov	%r0, 1
> -- 
> 2.18.4
> 
> 
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel



More information about the DTrace-devel mailing list