Does "strictfp" affect called/intrinsified Math functions?

Joe Darcy joe.darcy at oracle.com
Tue Jan 26 17:45:16 UTC 2021


On 1/26/2021 2:35 AM, Andrew Haley wrote:
> On 1/25/21 9:19 PM, Andrew Leonard wrote:
>
>> Can I just check my understanding is correct, in that the following example
>> will not actually return a "strictfp" value, because the Math.exp() is not
>> strictfp and by default is a non-strictfp Intrinsic inline implementation?
> strictfp affects the code in this method, not other methods called from it.
> If you need StrictMath.exp, which I very much doubt, you'll have to call it.
> There's no real connection between StrictMath and strictfp.

Right -- no direct connection between StrictMath and strictfp. It is not 
always necessary for StrictMath method to be declared strictfp to get 
reproducible results. If the expression in the method cannot overflow or 
underflow, strictfp won't change the result even when the variations 
allowed by non-strictfp could be used. Conversely, it would be fine for 
a Math.foo method to be declared strictfp as that would require Math.foo 
to have reproducible behavior across platforms, even if it differed from 
the StrictMath.foo behavior.

The code generation options allowed by non-strictfp are only available 
(in practice) on the x87 stack. If SSE instructions are being used, all 
the code is strict in practice.

-Joe



More information about the hotspot-dev mailing list