[lworld] RFR: 8353236: [lworld] Better documentation for Valhalla Unsafe intrinsics

Chen Liang liach at openjdk.org
Wed Apr 9 14:05:48 UTC 2025


On Wed, 9 Apr 2025 13:18:39 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:

> Hi,
> 
> This patch clarifies the meaning of undefined behavior when working with `Unsafe` and specifies the requirements when working with `Unsafe::makePrivateBuffer` and `Unsafe::finishPrivateBuffer`.
> 
> Please take a look and leave your suggestions, thanks a lot.

src/java.base/share/classes/jdk/internal/misc/Unsafe.java line 73:

> 71:  * control path may eventually reach an invocation of an {@code Unsafe} method
> 72:  * with illegal arguments, the symptoms of undefined behavior may be present
> 73:  * even before the invocation of the {@code Unsafe} method.

I think you can talk in a more JIT-oriented manner, that while Unsafe is mostly set up to be the hooks between core libraries and hotspot runtime, hotspot compiler may interpret the input values and perform aggressive optimizations with contracts that cannot be explicitly expressed by Java program semantics.

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

PR Review Comment: https://git.openjdk.org/valhalla/pull/1425#discussion_r2035449310


More information about the valhalla-dev mailing list