-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8372845: C2: Fold identity hash code if object is constant #28589
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
base: master
Are you sure you want to change the base?
Conversation
|
/author @iwanowww |
|
👋 Welcome back liach! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
|
@liach |
Webrevs
|
|
/label remove graal |
|
@iwanowww |
|
@iwanowww |
|
/contributor add liach |
|
I have one question: would it be safer for us to move the constant detection after generate_virtual_guard in the |
Yes, I think so too. We need a test for this scenario. Just an observation: This patch will only allow folding during parsing. I would expect that often, opportunities only arise after other optimizations already took place. For example, something like this would not be optimized if we run with Another example: So ideally, we would move this optimization to IGVN. This would also help Valhalla, where we need to (re-)compute the hashcode for a scalarized value object and would therefore like to fold the computation as aggressively as possible. |
Good catch. I missed that the intrinsic is shared between I'm not sure it makes sense to support |
I deliberately omitted post-parse optimization opportunities for now. It would require a gradual lowering of the representation from a high-level macro node to low-level poking at object header. Moreover, final representation has complex control, so either the macro node should be a CFG node or a way to determine a location in CFG for a data-only macro node and expanding it there needs to be supported. (There are other use cases for such functionality, like lowering data nodes into pure calls, but no readily available implementation is there yet.) IMO something to work on in a follow-up enhancement. |
Or, alternatively, inspect constant object's v-table during compilation and ensure that corresponding slot points at |
vnkozlov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good. Yes, we can work on constant folding in IGVN later.
|
@iwanowww please fix title to match JBS. |
|
@vnkozlov I can't since I'm not the author of the PR :-) |
|
I tried to come up with an example where the buggy code from Vladimir would inline to identityHashCode when the right call would be virtual - couldn't construct such a case unfortunately :( I think we can deal with IGVN later, as this involves creating new macro node and other infrastructure support. |
|
/touch |
|
@liach The pull request is being re-evaluated and the inactivity timeout has been reset. |
|
@liach |
Folding identity hash as constant if the incoming argument is constant would be useful for quick map lookups, such as for the Classifier proposal. Currently, identity hash is not constant because it loads the object header/mark word. We can add an explicit bypass to load an existing hash eagerly instead.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/28589/head:pull/28589$ git checkout pull/28589Update a local copy of the PR:
$ git checkout pull/28589$ git pull https://git.openjdk.org/jdk.git pull/28589/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 28589View PR using the GUI difftool:
$ git pr show -t 28589Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28589.diff
Using Webrev
Link to Webrev Comment