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

Coleen Phillimore coleenp at openjdk.java.net
Tue Apr 27 00:38:37 UTC 2021


On Mon, 26 Apr 2021 23:08:13 GMT, Ioi Lam <iklam at openjdk.org> wrote:

>> 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.

I agree and it's more characters to look at for no real performance benefit.  These offset functions are in many classes.

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

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


More information about the hotspot-dev mailing list