Skip to content

Conversation

@c-refice
Copy link
Contributor

@c-refice c-refice commented Jul 19, 2024

This PR adds JVMCI support to scoped access tracking introduced in #20158.

In this PR:

  • The Method::is_scoped flag is now exposed in JVMCI as HotSpotResolvedJavaMethod.isScoped(), and serialized to / deserialized from the JVMCI compiled code stream as a boolean flag.
  • To determine whether a compiled method has a scoped access, we simply check HotSpotResolvedJavaMethod.isScoped() returns true for the root method or any of the methods that were inlined in the compilation.
  • The above check is implemented as the method HotSpotCompiledNMethod.hasScopedAccess(), instead of as an explicit flag set in a the constructor of HotSpotCompiledNMethod. This keeps the change isolated to JVMCI, without requiring coordinated changes to the Graal compiler. No other changes in the compiler are necessary to benefit from the optimization.

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-8336489: Track scoped accesses in JVMCI compiled code (Enhancement - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 20256

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper bridgekeeper bot added the oca Needs verification of OCA signatory status label Jul 19, 2024
@bridgekeeper
Copy link

bridgekeeper bot commented Jul 19, 2024

Hi @c-refice, welcome to this OpenJDK project and thanks for contributing!

We do not recognize you as Contributor and need to ensure you have signed the Oracle Contributor Agreement (OCA). If you have not signed the OCA, please follow the instructions. Please fill in your GitHub username in the "Username" field of the application. Once you have signed the OCA, please let us know by writing /signed in a comment in this pull request.

If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please use "Add GitHub user c-refice" as summary for the issue.

If you are contributing this work on behalf of your employer and your employer has signed the OCA, please let us know by writing /covered in a comment in this pull request.

@openjdk
Copy link

openjdk bot commented Jul 19, 2024

@c-refice 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:

8336489: Track scoped accesses in JVMCI compiled code

Reviewed-by: dnsimon, never

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:

  • 2e093b0: 8337779: test/jdk/jdk/jfr/jvm/TestHiddenWait.java is a bit fragile
  • d3e7b0c: 8336462: ConcurrentSkipListSet Javadoc incorrectly warns about size method complexity
  • be34730: 8335257: Refactor code to create Initialized Assertion Predicates into separate class
  • fbe8a81: 8333144: docker tests do not work when ubsan is configured
  • dabdae6: 8334599: Improve code from JDK-8302671
  • 8bd3cd5: 8337716: ByteBuffer hashCode implementations are inconsistent
  • 367e0a6: 8334755: Asymptotically faster implementation of square root algorithm
  • 34edc73: 8337396: Cleanup usage of ExternalAddess
  • 7deee74: 8335122: Reorganize internal low-level support for HTML in jdk.javadoc
  • f2e1205: 8337676: JFR: Change the label of the throttle setting
  • ... and 68 more: https://git.openjdk.org/jdk/compare/374fca0fcbc049f937fa49bb4825edcbbf961f2b...master

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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@tkrodriguez, @dougxc) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk
Copy link

openjdk bot commented Jul 19, 2024

@c-refice The following labels will be automatically applied to this pull request:

  • graal
  • hotspot-compiler

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 hotspot-compiler hotspot-compiler-dev@openjdk.org labels Jul 19, 2024
@c-refice
Copy link
Contributor Author

/covered

@bridgekeeper bridgekeeper bot added the oca-verify Needs verification of OCA signatory status label Jul 19, 2024
@bridgekeeper
Copy link

bridgekeeper bot commented Jul 19, 2024

Thank you! Please allow for a few business days to verify that your employer has signed the OCA. Also, please note that pull requests that are pending an OCA check will not usually be evaluated, so your patience is appreciated!

@bridgekeeper bridgekeeper bot removed oca Needs verification of OCA signatory status oca-verify Needs verification of OCA signatory status labels Jul 19, 2024
@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 19, 2024
@mlbridge
Copy link

mlbridge bot commented Jul 19, 2024

Webrevs

Copy link
Contributor

@tkrodriguez tkrodriguez left a comment

Choose a reason for hiding this comment

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

Looks good to me

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 19, 2024
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Jul 23, 2024
@c-refice c-refice force-pushed the shared-close-jvmci branch from 1f60dae to 9620670 Compare July 23, 2024 12:58
@openjdk
Copy link

openjdk bot commented Jul 23, 2024

@c-refice Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information.

Copy link
Contributor

@tkrodriguez tkrodriguez left a comment

Choose a reason for hiding this comment

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

New version looks good.

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed ready Pull request is ready to be integrated labels Jul 23, 2024
@c-refice
Copy link
Contributor Author

c-refice commented Jul 26, 2024

I figured out what went wrong with the is_scoped flag in JVMCI. The implementation of HotSpotResolvedJavaMethodImpl#getConstMethodFlags was as follows:

    private int getConstMethodFlags() {
        return UNSAFE.getChar(getConstMethod() + config().constMethodFlagsOffset);
    }
    
    public boolean isScoped() {
        // constMethodFlagsIsScoped == 1 << 16
        return (getConstMethodFlags() & config().constMethodFlagsIsScoped) != 0;
    }

However, ConstMethod::_flags is a u4, not a u1. This caused only the least significant byte of the flags (or most, depending on endianness) to be read in JVMCI code. A similar problem also occurred with Method::_flags, though for that one two bytes were read.

I suppose we didn't really care about flags with bit indexes past 8 before now, hence why the tests never failed before. Nevertheless, I fixed both and isScoped() now behaves as expected (and tested)

@c-refice c-refice force-pushed the shared-close-jvmci branch from 59c4fa7 to 8fabb8b Compare July 26, 2024 17:10
@openjdk
Copy link

openjdk bot commented Jul 26, 2024

@c-refice Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information.

@c-refice
Copy link
Contributor Author

c-refice commented Jul 26, 2024

Apologies for the second force push, I involuntarily rebased my branch on top of origin/master again

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 5, 2024
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Aug 5, 2024
Copy link
Member

@dougxc dougxc left a comment

Choose a reason for hiding this comment

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

Still looks good to me.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 5, 2024
@c-refice
Copy link
Contributor Author

c-refice commented Aug 5, 2024

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Aug 5, 2024
@openjdk
Copy link

openjdk bot commented Aug 5, 2024

@c-refice
Your change (at version 8b61ab7) is now ready to be sponsored by a Committer.

@dougxc
Copy link
Member

dougxc commented Aug 5, 2024

/sponsor

@openjdk
Copy link

openjdk bot commented Aug 5, 2024

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

  • 7e925d7: 8337283: configure.log is truncated when build dir is on different filesystem
  • 2e093b0: 8337779: test/jdk/jdk/jfr/jvm/TestHiddenWait.java is a bit fragile
  • d3e7b0c: 8336462: ConcurrentSkipListSet Javadoc incorrectly warns about size method complexity
  • be34730: 8335257: Refactor code to create Initialized Assertion Predicates into separate class
  • fbe8a81: 8333144: docker tests do not work when ubsan is configured
  • dabdae6: 8334599: Improve code from JDK-8302671
  • 8bd3cd5: 8337716: ByteBuffer hashCode implementations are inconsistent
  • 367e0a6: 8334755: Asymptotically faster implementation of square root algorithm
  • 34edc73: 8337396: Cleanup usage of ExternalAddess
  • 7deee74: 8335122: Reorganize internal low-level support for HTML in jdk.javadoc
  • ... and 69 more: https://git.openjdk.org/jdk/compare/374fca0fcbc049f937fa49bb4825edcbbf961f2b...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Aug 5, 2024

@dougxc @c-refice Pushed as commit c095c0e.

💡 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-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

4 participants