RFR: 8315066: Add unsigned bounds and known bits to TypeInt/Long [v39]

Emanuel Peter epeter at openjdk.org
Thu Jan 30 15:31:03 UTC 2025


On Thu, 30 Jan 2025 15:04:05 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:

>> src/hotspot/share/opto/rangeinference.cpp line 59:
>> 
>>> 57: // This class deals with each interval with both bounds being >= 0 or < 0 in
>>> 58: // the signed domain. We call it Simple because a canonicalized TypeIntPrototype
>>> 59: // may contain 1 or 2 SimpleCanonicalResult.
>> 
>> Aha! Now I understand why "Simple"!
>> It could be nice if you had a constructor where you validate the "simple" constraint, i.e. that we are in either of these cases:
>> - empty.
>> - `[lo, hi] >= 0` and `[lo, hi] == [ulo, uhi]`
>> - `[lo, hi] < 0` and `[ulo, uhi] >= 2^31` and `[lo, hi] = [(jint)ulo, (jint)uhi]`
>> I did understand this correctly, right?
>
> Defining a constructor prevents usage of brace initialization :(

That's sad, but it may be worth it. I'm just seeing someone in the future break the constraint... and then having a hard time figuring out what they did wrong 😉

>> src/hotspot/share/opto/rangeinference.cpp line 66:
>> 
>>> 64:   bool _present; // whether this is an empty set
>>> 65:   RangeInt<U> _bounds;
>>> 66:   KnownBits<U> _bits;
>> 
>> Could these be const? That would additionally guaratee that nobody can come in and violate the "simple" constraint.
>
> Making a member const would make the whole object kind of const, which is not ideal here.

Why is it not ideal?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17508#discussion_r1935813765
PR Review Comment: https://git.openjdk.org/jdk/pull/17508#discussion_r1935814073


More information about the hotspot-compiler-dev mailing list