RFR: 8329194: Cleanup Type::cmp definition and usage

Emanuel Peter epeter at openjdk.org
Mon Apr 15 10:33:44 UTC 2024


On Thu, 28 Mar 2024 15:13:48 GMT, Jasmine Karthikeyan <jkarthikeyan at openjdk.org> wrote:

> Hi all, this patch aims to cleanup `Type::cmp` by changing it from returning a `0` when types are equal and `1` when they are not, to it returning a boolean denoting equality. This makes its usages at various callsites more intuitive. However, as it is passed to the type dictionary as a comparator, a lambda is needed to map the boolean to a comparison value. 
> 
> I was also considering changing the name to `Type::equals` as it's not really returning a comparison value anymore, but I felt it would be too similar to `Type::eq`. If this would be preferred though, I can change it.
> 
> Tier 1 testing passes on my machine. Reviews and thoughts would be appreciated!

src/hotspot/share/opto/type.hpp line 223:

> 221:   // Variant that drops the speculative part of the types
> 222:   bool higher_equal(const Type* t) const {
> 223:     return cmp(meet(t), t->remove_speculative());

Also: can you explain the comment above the method here? If it is true that `cmp` only gave back `0 or 1`, and now only a bool, then how does that tell us anything about "higher" or "lower" in the lattice? Are we not constrained to equal or not equal, where if we have not equal, we don't know if it is higher or lower?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18533#discussion_r1565557412


More information about the hotspot-compiler-dev mailing list