Re: RFR: 8301226: Add clamp() methods to java.lang.Math and to StrictMath [v4]

2023-02-07 Thread Tagir F . Valeev
On Tue, 7 Feb 2023 00:57:54 GMT, Joe Darcy wrote: >> Tagir F. Valeev has updated the pull request incrementally with one >> additional commit since the last revision: >> >> Added explanatory comments > > src/java.base/share/classes/java/lang/Math.java line 2266: > >> 2264: // If min

Re: RFR: 8301226: Add clamp() methods to java.lang.Math and to StrictMath [v4]

2023-02-06 Thread Joe Darcy
On Mon, 6 Feb 2023 09:46:15 GMT, Tagir F. Valeev wrote: >> clamp() methods added to Math and StrictMath >> >> `int clamp(long, int, int)` is somewhat different, as it accepts a `long` >> value and safely clamps it to an `int` range. Other overloads work with a >> particular type (long, float a

Re: RFR: 8301226: Add clamp() methods to java.lang.Math and to StrictMath [v4]

2023-02-06 Thread Joe Darcy
On Mon, 6 Feb 2023 09:46:15 GMT, Tagir F. Valeev wrote: >> clamp() methods added to Math and StrictMath >> >> `int clamp(long, int, int)` is somewhat different, as it accepts a `long` >> value and safely clamps it to an `int` range. Other overloads work with a >> particular type (long, float a

Re: RFR: 8301226: Add clamp() methods to java.lang.Math and to StrictMath [v4]

2023-02-06 Thread Tagir F . Valeev
On Mon, 6 Feb 2023 10:01:49 GMT, Quan Anh Mai wrote: > Suggestion: Refactor the uncommon cases into separate functions so the > compiler can have easier time inlining the common path. Thanks @merykitty this probably needs confirmation from VM folks. I'm pretty sure that C2 will be capable to d

Re: RFR: 8301226: Add clamp() methods to java.lang.Math and to StrictMath [v4]

2023-02-06 Thread Quan Anh Mai
On Mon, 6 Feb 2023 09:46:15 GMT, Tagir F. Valeev wrote: >> clamp() methods added to Math and StrictMath >> >> `int clamp(long, int, int)` is somewhat different, as it accepts a `long` >> value and safely clamps it to an `int` range. Other overloads work with a >> particular type (long, float a

Re: RFR: 8301226: Add clamp() methods to java.lang.Math and to StrictMath [v4]

2023-02-06 Thread Tagir F . Valeev
> clamp() methods added to Math and StrictMath > > `int clamp(long, int, int)` is somewhat different, as it accepts a `long` > value and safely clamps it to an `int` range. Other overloads work with a > particular type (long, float and double). Using similar approach in other > cases (e.g. `flo