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

Emanuel Peter epeter at openjdk.org
Mon Apr 15 09:57:42 UTC 2024


On Mon, 15 Apr 2024 07:15:14 GMT, Christian Hagedorn <chagedorn 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/cpu/x86/x86.ad line 10010:
> 
>> 10008:     const MachNode* mask1 = static_cast<const MachNode*>(this->in(this->operand_index($src1)));
>> 10009:     const MachNode* mask2 = static_cast<const MachNode*>(this->in(this->operand_index($src2)));
>> 10010:     assert(Type::cmp(mask1->bottom_type(), mask2->bottom_type()), "");
> 
> While at it, you could add a message like "should be false" for good practice.

Well, I would say it should be "types must be equal".

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

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


More information about the hotspot-compiler-dev mailing list