Improve documentation of register allocator data structures with respect to contracts of equals(), hashCode() and compareTo()

Description

Some of the data structures in the regalloc package don't obey the contracts of equals(), hashCode() and compareTo().

In particular,

  • BasicInterval and MappedBasicInterval implement equals() but not hashCode()

  • equals() isn't symmetric between BasicInterval and MappedBasicInterval

  • StartComparator in IncreasingStartIntervalSet would consider instances of MappedBasicInterval and BasicInterval equivalent even if a correct equals() implementation would return false. The same applies for the comparators in IncreasingEndMappedIntervalSet and IncreasingStartMappedIntervalSet

Moreover, IncreasingStartMappedIntervalSet is currently unused. BasicInterval is only used as an internal helper class.

We should refactor and/or redesign the data structures to ensure that they work correctly. After that, the documentation needs to be updated. Unit tests would also be very helpful.

Environment

All

Status

Assignee

Erik Brangs

Reporter

Erik Brangs

Labels

None

Components

Fix versions

Affects versions

Priority

Medium
Configure