RFR: 8343837: Remove unnecessary reinterpret_cast from C2AccessValuePtr [v2]

Tobias Hartmann thartmann at openjdk.org
Fri Nov 8 13:45:36 UTC 2024


On Fri, 8 Nov 2024 13:42:30 GMT, theoweidmannoracle <duke at openjdk.org> wrote:

>> C2AccessValuePtr contains a reinterpret cast from TypePtr* to its base class Type*. This cast was added in [JDK-8202377](https://bugs.openjdk.org/browse/JDK-8202377), due to a circular dependency problem, which no longer exists. The code compiles fine without it and this cast was removed.
>> 
>> Furthermore, a downcast from Type* to TypePtr* exists in this class using reinterpret_cast. This is replaced with the less powerful and more safe static_cast.
>
> theoweidmannoracle has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Update src/hotspot/share/gc/shared/c2/barrierSetC2.hpp
>   
>   Co-authored-by: Tobias Hartmann <tobias.hartmann at oracle.com>

src/hotspot/share/gc/shared/c2/barrierSetC2.hpp line 97:

> 95:     C2AccessValue(node, type) {}
> 96: 
> 97:   const TypePtr* type() const { return static_cast<const TypePtr*>(_type); }

I think this should be:

Suggestion:

  const TypePtr* type() const { return _type->is_ptr(); }


Which has the advantage that we assert that the type is as expected.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21977#discussion_r1834423445


More information about the hotspot-dev mailing list