In G1CollectedHeap::heap_region_containing, JDK-8237637 replaced a cast to HeapWord* with a cast sequence to void* then to HeapWord*. This was needed because this function template may be applied to an oop, and the direct cast to HeapWord* no longer works for oop when CHECK_UNHANDLED_OOPS is enabled.
But the problem here is really that heap_region_containing with an oop argument is sharing that common template definition. It could instead be a separate overload that calls the other on the result of cast_from_oop. But we don't actually need a template there at all; two ordinary function overloads, for HeapWord* and for oop (the latter calling the former on the cast-from-oop) suffices, and simplifies the code.
Similarly for heap_region_containing_or_null.
But the problem here is really that heap_region_containing with an oop argument is sharing that common template definition. It could instead be a separate overload that calls the other on the result of cast_from_oop. But we don't actually need a template there at all; two ordinary function overloads, for HeapWord* and for oop (the latter calling the former on the cast-from-oop) suffices, and simplifies the code.
Similarly for heap_region_containing_or_null.
- relates to
-
JDK-8237637 Remove dubious type conversions from oop
- Resolved