-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8314644: Change "Rvalue references and move semantics" into an accepted feature #15386
Conversation
👋 Welcome back jsjolen! A progress list of the required criteria for merging this PR into |
@jdksjolen The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
After internal discussion I have come to the conclusion that this probably won't move forward, but if we have any external contributors who would like to voice their opinion I am happy to hear them. |
Some thoughts of mine, cribbed from that internal discussion. I'll preface by A specific problem we currently have is that there are lots of classes with Move semantics is an excellent tool for some problems, much better than There are several problems we need to address with such a proposal. One is |
Mailing list message from daniel.daugherty at oracle.com on hotspot-dev: A couple of questions: - Are these C++ features supported in all of the compilers that we Dan On 8/22/23 8:23 AM, Johan Sj?len wrote: |
Hi Dan, here are my findings:
Looking at: https://en.cppreference.com/w/cpp/compiler_support/11 We can confirm that Rvalue references are supported by gcc 4.5, clang 17 and MSVC (no version mentioned). For IBM XL for AIX it is supported according to this url: https://www.ibm.com/docs/en/openxl-c-and-cpp-aix/17.1.1?topic=features-supported-language-levels To be clear: This is a feature from C++11 and is considered table stakes for C++ compilers today, I'd be surprised if it wasn't supported. But we don't want to be taken by surprise, I get that :-).
We may add tests checking that the move constructors are called when |
Thanks for the info. I appreciate the effort that it takes to dig up the details |
/label -build |
@magicus |
@jdksjolen This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
Hi, I've expanded the text on this a bit. I'm basically attempting to say that the usage of this should be limited and I give an example. I also use "we" to refer to "HotSpot developers as a whole" and "you" to refer to "the reader of this document." The latter is previously established as a style choice, but the former is not AFAICS. |
@jdksjolen This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
@jdksjolen This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the |
Shame that this never made it in, this sounds pretty useful |
Hi,
I'd like to propose that rvalue references and move semantics are now considered permitted in the style guide. This change would allow for move constructors to be written. This enables more performant code, if the move ctr is less expensive than the copy ctr, but also more correct code. For the latter part, look at "8314571: GrowableArray should move its old data and not copy it". Here we can avoid using copy assignment, instead using move constructors, which more accurately reflects what is happening: The old elements are in fact moved, and not copied.
Two useful std functions will become available to us with this change:
std::move
, for explicitly moving a value. This is a slightly more powerfulstatic_cast<T&&>(T)
, in that it also handlesT&
corectly.std::forward
, which simplifies the usage of perfect forwarding. Perfect forwarding is a technique where in copying is minimized. To quote Scott Meyers ( https://cppandbeyond.com/2011/04/25/session-announcement-adventures-in-perfect-forwarding/ ):Looking forward to your feedback, thank you.
Johan
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/15386/head:pull/15386
$ git checkout pull/15386
Update a local copy of the PR:
$ git checkout pull/15386
$ git pull https://git.openjdk.org/jdk.git pull/15386/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 15386
View PR using the GUI difftool:
$ git pr show -t 15386
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/15386.diff
Webrev
Link to Webrev Comment