[DTrace-devel] [PATCH 03/14] Promote associative integer arrays to 64 bits when loaded

Kris Van Hees kris.van.hees at oracle.com
Thu May 4 03:54:56 UTC 2023


On Mon, May 01, 2023 at 11:47:11PM -0400, eugene.loh--- via DTrace-devel wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
> 
> In commit 7e9ce1eee475 ("Promote integers to 64 bits when loaded"),
> integers were promoted to 64 bits when loaded.  Associative arrays
> were on a different code path.
> 
> Add the promotion to the associative-array code path and add tests
> for different variable types.  Also, do some minor refactoring in
> dt_cg_assoc_op() in anticipation of subsequent refactoring; this
> prep work is done here to improve readability of subsequent patches.

OK on the addition of the promotion.

> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
> ---
>  libdtrace/dt_cg.c                             | 31 +++---
>  test/unittest/arithmetic/tst.cast-add-assoc.d | 97 +++++++++++++++++++
>  test/unittest/arithmetic/tst.cast-add-assoc.r | 37 +++++++
>  test/unittest/arithmetic/tst.cast-add-tvar.d  | 97 +++++++++++++++++++
>  test/unittest/arithmetic/tst.cast-add-tvar.r  | 37 +++++++
>  test/unittest/arithmetic/tst.cast-imp-assoc.d | 95 ++++++++++++++++++
>  test/unittest/arithmetic/tst.cast-imp-assoc.r | 43 ++++++++
>  test/unittest/arithmetic/tst.cast-imp-tvar.d  | 95 ++++++++++++++++++
>  test/unittest/arithmetic/tst.cast-imp-tvar.r  | 43 ++++++++
>  9 files changed, 560 insertions(+), 15 deletions(-)
>  create mode 100644 test/unittest/arithmetic/tst.cast-add-assoc.d
>  create mode 100644 test/unittest/arithmetic/tst.cast-add-assoc.r
>  create mode 100644 test/unittest/arithmetic/tst.cast-add-tvar.d
>  create mode 100644 test/unittest/arithmetic/tst.cast-add-tvar.r
>  create mode 100644 test/unittest/arithmetic/tst.cast-imp-assoc.d
>  create mode 100644 test/unittest/arithmetic/tst.cast-imp-assoc.r
>  create mode 100644 test/unittest/arithmetic/tst.cast-imp-tvar.d
>  create mode 100644 test/unittest/arithmetic/tst.cast-imp-tvar.r
> 
> diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
> index c1fd46c0..7bfc33a1 100644
> --- a/libdtrace/dt_cg.c
> +++ b/libdtrace/dt_cg.c
> @@ -3988,7 +3988,7 @@ dt_cg_asgn_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
>  }
>  
>  static void
> -dt_cg_assoc_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
> +dt_cg_assoc_op(dt_node_t *dst, dt_irlist_t *dlp, dt_regset_t *drp)

I do not really agree with this change (and the resulting changes below)...
This is a function that generates code for a node, and the convention in the
code generator is that dnp is used for that variable.  The change to 'dst'
seems to imply that this node is the destination of some operation, but then
one would expect there to be a source as well, and that is clearly not the
case.

Let's keep this as-is, please.

>  {
>  	dt_ident_t	*idp = dt_dlib_get_func(yypcb->pcb_hdl, "dt_get_assoc");
>  	uint_t		varid;
> @@ -3996,25 +3996,25 @@ dt_cg_assoc_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
>  	TRACE_REGSET("    assoc_op: Begin");
>  
>  	assert(idp != NULL);
> -	assert(dnp->dn_kind == DT_NODE_VAR);
> -	assert(!(dnp->dn_ident->di_flags & DT_IDFLG_LOCAL));
> -	assert(dnp->dn_args != NULL);
> +	assert(dst->dn_kind == DT_NODE_VAR);
> +	assert(!(dst->dn_ident->di_flags & DT_IDFLG_LOCAL));
> +	assert(dst->dn_args != NULL);
>  
> -	dnp->dn_ident->di_flags |= DT_IDFLG_DIFR;
> +	dst->dn_ident->di_flags |= DT_IDFLG_DIFR;
>  
>  	/* Get the tuple. */
> -	dt_cg_arglist(dnp->dn_ident, dnp->dn_args, dlp, drp);
> +	dt_cg_arglist(dst->dn_ident, dst->dn_args, dlp, drp);
>  
> -	if ((dnp->dn_reg = dt_regset_alloc(drp)) == -1)
> +	if ((dst->dn_reg = dt_regset_alloc(drp)) == -1)
>  		longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
>  	if (dt_regset_xalloc_args(drp) == -1)
>  		longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
>  
> -	varid = dnp->dn_ident->di_id - DIF_VAR_OTHER_UBASE;
> +	varid = dst->dn_ident->di_id - DIF_VAR_OTHER_UBASE;
>  
>  	emit(dlp,  BPF_MOV_IMM(BPF_REG_1, varid));
> -	emit(dlp,  BPF_MOV_REG(BPF_REG_2, dnp->dn_args->dn_reg));
> -	dt_regset_free(drp, dnp->dn_args->dn_reg);
> +	emit(dlp,  BPF_MOV_REG(BPF_REG_2, dst->dn_args->dn_reg));
> +	dt_regset_free(drp, dst->dn_args->dn_reg);
>  	emit(dlp,  BPF_MOV_IMM(BPF_REG_3, 0));
>  	emit(dlp,  BPF_MOV_IMM(BPF_REG_4, 0));
>  	dt_cg_zerosptr(BPF_REG_5, dlp, drp);
> @@ -4022,10 +4022,10 @@ dt_cg_assoc_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
>  	emite(dlp, BPF_CALL_FUNC(idp->di_id), idp);
>  	dt_regset_free_args(drp);
>  
> -	if (dnp->dn_flags & DT_NF_REF) {
> -		emit(dlp,  BPF_MOV_REG(dnp->dn_reg, BPF_REG_0));
> +	if (dst->dn_flags & DT_NF_REF) {
> +		emit(dlp,  BPF_MOV_REG(dst->dn_reg, BPF_REG_0));
>  	} else {
> -		size_t	size = dt_node_type_size(dnp);
> +		size_t	size = dt_node_type_size(dst);
>  		uint_t	lbl_notnull = dt_irlist_label(dlp);
>  		uint_t	lbl_done = dt_irlist_label(dlp);
>  
> @@ -4033,10 +4033,11 @@ dt_cg_assoc_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
>  		       (size & (size - 1)) == 0);
>  
>  		emit(dlp,  BPF_BRANCH_IMM(BPF_JNE, BPF_REG_0, 0, lbl_notnull));
> -		emit(dlp,  BPF_MOV_IMM(dnp->dn_reg, 0));
> +		emit(dlp,  BPF_MOV_IMM(dst->dn_reg, 0));
>  		emit(dlp,  BPF_JUMP(lbl_done));
>  		emitl(dlp, lbl_notnull,
> -			   BPF_LOAD(ldstw[size], dnp->dn_reg, BPF_REG_0, 0));
> +			   BPF_LOAD(ldstw[size], dst->dn_reg, BPF_REG_0, 0));
> +		dt_cg_promote(dst, size, dlp, drp);

Good catch.

>  		emitl(dlp, lbl_done,
>  			   BPF_NOP());
>  	}
> diff --git a/test/unittest/arithmetic/tst.cast-add-assoc.d b/test/unittest/arithmetic/tst.cast-add-assoc.d
> new file mode 100644
> index 00000000..494099cf
> --- /dev/null
> +++ b/test/unittest/arithmetic/tst.cast-add-assoc.d
> @@ -0,0 +1,97 @@
> +/*
> + * Oracle Linux DTrace.
> + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
> + * Licensed under the Universal Permissive License v 1.0 as shown at
> + * http://oss.oracle.com/licenses/upl.
> + */
> +
> +/*
> + * ASSERTION:  Integers are promoted correctly for mixed-type adds
> + *	       using associative arrays.
> + *
> + * SECTION: Types, Operators, and Expressions/Arithmetic Operators
> + */
> +/* @@runtest-opts: -qC */
> +
> +signed char c[int];
> +short s[int];
> +int i[int];
> +long long l[int];
> +unsigned char C[int];
> +unsigned short S[int];
> +unsigned int I[int];
> +unsigned long long L[int];
> +
> +#define FMT " %d"
> +#define USE_FMT(f)
> +
> +#define TEST(x, y) \
> +  x[0] = -2; y[0] = -3; printf(FMT, x[0] + y[0]); printf(FMT, y[0] + x[0]); \
> +  x[0] = -2; y[0] = +3; printf(FMT, x[0] + y[0]); printf(FMT, y[0] + x[0]); \
> +  x[0] = +2; y[0] = -3; printf(FMT, x[0] + y[0]); printf(FMT, y[0] + x[0]); \
> +  x[0] = +2; y[0] = +3; printf(FMT, x[0] + y[0]); printf(FMT, y[0] + x[0]); printf("\n");
> +
> +BEGIN
> +{
> +	/* cast to signed char */
> +	USE_FMT(" %hhd");
> +	TEST(c, c)
> +
> +	/* cast to unsigned char */
> +	USE_FMT(" %hhu");
> +	TEST(C, c)
> +	TEST(C, C)
> +
> +	/* cast to short */
> +	USE_FMT(" %hd");
> +	TEST(s, c)
> +	TEST(s, C)
> +	TEST(s, s)
> +
> +	/* cast to unsigned short */
> +	USE_FMT(" %hu");
> +	TEST(S, c)
> +	TEST(S, C)
> +	TEST(S, s)
> +	TEST(S, S)
> +
> +	/* cast to int */
> +	USE_FMT(" %d");
> +	TEST(i, c)
> +	TEST(i, C)
> +	TEST(i, s)
> +	TEST(i, S)
> +	TEST(i, i)
> +
> +	/* cast to unsigned int */
> +	USE_FMT(" %u");
> +	TEST(I, c)
> +	TEST(I, C)
> +	TEST(I, s)
> +	TEST(I, S)
> +	TEST(I, i)
> +	TEST(I, I)
> +
> +	/* cast to long long */
> +	USE_FMT(" %lld");
> +	TEST(l, c)
> +	TEST(l, C)
> +	TEST(l, s)
> +	TEST(l, S)
> +	TEST(l, i)
> +	TEST(l, I)
> +	TEST(l, l)
> +
> +	/* cast to unsigned long long */
> +	USE_FMT(" %llu");
> +	TEST(L, c)
> +	TEST(L, C)
> +	TEST(L, s)
> +	TEST(L, S)
> +	TEST(L, i)
> +	TEST(L, I)
> +	TEST(L, l)
> +	TEST(L, L)
> +
> +	exit (0);
> +}
> diff --git a/test/unittest/arithmetic/tst.cast-add-assoc.r b/test/unittest/arithmetic/tst.cast-add-assoc.r
> new file mode 100644
> index 00000000..778b88e0
> --- /dev/null
> +++ b/test/unittest/arithmetic/tst.cast-add-assoc.r
> @@ -0,0 +1,37 @@
> + -6 -6 6 6 -6 -6 6 6
> + 251 251 1 1 255 255 5 5
> + 250 250 6 6 250 250 6 6
> + -5 -5 1 1 -1 -1 5 5
> + 251 251 1 1 255 255 5 5
> + -6 -6 6 6 -6 -6 6 6
> + 65531 65531 1 1 65535 65535 5 5
> + 251 251 1 1 255 255 5 5
> + 65531 65531 1 1 65535 65535 5 5
> + 65530 65530 6 6 65530 65530 6 6
> + -5 -5 1 1 -1 -1 5 5
> + 251 251 1 1 255 255 5 5
> + -5 -5 1 1 -1 -1 5 5
> + 65531 65531 1 1 65535 65535 5 5
> + -6 -6 6 6 -6 -6 6 6
> + 4294967291 4294967291 1 1 4294967295 4294967295 5 5
> + 251 251 1 1 255 255 5 5
> + 4294967291 4294967291 1 1 4294967295 4294967295 5 5
> + 65531 65531 1 1 65535 65535 5 5
> + 4294967291 4294967291 1 1 4294967295 4294967295 5 5
> + 4294967290 4294967290 6 6 4294967290 4294967290 6 6
> + -5 -5 1 1 -1 -1 5 5
> + 251 251 1 1 255 255 5 5
> + -5 -5 1 1 -1 -1 5 5
> + 65531 65531 1 1 65535 65535 5 5
> + -5 -5 1 1 -1 -1 5 5
> + 4294967291 4294967291 1 1 4294967295 4294967295 5 5
> + -6 -6 6 6 -6 -6 6 6
> + 18446744073709551611 18446744073709551611 1 1 18446744073709551615 18446744073709551615 5 5
> + 251 251 1 1 255 255 5 5
> + 18446744073709551611 18446744073709551611 1 1 18446744073709551615 18446744073709551615 5 5
> + 65531 65531 1 1 65535 65535 5 5
> + 18446744073709551611 18446744073709551611 1 1 18446744073709551615 18446744073709551615 5 5
> + 4294967291 4294967291 1 1 4294967295 4294967295 5 5
> + 18446744073709551611 18446744073709551611 1 1 18446744073709551615 18446744073709551615 5 5
> + 18446744073709551610 18446744073709551610 6 6 18446744073709551610 18446744073709551610 6 6
> +
> diff --git a/test/unittest/arithmetic/tst.cast-add-tvar.d b/test/unittest/arithmetic/tst.cast-add-tvar.d
> new file mode 100644
> index 00000000..d79bc60f
> --- /dev/null
> +++ b/test/unittest/arithmetic/tst.cast-add-tvar.d
> @@ -0,0 +1,97 @@
> +/*
> + * Oracle Linux DTrace.
> + * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
> + * Licensed under the Universal Permissive License v 1.0 as shown at
> + * http://oss.oracle.com/licenses/upl.
> + */
> +
> +/*
> + * ASSERTION:  Integers are promoted correctly for mixed-type adds
> + *	       when using thread-local variables.
> + *
> + * SECTION: Types, Operators, and Expressions/Arithmetic Operators
> + */
> +/* @@runtest-opts: -qC */
> +
> +self signed char c;
> +self short s;
> +self int i;
> +self long long l;
> +self unsigned char C;
> +self unsigned short S;
> +self unsigned int I;
> +self unsigned long long L;
> +
> +#define FMT " %d"
> +#define USE_FMT(f)
> +
> +#define TEST(x, y) \
> +  self->x = -2; self->y = -3; printf(FMT, self->x + self->y); printf(FMT, self->y + self->x); \
> +  self->x = -2; self->y = +3; printf(FMT, self->x + self->y); printf(FMT, self->y + self->x); \
> +  self->x = +2; self->y = -3; printf(FMT, self->x + self->y); printf(FMT, self->y + self->x); \
> +  self->x = +2; self->y = +3; printf(FMT, self->x + self->y); printf(FMT, self->y + self->x); printf("\n");
> +
> +BEGIN
> +{
> +	/* cast to signed char */
> +	USE_FMT(" %hhd");
> +	TEST(c, c)
> +
> +	/* cast to unsigned char */
> +	USE_FMT(" %hhu");
> +	TEST(C, c)
> +	TEST(C, C)
> +
> +	/* cast to short */
> +	USE_FMT(" %hd");
> +	TEST(s, c)
> +	TEST(s, C)
> +	TEST(s, s)
> +
> +	/* cast to unsigned short */
> +	USE_FMT(" %hu");
> +	TEST(S, c)
> +	TEST(S, C)
> +	TEST(S, s)
> +	TEST(S, S)
> +
> +	/* cast to int */
> +	USE_FMT(" %d");
> +	TEST(i, c)
> +	TEST(i, C)
> +	TEST(i, s)
> +	TEST(i, S)
> +	TEST(i, i)
> +
> +	/* cast to unsigned int */
> +	USE_FMT(" %u");
> +	TEST(I, c)
> +	TEST(I, C)
> +	TEST(I, s)
> +	TEST(I, S)
> +	TEST(I, i)
> +	TEST(I, I)
> +
> +	/* cast to long long */
> +	USE_FMT(" %lld");
> +	TEST(l, c)
> +	TEST(l, C)
> +	TEST(l, s)
> +	TEST(l, S)
> +	TEST(l, i)
> +	TEST(l, I)
> +	TEST(l, l)
> +
> +	/* cast to unsigned long long */
> +	USE_FMT(" %llu");
> +	TEST(L, c)
> +	TEST(L, C)
> +	TEST(L, s)
> +	TEST(L, S)
> +	TEST(L, i)
> +	TEST(L, I)
> +	TEST(L, l)
> +	TEST(L, L)
> +
> +	exit (0);
> +}
> diff --git a/test/unittest/arithmetic/tst.cast-add-tvar.r b/test/unittest/arithmetic/tst.cast-add-tvar.r
> new file mode 100644
> index 00000000..778b88e0
> --- /dev/null
> +++ b/test/unittest/arithmetic/tst.cast-add-tvar.r
> @@ -0,0 +1,37 @@
> + -6 -6 6 6 -6 -6 6 6
> + 251 251 1 1 255 255 5 5
> + 250 250 6 6 250 250 6 6
> + -5 -5 1 1 -1 -1 5 5
> + 251 251 1 1 255 255 5 5
> + -6 -6 6 6 -6 -6 6 6
> + 65531 65531 1 1 65535 65535 5 5
> + 251 251 1 1 255 255 5 5
> + 65531 65531 1 1 65535 65535 5 5
> + 65530 65530 6 6 65530 65530 6 6
> + -5 -5 1 1 -1 -1 5 5
> + 251 251 1 1 255 255 5 5
> + -5 -5 1 1 -1 -1 5 5
> + 65531 65531 1 1 65535 65535 5 5
> + -6 -6 6 6 -6 -6 6 6
> + 4294967291 4294967291 1 1 4294967295 4294967295 5 5
> + 251 251 1 1 255 255 5 5
> + 4294967291 4294967291 1 1 4294967295 4294967295 5 5
> + 65531 65531 1 1 65535 65535 5 5
> + 4294967291 4294967291 1 1 4294967295 4294967295 5 5
> + 4294967290 4294967290 6 6 4294967290 4294967290 6 6
> + -5 -5 1 1 -1 -1 5 5
> + 251 251 1 1 255 255 5 5
> + -5 -5 1 1 -1 -1 5 5
> + 65531 65531 1 1 65535 65535 5 5
> + -5 -5 1 1 -1 -1 5 5
> + 4294967291 4294967291 1 1 4294967295 4294967295 5 5
> + -6 -6 6 6 -6 -6 6 6
> + 18446744073709551611 18446744073709551611 1 1 18446744073709551615 18446744073709551615 5 5
> + 251 251 1 1 255 255 5 5
> + 18446744073709551611 18446744073709551611 1 1 18446744073709551615 18446744073709551615 5 5
> + 65531 65531 1 1 65535 65535 5 5
> + 18446744073709551611 18446744073709551611 1 1 18446744073709551615 18446744073709551615 5 5
> + 4294967291 4294967291 1 1 4294967295 4294967295 5 5
> + 18446744073709551611 18446744073709551611 1 1 18446744073709551615 18446744073709551615 5 5
> + 18446744073709551610 18446744073709551610 6 6 18446744073709551610 18446744073709551610 6 6
> +
> diff --git a/test/unittest/arithmetic/tst.cast-imp-assoc.d b/test/unittest/arithmetic/tst.cast-imp-assoc.d
> new file mode 100644
> index 00000000..8b0cc24f
> --- /dev/null
> +++ b/test/unittest/arithmetic/tst.cast-imp-assoc.d
> @@ -0,0 +1,95 @@
> +/*
> + * Oracle Linux DTrace.
> + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
> + * Licensed under the Universal Permissive License v 1.0 as shown at
> + * http://oss.oracle.com/licenses/upl.
> + */
> +
> +/*
> + * ASSERTION:  Integers are typecast correctly (implicit)
> + *	       when using associative arrays.
> + *
> + * SECTION: Types, Operators, and Expressions/Arithmetic Operators
> + */
> +/* @@runtest-opts: -qC */
> +
> +signed char c[int], c0[int];
> +short s[int], s0[int];
> +int i[int], i0[int];
> +long long l[int], l0[int];
> +unsigned char C[int], C0[int];
> +unsigned short S[int], S0[int];
> +unsigned int I[int], I0[int];
> +unsigned long long L[int], L0[int];
> +
> +#define FMT "%d %d %d %d %d %d %d %d\n"
> +
> +#define TEST(x) \
> +	c[0] = (x); s[0] = (x); i[0] = (x); l[0] = (x); \
> +	C[0] = (x); S[0] = (x); I[0] = (x); L[0] = (x); \
> +	printf(FMT, c[0], s[0], i[0], l[0], C[0], S[0], I[0], L[0])
> +
> +BEGIN
> +{
> +	/* from scalar */
> +	TEST(-2);
> +	TEST(0xfffffffffffffffe);
> +	TEST(0xfffffffe);
> +	TEST(0xfffe);
> +	TEST(0xfe);
> +	TEST(2);
> +	TEST(0x55);
> +	TEST(0x5555);
> +	TEST(0x55555555);
> +	TEST(0x5555555555555555);
> +
> +	/* from signed char */
> +	c0[0] = -2; TEST(c0[0]);
> +	c0[0] = 0xfe; TEST(c0[0]);
> +	c0[0] = 2; TEST(c0[0]);
> +	c0[0] = 0x55; TEST(c0[0]);
> +
> +	/* from short */
> +	s0[0] = -2; TEST(s0[0]);
> +	s0[0] = 0xfffe; TEST(s0[0]);
> +	s0[0] = 2; TEST(s0[0]);
> +	s0[0] = 0x5555; TEST(s0[0]);
> +
> +	/* from int */
> +	i0[0] = -2; TEST(i0[0]);
> +	i0[0] = 0xfffffffe; TEST(i0[0]);
> +	i0[0] = 2; TEST(i0[0]);
> +	i0[0] = 0x55555555; TEST(i0[0]);
> +
> +	/* from long long */
> +	l0[0] = -2; TEST(l0[0]);
> +	l0[0] = 0xfffffffffffffffe; TEST(l0[0]);
> +	l0[0] = 2; TEST(l0[0]);
> +	l0[0] = 0x5555555555555555; TEST(l0[0]);
> +
> +	/* from unsigned char */
> +	C0[0] = -2; TEST(C0[0]);
> +	C0[0] = 0xfe; TEST(C0[0]);
> +	C0[0] = 2; TEST(C0[0]);
> +	C0[0] = 0x55; TEST(C0[0]);
> +
> +	/* from unsigned short */
> +	S0[0] = -2; TEST(S0[0]);
> +	S0[0] = 0xfffe; TEST(S0[0]);
> +	S0[0] = 2; TEST(S0[0]);
> +	S0[0] = 0x5555; TEST(S0[0]);
> +
> +	/* from unsigned int */
> +	I0[0] = -2; TEST(I0[0]);
> +	I0[0] = 0xfffffffe; TEST(I0[0]);
> +	I0[0] = 2; TEST(I0[0]);
> +	I0[0] = 0x55555555; TEST(I0[0]);
> +
> +	/* from unsigned long long */
> +	L0[0] = -2; TEST(L0[0]);
> +	L0[0] = 0xfffffffffffffffe; TEST(L0[0]);
> +	L0[0] = 2; TEST(L0[0]);
> +	L0[0] = 0x5555555555555555; TEST(L0[0]);
> +
> +	exit (0);
> +}
> diff --git a/test/unittest/arithmetic/tst.cast-imp-assoc.r b/test/unittest/arithmetic/tst.cast-imp-assoc.r
> new file mode 100644
> index 00000000..0ae3e3f1
> --- /dev/null
> +++ b/test/unittest/arithmetic/tst.cast-imp-assoc.r
> @@ -0,0 +1,43 @@
> +-2 -2 -2 -2 254 65534 4294967294 18446744073709551614
> +-2 -2 -2 -2 254 65534 4294967294 18446744073709551614
> +-2 -2 -2 4294967294 254 65534 4294967294 4294967294
> +-2 -2 65534 65534 254 65534 65534 65534
> +-2 254 254 254 254 254 254 254
> +2 2 2 2 2 2 2 2
> +85 85 85 85 85 85 85 85
> +85 21845 21845 21845 85 21845 21845 21845
> +85 21845 1431655765 1431655765 85 21845 1431655765 1431655765
> +85 21845 1431655765 6148914691236517205 85 21845 1431655765 6148914691236517205
> +-2 -2 -2 -2 254 65534 4294967294 18446744073709551614
> +-2 -2 -2 -2 254 65534 4294967294 18446744073709551614
> +2 2 2 2 2 2 2 2
> +85 85 85 85 85 85 85 85
> +-2 -2 -2 -2 254 65534 4294967294 18446744073709551614
> +-2 -2 -2 -2 254 65534 4294967294 18446744073709551614
> +2 2 2 2 2 2 2 2
> +85 21845 21845 21845 85 21845 21845 21845
> +-2 -2 -2 -2 254 65534 4294967294 18446744073709551614
> +-2 -2 -2 -2 254 65534 4294967294 18446744073709551614
> +2 2 2 2 2 2 2 2
> +85 21845 1431655765 1431655765 85 21845 1431655765 1431655765
> +-2 -2 -2 -2 254 65534 4294967294 18446744073709551614
> +-2 -2 -2 -2 254 65534 4294967294 18446744073709551614
> +2 2 2 2 2 2 2 2
> +85 21845 1431655765 6148914691236517205 85 21845 1431655765 6148914691236517205
> +-2 254 254 254 254 254 254 254
> +-2 254 254 254 254 254 254 254
> +2 2 2 2 2 2 2 2
> +85 85 85 85 85 85 85 85
> +-2 -2 65534 65534 254 65534 65534 65534
> +-2 -2 65534 65534 254 65534 65534 65534
> +2 2 2 2 2 2 2 2
> +85 21845 21845 21845 85 21845 21845 21845
> +-2 -2 -2 4294967294 254 65534 4294967294 4294967294
> +-2 -2 -2 4294967294 254 65534 4294967294 4294967294
> +2 2 2 2 2 2 2 2
> +85 21845 1431655765 1431655765 85 21845 1431655765 1431655765
> +-2 -2 -2 -2 254 65534 4294967294 18446744073709551614
> +-2 -2 -2 -2 254 65534 4294967294 18446744073709551614
> +2 2 2 2 2 2 2 2
> +85 21845 1431655765 6148914691236517205 85 21845 1431655765 6148914691236517205
> +
> diff --git a/test/unittest/arithmetic/tst.cast-imp-tvar.d b/test/unittest/arithmetic/tst.cast-imp-tvar.d
> new file mode 100644
> index 00000000..e16f2e02
> --- /dev/null
> +++ b/test/unittest/arithmetic/tst.cast-imp-tvar.d
> @@ -0,0 +1,95 @@
> +/*
> + * Oracle Linux DTrace.
> + * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
> + * Licensed under the Universal Permissive License v 1.0 as shown at
> + * http://oss.oracle.com/licenses/upl.
> + */
> +
> +/*
> + * ASSERTION:  Integers are typecast correctly (implicit)
> + *	       when using thread-local variables.
> + *
> + * SECTION: Types, Operators, and Expressions/Arithmetic Operators
> + */
> +/* @@runtest-opts: -qC -DUSE_AS_D_SCRIPT */
> +
> +self signed char c, c0;
> +self short s, s0;
> +self int i, i0;
> +self long long l, l0;
> +self unsigned char C, C0;
> +self unsigned short S, S0;
> +self unsigned int I, I0;
> +self unsigned long long L, L0;
> +
> +#define FMT "%d %d %d %d %d %d %d %d\n"
> +
> +#define TEST(x) \
> +	self->c = (x); self->s = (x); self->i = (x); self->l = (x); \
> +	self->C = (x); self->S = (x); self->I = (x); self->L = (x); \
> +	printf(FMT, self->c, self->s, self->i, self->l, self->C, self->S, self->I, self->L)
> +
> +BEGIN
> +{
> +	/* from scalar */
> +	TEST(-2);
> +	TEST(0xfffffffffffffffe);
> +	TEST(0xfffffffe);
> +	TEST(0xfffe);
> +	TEST(0xfe);
> +	TEST(2);
> +	TEST(0x55);
> +	TEST(0x5555);
> +	TEST(0x55555555);
> +	TEST(0x5555555555555555);
> +
> +	/* from signed char */
> +	self->c0 = -2; TEST(self->c0);
> +	self->c0 = 0xfe; TEST(self->c0);
> +	self->c0 = 2; TEST(self->c0);
> +	self->c0 = 0x55; TEST(self->c0);
> +
> +	/* from short */
> +	self->s0 = -2; TEST(self->s0);
> +	self->s0 = 0xfffe; TEST(self->s0);
> +	self->s0 = 2; TEST(self->s0);
> +	self->s0 = 0x5555; TEST(self->s0);
> +
> +	/* from int */
> +	self->i0 = -2; TEST(self->i0);
> +	self->i0 = 0xfffffffe; TEST(self->i0);
> +	self->i0 = 2; TEST(self->i0);
> +	self->i0 = 0x55555555; TEST(self->i0);
> +
> +	/* from long long */
> +	self->l0 = -2; TEST(self->l0);
> +	self->l0 = 0xfffffffffffffffe; TEST(self->l0);
> +	self->l0 = 2; TEST(self->l0);
> +	self->l0 = 0x5555555555555555; TEST(self->l0);
> +
> +	/* from unsigned char */
> +	self->C0 = -2; TEST(self->C0);
> +	self->C0 = 0xfe; TEST(self->C0);
> +	self->C0 = 2; TEST(self->C0);
> +	self->C0 = 0x55; TEST(self->C0);
> +
> +	/* from unsigned short */
> +	self->S0 = -2; TEST(self->S0);
> +	self->S0 = 0xfffe; TEST(self->S0);
> +	self->S0 = 2; TEST(self->S0);
> +	self->S0 = 0x5555; TEST(self->S0);
> +
> +	/* from unsigned int */
> +	self->I0 = -2; TEST(self->I0);
> +	self->I0 = 0xfffffffe; TEST(self->I0);
> +	self->I0 = 2; TEST(self->I0);
> +	self->I0 = 0x55555555; TEST(self->I0);
> +
> +	/* from unsigned long long */
> +	self->L0 = -2; TEST(self->L0);
> +	self->L0 = 0xfffffffffffffffe; TEST(self->L0);
> +	self->L0 = 2; TEST(self->L0);
> +	self->L0 = 0x5555555555555555; TEST(self->L0);
> +
> +	exit (0);
> +}
> diff --git a/test/unittest/arithmetic/tst.cast-imp-tvar.r b/test/unittest/arithmetic/tst.cast-imp-tvar.r
> new file mode 100644
> index 00000000..0ae3e3f1
> --- /dev/null
> +++ b/test/unittest/arithmetic/tst.cast-imp-tvar.r
> @@ -0,0 +1,43 @@
> +-2 -2 -2 -2 254 65534 4294967294 18446744073709551614
> +-2 -2 -2 -2 254 65534 4294967294 18446744073709551614
> +-2 -2 -2 4294967294 254 65534 4294967294 4294967294
> +-2 -2 65534 65534 254 65534 65534 65534
> +-2 254 254 254 254 254 254 254
> +2 2 2 2 2 2 2 2
> +85 85 85 85 85 85 85 85
> +85 21845 21845 21845 85 21845 21845 21845
> +85 21845 1431655765 1431655765 85 21845 1431655765 1431655765
> +85 21845 1431655765 6148914691236517205 85 21845 1431655765 6148914691236517205
> +-2 -2 -2 -2 254 65534 4294967294 18446744073709551614
> +-2 -2 -2 -2 254 65534 4294967294 18446744073709551614
> +2 2 2 2 2 2 2 2
> +85 85 85 85 85 85 85 85
> +-2 -2 -2 -2 254 65534 4294967294 18446744073709551614
> +-2 -2 -2 -2 254 65534 4294967294 18446744073709551614
> +2 2 2 2 2 2 2 2
> +85 21845 21845 21845 85 21845 21845 21845
> +-2 -2 -2 -2 254 65534 4294967294 18446744073709551614
> +-2 -2 -2 -2 254 65534 4294967294 18446744073709551614
> +2 2 2 2 2 2 2 2
> +85 21845 1431655765 1431655765 85 21845 1431655765 1431655765
> +-2 -2 -2 -2 254 65534 4294967294 18446744073709551614
> +-2 -2 -2 -2 254 65534 4294967294 18446744073709551614
> +2 2 2 2 2 2 2 2
> +85 21845 1431655765 6148914691236517205 85 21845 1431655765 6148914691236517205
> +-2 254 254 254 254 254 254 254
> +-2 254 254 254 254 254 254 254
> +2 2 2 2 2 2 2 2
> +85 85 85 85 85 85 85 85
> +-2 -2 65534 65534 254 65534 65534 65534
> +-2 -2 65534 65534 254 65534 65534 65534
> +2 2 2 2 2 2 2 2
> +85 21845 21845 21845 85 21845 21845 21845
> +-2 -2 -2 4294967294 254 65534 4294967294 4294967294
> +-2 -2 -2 4294967294 254 65534 4294967294 4294967294
> +2 2 2 2 2 2 2 2
> +85 21845 1431655765 1431655765 85 21845 1431655765 1431655765
> +-2 -2 -2 -2 254 65534 4294967294 18446744073709551614
> +-2 -2 -2 -2 254 65534 4294967294 18446744073709551614
> +2 2 2 2 2 2 2 2
> +85 21845 1431655765 6148914691236517205 85 21845 1431655765 6148914691236517205
> +
> -- 
> 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