RFR: 8247909: Improve PrimitiveConversions::cast using C++14

Kim Barrett kim.barrett at oracle.com
Tue Sep 15 07:34:37 UTC 2020


> On Sep 14, 2020, at 4:07 AM, Stefan Karlsson <stefank at openjdk.java.net> wrote:
> 
> On Sun, 13 Sep 2020 07:27:13 GMT, Kim Barrett <kbarrett at openjdk.org> wrote:
> 
>> Please review this reimplementation of PrimitiveConversions::cast,
>> using facilities from C++14.  In particular, conversions involving
>> only integral values or integral and enum values are now constexpr.
>> Also using <type_traits> rather than HotSpot work-alikes.
>> 
>> Had to update zForwardingEntry.hpp because of a class no longer being
>> implicitly included.  Improved a friend declaration while in the
>> vicinity.
>> 
>> Testing
>> mach5 tier1
> 
> I think this looks good.

Thanks.

> The patch updates ZForwardingEntry to use std::true_type. Why isn't that done for the handful
> other places where we use PrimitiveConversions::Translate?

zForwardingEntry.hpp needed to be touched to address the dependency on
integralConstant.hpp, which is no longer included by primitiveConversions.hpp.
Other uses of PrimitiveConversions::Translate didn't run into that problem
for one reason or another.

I have a collection of other C++11/14-based changes still to be worked
through, including some that change the HotSpot workalikes for various type
traits. In some cases they might be eliminated, replacing uses with
<type_traits> facilities. In other cases where there are many uses we might
reimplement them using <type_traits> and incrementally replace uses.
Changing the base class for PrimitiveConversions::Translate specializations
is somewhere in there.

> src/hotspot/share/metaprogramming/primitiveConversions.hpp line 35:
> 
>> 33: class PrimitiveConversions : public AllStatic {
>> 34:
>> 35:   // True if types are the same size and either is integral then int.
> 
> I don't get the " then int." part. Is this from an earlier version using "enable if" with types?

Well spotted; your guess is correct.  I’ll delete that phrase.

> PR: https://git.openjdk.java.net/jdk/pull/143




More information about the hotspot-dev mailing list