RFR: 8329194: Cleanup Type::cmp definition and usage [v2]
Jasmine Karthikeyan
jkarthikeyan at openjdk.org
Tue Apr 16 13:56:04 UTC 2024
On Tue, 16 Apr 2024 10:56:56 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
>> Jasmine Karthikeyan has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Rename to Type::equals, changes from code review
>
> src/hotspot/share/opto/type.hpp line 160:
>
>> 158:
>> 159: static int uhash( const Type *const t );
>> 160: // Structural equality check. Assumes that equals() has already compared
>
> Is this even correct? Because we use `eq` inside `equals`, (before your patch, we used `eq` inside `cmp`).
> Should this not rather mean that we should have already done the `==`?
> What do you think?
I think it's still correct, because from my understanding it's referring to this line in `equals`:
```c++
if (t1->_base != t2->_base) {
return false; // Missed badly
}
`equals` only calls `eq`after this, so `eq` knows that the underlying type of both classes are the same. So `TypeInt::eq`, for example, is able to safely cast the incoming `Type* t` to a `TypeInt*` to do a structural equality check.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/18533#discussion_r1567406437
More information about the hotspot-compiler-dev
mailing list