RFR: 8247912: Make narrowOop a scoped enum [v2]

Kim Barrett kbarrett at openjdk.java.net
Tue Sep 29 06:17:38 UTC 2020


On Thu, 24 Sep 2020 13:17:08 GMT, Ioi Lam <iklam at openjdk.org> wrote:

>>> > Also, should we allow only unsigned types for T? I think using signed types here is prone to error and should be
>>> > flagged.
>>> 
>>> It turns out we can't restrict it to unsigned types, at least not very easily. For example,
>>> CDS calls this with an intptr_t value. I suppose CDS could do conversion itself before
>>> calling this, but that seems a little odd. And I don't know how many more there are after
>>> changing that one.
>> 
>> But shouldn't intptr_t be unsigned? I tested with this:
>> 
>> #include <type_traits>
>> #include <stdio.h>
>> 
>> int main() {
>>   printf("%d %d\n", std::is_signed<int>::value, std::is_signed<int*>::value);
>> }
>> 
>> and it prints out "1 0".
>
>> > > Also, should we allow only unsigned types for T? I think using signed types here is prone to error and should be
>> > > flagged.
>> > 
>> > 
>> > It turns out we can't restrict it to unsigned types, at least not very easily. For example,
>> > CDS calls this with an intptr_t value. I suppose CDS could do conversion itself before
>> > calling this, but that seems a little odd. And I don't know how many more there are after
>> > changing that one.
>> 
>> But shouldn't intptr_t be unsigned? I tested with this:
> 
> Oops, my mistake. I thought `intptr_t` was `int*`, but it's in fact "Integer type capable of holding a value converted
> from a void pointer and then be converted back to that type with a value that compares equal to the original pointer."

Ping.  Needs more reviews.

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

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


More information about the shenandoah-dev mailing list