[DTrace-devel] [PATCH 20/61] Have dt_cg_typecast() copy results from src to dst in default case

Kris Van Hees kris.van.hees at oracle.com
Fri Jul 29 14:54:22 UTC 2022


This is almostly entirely superceded by "[PATCH 22/61] Fix typecast" so I
would prefer to simply put the src to dst move into that one, and drop this
patch.

Also (and I will mention that in review comment to "[PATCH 22/61] Fix typecast",
you should add a conditional:

	if (dst->dn_reg != src->dn_reg)
		emit(dlp, BPF_MOV_REG(dst->dn_reg, src->dn_reg));

That way, for all known uses (right now) we do not get that extra instruction,
and yet, the function is safe if at some point it is called with dst and src
nodes that are in different registers.

On Fri, Jul 08, 2022 at 10:45:04AM -0400, eugene.loh--- via DTrace-devel wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
> 
> The dt_cg_typecast() function is written as if results are being
> transfered from src to dst.  However, if src and dst types are
> compatible and no bit-filling is needed, no such src-to-dst transfer
> is performed.  In practice, this is not a problem since callers tend
> to set src and dst registers equal to one another, meaning the typecast
> operation is done in-place.
> 
> Either:
> 
> *)  add an explicit src-to-dst transfer for the "default case" (when
> src and dst types are compatible and need no bit filling), or
> 
> *)  rewrite dt_cg_typecast() to be in-register (typically eliminating
> one instruction)
> 
> Here, the first solution is used.
> 
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
> ---
>  libdtrace/dt_cg.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
> index 633e4613..f1893198 100644
> --- a/libdtrace/dt_cg.c
> +++ b/libdtrace/dt_cg.c
> @@ -2576,7 +2576,8 @@ dt_cg_typecast(const dt_node_t *src, const dt_node_t *dst,
>  		emit(dlp,  BPF_LOAD(BPF_DW, dst->dn_reg, mst, DMST_SCALARIZER));
>  
>  		dt_regset_free(drp, mst);
> -	}
> +	} else
> +		emit(dlp, BPF_MOV_REG(dst->dn_reg, src->dn_reg));
>  }
>  
>  /*
> -- 
> 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