RFR: 8265867: thread.hpp defines some enums but no reference

Ioi Lam iklam at openjdk.java.net
Mon Apr 26 23:11:41 UTC 2021


On Mon, 26 Apr 2021 20:58:47 GMT, Coleen Phillimore <coleenp at openjdk.org> wrote:

>> Deleted 2 useless enums.
>> This patch also added const and constexpr for the applicable member functions.
>
> src/hotspot/share/gc/shared/threadLocalAllocBuffer.hpp line 189:
> 
>> 187:   static constexpr ByteSize end_offset()         { return byte_offset_of(ThreadLocalAllocBuffer, _end); }
>> 188:   static constexpr ByteSize top_offset()         { return byte_offset_of(ThreadLocalAllocBuffer, _top); }
>> 189:   static constexpr ByteSize pf_top_offset()      { return byte_offset_of(ThreadLocalAllocBuffer, _pf_top); }
> 
> Is constexpr really necessary here?  Isn't this usually a constant expression for most compilers?

We have many of these inline functions that could be either `const` and `constexpr`. Since `constexpr` has been allowed only recently, there are very few functions that are actually declared `constexpr`.

My recommendation is to limit `constexpr` only to new code. We can change `const` to `constexpr` when required (e.g., when an existing function is called by new code that's in a `constexpr` context). That way, we can limit code churn.

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

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


More information about the hotspot-dev mailing list