[DTrace-devel] [PATCH 23/61] test: Need wider variables to hold 1<<63

Kris Van Hees kris.van.hees at oracle.com
Mon Aug 1 19:56:39 UTC 2022


On Fri, Jul 08, 2022 at 10:45:07AM -0400, eugene.loh--- via DTrace-devel wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
> 
> DTrace has some peculiar -- arguably incorrect -- semantics for
> integer types dating back to Solaris.  Consider 1<<63.  Normal C
> rules would say this is a 4-byte int whose value is 0.  The DTrace
> parser, however, treats it as the 8-byte integer 0x8000000000000000.
> Subsequently, D uses the 8-byte value when assigning to an 8-byte
> variable.  E.g.,
>     long long x;
>     x = 1 << 63;
> stores 1<<63.  Nevertheless, D treat 1<<63 as a 4-byte expression.
> E.g.,
>     x = 1 << 63;
>     trace(1 << 63);
> will use a default 4-byte int for x and trace a 4-byte value of 0.
> 
> The tests addressed by this patch expect 8-byte increments but
> use default-width int this->val variables.  There is no way a
> 4-byte int could produce a, say, 9223372036854775801 increment.
> 
> Declare this->val to be 8 bytes and properly set it to the intended
> values.
> 
> The tests will still XFAIL, since support for aggregation keys
> is missing.
> 
> The D semantics should perhaps be examined further, but this
> patch at least fixes these particular tests.
> 
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>

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

... but this would have been more appropriately included *after* indexed
    aggregations were implemented.
... this also seems to demonstrate that when aggregations were implemented,
    these tests should have been modified to not need indexed aggragations,
    or at a minimum, versions should have been added that do not depend on
    indexed aggregations.
... but ...

... queued for dev

> sq Need wider variables

I assume this is not meant to be here.

> ---
>  test/unittest/aggs/tst.neglquant.d | 36 ++++++++++++++++--------------
>  test/unittest/aggs/tst.negquant.d  | 24 +++++++++++---------
>  2 files changed, 32 insertions(+), 28 deletions(-)
> 
> diff --git a/test/unittest/aggs/tst.neglquant.d b/test/unittest/aggs/tst.neglquant.d
> index f67dd842..6629438b 100644
> --- a/test/unittest/aggs/tst.neglquant.d
> +++ b/test/unittest/aggs/tst.neglquant.d
> @@ -1,6 +1,6 @@
>  /*
>   * Oracle Linux DTrace.
> - * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
> + * Copyright (c) 2006, 2022, 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.
>   */
> @@ -45,38 +45,40 @@ BEGIN
>  	@["n-judah"] = lquantize(2, 0, 10, 1);
>  }
>  
> +this long long val;
> +
>  BEGIN
>  {
>  	this->i = 1;
> -	this->val = (1 << 63) - 1;
> +	this->val = (((long long) 1) << 63) - 1;
>  
>  	@["f-market"] = lquantize(this->i, 0, 10, 1, this->val);
>  	this->i++;
> -	this->val = ((1 << 63) - 1) / this->i;
> +	this->val = ((((long long) 1) << 63) - 1) / this->i;
>  
>  	@["f-market"] = lquantize(this->i, 0, 10, 1, this->val);
>  	this->i++;
> -	this->val = ((1 << 63) - 1) / this->i;
> +	this->val = ((((long long) 1) << 63) - 1) / this->i;
>  
>  	@["f-market"] = lquantize(this->i, 0, 10, 1, this->val);
>  	this->i++;
> -	this->val = ((1 << 63) - 1) / this->i;
> +	this->val = ((((long long) 1) << 63) - 1) / this->i;
>  
>  	@["f-market"] = lquantize(this->i, 0, 10, 1, this->val);
>  	this->i++;
> -	this->val = ((1 << 63) - 1) / this->i;
> +	this->val = ((((long long) 1) << 63) - 1) / this->i;
>  
>  	@["f-market"] = lquantize(this->i, 0, 10, 1, this->val);
>  	this->i++;
> -	this->val = ((1 << 63) - 1) / this->i;
> +	this->val = ((((long long) 1) << 63) - 1) / this->i;
>  
>  	@["f-market"] = lquantize(this->i, 0, 10, 1, this->val);
>  	this->i++;
> -	this->val = ((1 << 63) - 1) / this->i;
> +	this->val = ((((long long) 1) << 63) - 1) / this->i;
>  
>  	@["f-market"] = lquantize(this->i, 0, 10, 1, this->val);
>  	this->i++;
> -	this->val = ((1 << 63) - 1) / this->i;
> +	this->val = ((((long long) 1) << 63) - 1) / this->i;
>  }
>  
>  BEGIN
> @@ -93,35 +95,35 @@ BEGIN
>  	 * this robustness on new ISAs very much depends on the precision
>  	 * of the long double representation.
>  	 */
> -	this->val = (1 << 63) - 7;
> +	this->val = (((long long) 1) << 63) - 7;
>  
>  	@["s-castro"] = lquantize(this->i, 0, 10, 1, this->val);
>  	this->i++;
> -	this->val = ((1 << 63) - 1) / this->i;
> +	this->val = ((((long long) 1) << 63) - 1) / this->i;
>  
>  	@["s-castro"] = lquantize(this->i, 0, 10, 1, this->val);
>  	this->i++;
> -	this->val = ((1 << 63) - 1) / this->i;
> +	this->val = ((((long long) 1) << 63) - 1) / this->i;
>  
>  	@["s-castro"] = lquantize(this->i, 0, 10, 1, this->val);
>  	this->i++;
> -	this->val = ((1 << 63) - 1) / this->i;
> +	this->val = ((((long long) 1) << 63) - 1) / this->i;
>  
>  	@["s-castro"] = lquantize(this->i, 0, 10, 1, this->val);
>  	this->i++;
> -	this->val = ((1 << 63) - 1) / this->i;
> +	this->val = ((((long long) 1) << 63) - 1) / this->i;
>  
>  	@["s-castro"] = lquantize(this->i, 0, 10, 1, this->val);
>  	this->i++;
> -	this->val = ((1 << 63) - 1) / this->i;
> +	this->val = ((((long long) 1) << 63) - 1) / this->i;
>  
>  	@["s-castro"] = lquantize(this->i, 0, 10, 1, this->val);
>  	this->i++;
> -	this->val = ((1 << 63) - 1) / this->i;
> +	this->val = ((((long long) 1) << 63) - 1) / this->i;
>  
>  	@["s-castro"] = lquantize(this->i, 0, 10, 1, this->val);
>  	this->i++;
> -	this->val = ((1 << 63) - 1) / this->i;
> +	this->val = ((((long long) 1) << 63) - 1) / this->i;
>  }
>  
>  BEGIN
> diff --git a/test/unittest/aggs/tst.negquant.d b/test/unittest/aggs/tst.negquant.d
> index 5a0268d1..78fa96ba 100644
> --- a/test/unittest/aggs/tst.negquant.d
> +++ b/test/unittest/aggs/tst.negquant.d
> @@ -1,6 +1,6 @@
>  /*
>   * Oracle Linux DTrace.
> - * Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
> + * Copyright (c) 2006, 2022, 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.
>   */
> @@ -45,48 +45,50 @@ BEGIN
>  	@["n-judah"] = quantize(2);
>  }
>  
> +this long long val;
> +
>  BEGIN
>  {
>  	this->i = 1;
> -	this->val = (1 << 63) - 1;
> +	this->val = (((long long) 1) << 63) - 1;
>  
>  	@["f-market"] = quantize(this->i, this->val);
>  	this->i <<= 1;
> -	this->val >>= 1;
> +	this->val >>= ((long long) 1);
>  
>  	@["f-market"] = quantize(this->i, this->val);
>  	this->i <<= 1;
> -	this->val >>= 1;
> +	this->val >>= ((long long) 1);
>  
>  	@["f-market"] = quantize(this->i, this->val);
>  	this->i <<= 1;
> -	this->val >>= 1;
> +	this->val >>= ((long long) 1);
>  
>  	@["f-market"] = quantize(this->i, this->val);
>  	this->i <<= 1;
> -	this->val >>= 1;
> +	this->val >>= ((long long) 1);
>  }
>  
>  BEGIN
>  {
>  	this->i = 1;
> -	this->val = (1 << 63) - 4;
> +	this->val = (((long long) 1) << 63) - 4;
>  
>  	@["s-castro"] = quantize(this->i, this->val);
>  	this->i <<= 1;
> -	this->val >>= 1;
> +	this->val >>= ((long long) 1);
>  
>  	@["s-castro"] = quantize(this->i, this->val);
>  	this->i <<= 1;
> -	this->val >>= 1;
> +	this->val >>= ((long long) 1);
>  
>  	@["s-castro"] = quantize(this->i, this->val);
>  	this->i <<= 1;
> -	this->val >>= 1;
> +	this->val >>= ((long long) 1);
>  
>  	@["s-castro"] = quantize(this->i, this->val);
>  	this->i <<= 1;
> -	this->val >>= 1;
> +	this->val >>= ((long long) 1);
>  }
>  
>  BEGIN
> -- 
> 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