RFR: JDK-8320892: AArch64: Restore FPU control state after JNI [v3]

Tom Shull duke at openjdk.org
Tue Dec 5 11:40:37 UTC 2023


On Tue, 28 Nov 2023 15:58:04 GMT, Andrew Haley <aph at openjdk.org> wrote:

>> Some buggy libraries corrupt the floating-point control register. Provide something similar to the x86 RestoreMXCSROnJNICalls. 
>> 
>> I realize that using the x86ish name "RestoreMXCSROnJNICalls" might be a little controversial, but it is a _global_ flag, not a CPU-specific one. And it's clearly intended for this purpose. It might have been better if that flag had been given a better name twentyish years ago, but we can't change it now.
>
> Andrew Haley has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Fix thinko

src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp line 4439:

> 4437:     // don't want non-IEEE rounding modes or floating-point traps.
> 4438:     bfi(tmp1, zr, 22, 4); // Clear DN, FZ, and Rmode
> 4439:     bfi(tmp1, zr, 8, 5);  // Clear exception-control bits (8-12)

(Related to both this PR and https://github.com/openjdk/jdk/pull/16637) 

Shouldn't also explicit flushing inputs to zero, i.e. when AH:FIZ is (1:1), be protected against?

Also, is it necessary to clear DN? When looking at the spec, I think this should be allowed.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/16851#discussion_r1415447581


More information about the hotspot-dev mailing list