Conversation
|
/label hotspot |
|
👋 Welcome back stefank! A progress list of the required criteria for merging this PR into |
|
@stefank this pull request can not be integrated into git checkout 8263721_unify_oop_casting
git fetch https://git.openjdk.java.net/jdk master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push |
|
@stefank |
kimbarrett
left a comment
There was a problem hiding this comment.
Looks good. Just the one minor nit.
There are a lot of casts to void* as an argument that ought to be cleaned up. And the set of valid types for the cast functions ought to be restricted to "reasonable" types. But that can be a followup.
| oop() : _o(NULL) { register_if_checking(); } | ||
| oop(const oop& o) : _o(o._o) { register_if_checking(); } | ||
| oop(const void* p) : _o((oopDesc*)p) { register_if_checking(); } | ||
| oop() : _o(NULL) { register_if_checking(); } |
|
@stefank This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been no new commits pushed to the ➡️ To integrate this PR with the above commit message to the |
coleenp
left a comment
There was a problem hiding this comment.
Looks like a safe to me. I didn't realize there were still so many files with oop casts. I only scrolled by the GC ones though.
|
Thanks for reviewing! |
|
@stefank Since your change was applied there have been 4 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit a79f095. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
In fastdebug builds we replace the "oopDesc* to oop" typedef with a wrapper class that holds an oopDesc*. This wrapper class allows any kind of pointer to be implicitly converted to an oop. So you can write code like this:
and the compiler will unfortunately accept it. Fortunately, this will be caught in release builds, because you can't convert a Method* into an oopDesc*.
One interesting thing is that you can't convert values of integral type too oops:
This fails in both fastdebug and release builds. To be able to convert integral values to oops, there are two helper functions:
So, the above example would have to be written as:
My proposal is that we stop allowing implicit (and explicit) casts from void*, and instead use cast_to_oop whenever we want to cast to oops. We would still allow oopDesc* to be implicitly converted to oop. This would also allow NULL to be converted too oop without casting:
This will make the code to convert oops a little bit longer. It could be argued that that's a good thing, because everyone should be cautious about converting things into oops. This will also give us one entry-point where we could add (probably temporary) verification code.
An alternative to the suggestion above, could be to completely get rid of cast_to_oop and cast_from_oop. But for that to work we need to stop using NULL, which is an integral 0, and start to use nullptr for oops. I've prototyped this as well, but initial investigations showed that some tended to prefer having the cast_to_oop function. (We could still move from NULL to nullptr, if we think that is a good idea).
Progress
Issue
Reviewers
Download
To checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3047/head:pull/3047$ git checkout pull/3047To update a local copy of the PR:
$ git checkout pull/3047$ git pull https://git.openjdk.java.net/jdk pull/3047/head