RFR: 8282143: Objects.requireNonNull should be ForceInline [v2]

Quan Anh Mai duke at openjdk.java.net
Wed Mar 2 00:35:59 UTC 2022


On Tue, 1 Mar 2022 02:22:49 GMT, Quan Anh Mai <duke at openjdk.java.net> wrote:

>> Hi,
>> 
>> `Objects.requireNonNull` may fail to be inlined. The call is expensive and may lead to objects escaping to the heap while the null check is cheap and is often elided. I have observed this when using the vector API when a call to `Objects.requireNonNull` leads to vectors being materialised in a hot loop.
>> 
>> Should the other `requireNonNull` be `ForceInline` as well?
>> 
>> Thank you very much.
>
> Quan Anh Mai has updated the pull request incrementally with one additional commit since the last revision:
> 
>   the other

Thanks a lot for your reviews, do I need a second review for this?
@ExE-Boss IMO generally we only decorate `ForceInline` on functions of which inlining is crucial since inlining decision is a hard problem and often not solvable from the local point of view, especially from the callee's one.

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

PR: https://git.openjdk.java.net/jdk/pull/7543


More information about the core-libs-dev mailing list