RFR: 8346774: Use Predicate classes instead of Node classes
Kim Barrett
kbarrett at openjdk.org
Wed Jan 29 18:02:10 UTC 2025
On Fri, 24 Jan 2025 12:15:05 GMT, Christian Hagedorn <chagedorn at openjdk.org> wrote:
> I assumed that RVO will make sure that we do not create an extra copy regardless of whether a method is inlined or not. Maybe @kimbarrett can comment on that.
Not a review, just a response to the question about RVO.
The use of NRVO and RVO here looks fine to me.
C++17 makes RVO mandatory. We're not using C++17 yet, but part of the
rationale for making it mandatory is that compilers were already doing it (and
had been for some time), at least with optimizing settings. You just couldn't
rely on it, and had to provide the appropriate ctors even if RVO was always
performed. (For example, a copy-ctor is needed even if always using a factory
function that returns a directly constructed object.)
While NRVO was not made mandatory, that may have been more a matter of concern
over specification difficulty for corner cases. In my experience, obvious
cases like those in this PR have been getting NRVO from optimizing compilers
for a long time.
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0135r0.html
https://en.cppreference.com/w/cpp/language/copy_elision
Support for guaranteed copy elision
https://en.cppreference.com/w/cpp/compiler_support/17
gcc: 7, clang: 4, msvc: 19.13 (VS 2017 15.6)
These versions are for the C++17 "guaranteed in all circumstances" feature.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/23234#issuecomment-2622458475
More information about the hotspot-compiler-dev
mailing list