RFR (S): 8233702: Introduce helper function to clamp value to range

Thomas Schatzl thomas.schatzl at oracle.com
Wed Nov 13 15:23:18 UTC 2019


Hi,

On 13.11.19 07:11, Kim Barrett wrote:
>> On Nov 12, 2019, at 4:17 AM, Thomas Schatzl <thomas.schatzl at oracle.com> wrote:
>>
>> Hi all,
>>
>>   I would like to introduce a small helper function to clamp a given value between a min/max value.
>> This would unclutter a few MIN(MAX(value, <min_value>), <max_value>) statements for imho better readability.
>>
>> There are two places in (non-CMS) code remaining with the above statement, because in these cases it happens that a value min > max is passed, i.e. you potentially (already) get returned unexpected values.
>> (I did remove that assert in this webrev)
> 
> I think the clamp function should be asserting min <= max.
> 
> I haven’t reviewed all of the changed uses yet, so not yet a review.
> 

   I re-added the assert, and re-checked in our CI with hs-tier1-5. For 
some reason there were some failures I thought I had fixed already. Sorry :(

Here are new webrevs:

http://cr.openjdk.java.net/~tschatzl/8233702/webrev.0_to_1/ (diff)
http://cr.openjdk.java.net/~tschatzl/8233702/webrev.1/ (full)

Thanks,
   Thomas


More information about the hotspot-dev mailing list