RFR: 8230203: Replace markWord enums with uintptr_t constants
Kim Barrett
kim.barrett at oracle.com
Tue Aug 27 21:04:29 UTC 2019
> On Aug 27, 2019, at 10:37 AM, Doerr, Martin <martin.doerr at sap.com> wrote:
>
> Hi Stefan,
>
>>> I think it would be better to use C++ 2011 Strongly-typed Enums.
>>
>> Could you elaborate why it would be better to use them in this case?
>
> IMHO enums are better to read and edit. I don't like "static const uintptr_t" replicated 100 times.
Strongly-typed enums (aka enum classes) are not the right thing here. What I think you want is
C++11 explicitly typed enums, e.g. “enum : uintptr_t { … };”
I agree there’s a lot less boilerplate with that. But I like all the cast removals coming out of this
change, and would rather not wait for those.
> In addition, static consts usually spam the binaries with stuff which is never needed while enums are only for the compiler.
The C++11/14 changes to the ODR-used rules solve that. gcc (at least) has implemented effectively that for
a long time. Under the new rules one doesn’t need a definition (with no initializer) of such constants in some
translation unit unless the name is ODR-used, and an lvalue-to-rvalue converted use no longer counts as
an ODR-use.
> I don't understand what keeps us from targeting JEP 347 to jdk14.
There are still some issues with Solaris Studio. Potential issues with other (more obscure) platforms.
More information about the hotspot-dev
mailing list