Skip to content

Conversation

@matias9927
Copy link
Contributor

@matias9927 matias9927 commented Apr 17, 2024

Before JDK-8307190, JDK-8309673, and JDK-8301995, invokedynamic operands needed to be rewritten to encoded values to better distinguish indy entries from other cp cache entries. The above changes now distinguish between entries with to_cp_index() using the bytecode, which is now propagated by the callers.

The encoding flips the bits of the index so the encoded index is always negative, leading to access errors if there is no matching decode call. These calls are removed with some methods adjusted to distinguish between indices with the bytecode. Verified with tier 1-5 tests. The changes show no issues when tested against libgraal.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8330388: Remove invokedynamic cache index encoding (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/18819/head:pull/18819
$ git checkout pull/18819

Update a local copy of the PR:
$ git checkout pull/18819
$ git pull https://git.openjdk.org/jdk.git pull/18819/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 18819

View PR using the GUI difftool:
$ git pr show -t 18819

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/18819.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 17, 2024

👋 Welcome back matsaave! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Apr 17, 2024

@matias9927 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:

8330388: Remove invokedynamic cache index encoding

Reviewed-by: cjplummer, dlong, coleenp

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 78 new commits pushed to the master branch:

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk
Copy link

openjdk bot commented Apr 17, 2024

@matias9927 The following labels will be automatically applied to this pull request:

  • graal
  • hotspot
  • serviceability

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.

@openjdk openjdk bot added graal graal-dev@openjdk.org serviceability serviceability-dev@openjdk.org hotspot hotspot-dev@openjdk.org labels Apr 17, 2024
@matias9927 matias9927 marked this pull request as ready for review April 17, 2024 18:49
@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 17, 2024
@mlbridge
Copy link

mlbridge bot commented Apr 17, 2024

Webrevs

Copy link
Contributor

@plummercj plummercj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SA changes look good.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Apr 17, 2024
// process the BSM
int pool_index = indy_info->constant_pool_index();
BootstrapInfo bootstrap_specifier(cp, pool_index, index);
BootstrapInfo bootstrap_specifier(cp, pool_index, indy_index);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just change the incoming parameter name to index?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indy_index is used frequently even in functions that are only used in the context of invokedynamic. I think it helps with clarity.

static const int CPCACHE_INDEX_MANGLE_VALUE = 1000000;

// This function is used to encode an invokedynamic index to differentiate it from a
// constant pool index. It assumes it is being called with a index that is less than 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment still correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last sentence is no longer valid, thanks for catching this!

return true;
} else if (indy_entry->resolution_failed()) {
int encoded_index = ResolutionErrorTable::encode_indy_index(ConstantPool::encode_invokedynamic_index(_indy_index));
int encoded_index = ResolutionErrorTable::encode_indy_index(_indy_index);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an improvement, from two levels of encoding to only one!

@dean-long
Copy link
Member

Did you consider minimizing changes by leaving decode_invokedynamic_index/encode_invokedynamic_index calls in place, but having the implementations not change the value?

Copy link
Member

@dean-long dean-long left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dougxc should check JVMCI changes.

} else {
which = rawIndex;
}
int which = rawIndex;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could get rid of that intermediate variable now and just use rawIndex below.

@dougxc
Copy link
Member

dougxc commented Apr 18, 2024

@dougxc should check JVMCI changes.

Thanks for the heads up. I've asked @matias9927 to double check these changes against libgraal which should address any concerns about how this change impacts Graal.

Copy link
Contributor

@coleenp coleenp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To borrow @shipilev's comment from a different PR, Good Riddance!

@matias9927
Copy link
Contributor Author

Did you consider minimizing changes by leaving decode_invokedynamic_index/encode_invokedynamic_index calls in place, but having the implementations not change the value?

The intention from the start was to remove the encode/decode methods because they have been made unnecessary thanks to the changes mentioned in the description. As the author of the previously mentioned changes that overhauled the cpcache, this change should have been included in one of those PRs, but I must have forgotten! Leaving the calls in even if they did nothing would just make the code confusing and might become a red herring if other issues in the area come up.

Copy link
Contributor

@coleenp coleenp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still good!

@matias9927
Copy link
Contributor Author

Thanks for the reviews @dean-long @gilles-duboscq @coleenp and @plummercj!
/integrate

@openjdk
Copy link

openjdk bot commented Apr 23, 2024

Going to push as commit 383fe6e.
Since your change was applied there have been 94 commits pushed to the master branch:

  • 2ea8926: 8330961: Remove redundant public specifier in ModRefBarrierSet
  • 3d5eeac: 8289770: Remove Windows version macro from ShellFolder2.cpp
  • 6158da5: 8330108: Increase CipherInputStream buffer size
  • a92ad03: 8329995: Restricted access to /proc can cause JFR initialization to crash
  • fcb4a8b: 8330578: The VM creates instance of abstract class VirtualMachineError
  • 3bd6982: 8326150: Typo in the documentation for jdk.jshell
  • d9d926d: 8330145: Serial: Refactor SerialHeap::scan_evacuated_objs
  • 1a6da3d: 8330822: Remove ModRefBarrierSet::write_ref_array_work
  • 281f9bd: 8330735: RISC-V: No need to move sp to tmp register in set_last_Java_frame
  • daa5a4b: 8330802: Desugar switch in Locale::createLocale
  • ... and 84 more: https://git.openjdk.org/jdk/compare/941bee197ff679e9b8755cad117f5172e3508ef2...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Apr 23, 2024
@openjdk openjdk bot closed this Apr 23, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Apr 23, 2024
@openjdk
Copy link

openjdk bot commented Apr 23, 2024

@matias9927 Pushed as commit 383fe6e.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

graal graal-dev@openjdk.org hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

6 participants