Skip to content
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

8301995: Move invokedynamic resolution information out of ConstantPoolCacheEntry #12778

Closed
wants to merge 18 commits into from

Conversation

matias9927
Copy link
Contributor

@matias9927 matias9927 commented Feb 27, 2023

The current structure used to store the resolution information for invokedynamic, ConstantPoolCacheEntry, is difficult to interpret due to its ambigious fields f1 and f2. This structure can hold information for fields, methods, and invokedynamics and each of its fields can hold different types of values depending on the entry.

This enhancement proposes a new structure to exclusively contain invokedynamic information in a manner that is easy to interpret and easy to extend. Resolved invokedynamic entries will be stored in an array in the constant pool cache and the operand of the invokedynamic bytecode will be rewritten to be the index into this array.

Any areas that previously accessed invokedynamic data from ConstantPoolCacheEntry will be replaced with accesses to this new array and structure. Verified with tier1-9 tests.

The PPC port was provided by @reinrich, RISCV was provided by @DingliZhang and @zifeihan, and S390x by @offamitkumar.

This change supports the following platforms: x86, aarch64, PPC, RISCV, and S390x


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-8301995: Move invokedynamic resolution information out of ConstantPoolCacheEntry

Reviewers

Contributors

  • Richard Reingruber <rrich@openjdk.org>
  • Dingli Zhang <dzhang@openjdk.org>
  • Gui Cao <gcao@openjdk.org>
  • Amit Kumar <amitkumar@openjdk.org>

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 12778

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 27, 2023

👋 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 Feb 27, 2023

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

  • 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 serviceability serviceability-dev@openjdk.org hotspot hotspot-dev@openjdk.org labels Feb 27, 2023
@matias9927 matias9927 changed the title 8301995: Move invokedynamic resolution information out of the cpCache 8301995: Move invokedynamic resolution information out of ConstantPoolCacheEntry Feb 28, 2023
@matias9927 matias9927 marked this pull request as ready for review March 2, 2023 16:50
@openjdk openjdk bot added the rfr Pull request is ready for review label Mar 2, 2023
@mlbridge
Copy link

mlbridge bot commented Mar 2, 2023

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.

This looks really good. I noted a few changes and questions.

src/hotspot/cpu/ppc/templateTable_ppc_64.cpp Show resolved Hide resolved
src/hotspot/cpu/x86/templateTable_x86.cpp Show resolved Hide resolved
src/hotspot/share/cds/classListParser.cpp Outdated Show resolved Hide resolved
src/hotspot/share/ci/ciReplay.cpp Outdated Show resolved Hide resolved
src/hotspot/share/ci/ciReplay.cpp Outdated Show resolved Hide resolved
src/hotspot/share/oops/resolvedIndyEntry.hpp Outdated Show resolved Hide resolved
src/hotspot/share/oops/resolvedIndyEntry.hpp Outdated Show resolved Hide resolved
src/hotspot/share/oops/resolvedIndyEntry.hpp Show resolved Hide resolved
src/hotspot/share/interpreter/bootstrapInfo.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/x86/interp_masm_x86.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/x86/templateTable_x86.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/x86/templateTable_x86.cpp Outdated Show resolved Hide resolved
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.

I have a couple of very minor comments. This change is great. Thank you!

void TemplateTable::load_invoke_cp_cache_entry(int byte_no,
Register method,
Register itable_index,
Register flags,
bool is_invokevirtual,
bool is_invokevfinal, /*unused*/
bool is_invokedynamic) {
bool is_invokedynamic /*unused*/) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you remove the parameter since the s390 port is here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, never mind, I saw s390 port but it doesn't seem to be in these changes (?)

Copy link
Member

Choose a reason for hiding this comment

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

Ok, never mind, I saw s390 port but it doesn't seem to be in these changes (?)

It is not in these changes.
@offamitkumar is working on s390x. It is not yet finished though.
(I wasn't aware that putting the URL of this PR into a comment somewhere else adds a comment to this PR)

src/hotspot/share/oops/resolvedIndyEntry.hpp Outdated Show resolved Hide resolved
@openjdk
Copy link

openjdk bot commented Mar 13, 2023

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

8301995: Move invokedynamic resolution information out of ConstantPoolCacheEntry

Co-authored-by: Richard Reingruber <rrich@openjdk.org>
Co-authored-by: Dingli Zhang <dzhang@openjdk.org>
Co-authored-by: Gui Cao <gcao@openjdk.org>
Co-authored-by: Amit Kumar <amitkumar@openjdk.org>
Reviewed-by: coleenp, dnsimon, fparain, gcao, aph, fyang, amitkumar, lucy

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

  • 50a995f: 8304927: Update java/net/httpclient/BasicAuthTest.java to check basic auth over HTTP/2
  • ca745cb: 8291598: Matcher.appendReplacement should not create new StringBuilder instances
  • 1683a63: 8305098: [Backout] JDK-8303912 Clean up JavadocTokenizer
  • fab2357: 8304498: JShell does not switch to raw mode when there is no /bin/test
  • 1fc218c: 8303912: Clean up JavadocTokenizer
  • c1f5ca1: 8303623: Compiler should disallow non-standard UTF-8 string encodings
  • 695683b: 8304880: [PPC64] VerifyOops code in C1 doesn't work with ZGC
  • 83ce65e: 8305004: add @SPEC tags to langtools modules
  • 32ef452: 8304884: Update Bytecodes data to be mostly compile time constants
  • 927e674: 8300977: Retire java.io.ExpiringCache
  • ... and 166 more: https://git.openjdk.org/jdk/compare/55aa122462c34d8f4cafa58f4d1f2d900449c83e...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.

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

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Mar 13, 2023
@coleenp
Copy link
Contributor

coleenp commented Mar 13, 2023

@dougxc Can you have a look at the jvmci changes in this PR also?

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.

As communicated to Matias earlier via email, the JVMCI changes in this PR look fine.

@reinrich
Copy link
Member

@matias9927 can I ask you to merge master? There seem to be conflicts (at least I see a message "This branch has conflicts that must be resolved").
I'd like to give the change a spin in our CI testing. This requires that it can be applied on master.

@zifeihan
Copy link
Member

Hi,
I have updated the riscv related code by referring to the latest aarch64 related changes, please help me to update it.
zifeihan@ca9f110
(on this branch: https://github.com/zifeihan/jdk/commits/follow_12778)

@RealFYang @DingliZhang Please help review the RISCV port code.

@matias9927
Copy link
Contributor Author

@matias9927 can I ask you to merge master? There seem to be conflicts (at least I see a message "This branch has conflicts that must be resolved"). I'd like to give the change a spin in our CI testing. This requires that it can be applied on master.

I saw that merge error but nothing came up when I tried to merge locally. The branch is updated nonetheless, so you should be able to test it now @reinrich !

Copy link
Member

@calvinccheung calvinccheung 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. Just a few minor comments.

src/hotspot/share/oops/cpCache.cpp Outdated Show resolved Hide resolved
src/hotspot/share/oops/cpCache.cpp Outdated Show resolved Hide resolved
src/hotspot/share/oops/cpCache.cpp Outdated Show resolved Hide resolved
src/hotspot/share/oops/cpCache.cpp Outdated Show resolved Hide resolved
src/hotspot/share/prims/methodComparator.cpp Outdated Show resolved Hide resolved
src/hotspot/share/interpreter/bootstrapInfo.cpp Outdated Show resolved Hide resolved
src/hotspot/share/interpreter/bootstrapInfo.cpp Outdated Show resolved Hide resolved
Copy link
Contributor

@theRealAph theRealAph left a comment

Choose a reason for hiding this comment

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

AArch64 looks good. Thank you.

src/hotspot/cpu/aarch64/templateTable_aarch64.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/aarch64/templateTable_aarch64.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/riscv/templateTable_riscv.cpp Show resolved Hide resolved
src/hotspot/cpu/riscv/templateTable_riscv.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/riscv/templateTable_riscv.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/riscv/templateTable_riscv.cpp Outdated Show resolved Hide resolved
@zifeihan
Copy link
Member

More changes for RISC-V which resolve @RealFYang's review comments. @matias9927 Please help integrate this
zifeihan@413dd02
(on this branch: https://github.com/zifeihan/jdk/commits/12778_riscv_port_v4)
By the way, the riscv port passed the tier1-3 tests on unmatched board with no new errors introduced.

@matias9927 matias9927 requested review from TheRealMDoerr and RealFYang and removed request for TheRealMDoerr March 27, 2023 18:16
Copy link
Member

@RealFYang RealFYang left a comment

Choose a reason for hiding this comment

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

Updated RISC-V part looks good.

@offamitkumar
Copy link
Member

Hi Matias,

s390x port is almost complete. All builds are successful & tier1 test for fast debug are complete. For other builds, tests are in progress. Please don't integrate, Wait for us 🙂

Thanks

Copy link
Member

@offamitkumar offamitkumar left a comment

Choose a reason for hiding this comment

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

{tier1, tier2} X {fast debug, slow debug, release} testing done for s390x. PR seems clean.
@matias9927 please include port for s390x from this commit:
offamitkumar@a582f32

Thanks

Comment on lines +647 to +652
__ get_cache_index_at_bcp(size, 1, index_size); // Load index.
// Get address of invokedynamic array
__ ld_ptr(cache, in_bytes(ConstantPoolCache::invokedynamic_entries_offset()), R27_constPoolCache);
// Scale the index to be the entry index * sizeof(ResolvedInvokeDynamicInfo)
__ sldi(size, size, log2i_exact(sizeof(ResolvedIndyEntry)));
__ add(cache, cache, size);
Copy link
Member

Choose a reason for hiding this comment

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

@reinrich Is there any specific reason, why you're not calling load_resolved_indy_entry() method here. On s390x build/changes are stable even with calling that helper method.

Copy link
Contributor

Choose a reason for hiding this comment

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

It should work if we move the addition of Array<ResolvedIndyEntry>::base_offset_in_bytes() into the other caller.

Copy link
Member

Choose a reason for hiding this comment

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

@reinrich Is there any specific reason, why you're not calling load_resolved_indy_entry() method here. On s390x build/changes are stable even with calling that helper method.

Looks like this was changed on x86_64 after I ported it to ppc. Thanks for making me aware of it.

@matias9927
Copy link
Contributor Author

/contributor add @offamitkumar

@openjdk
Copy link

openjdk bot commented Mar 28, 2023

@matias9927
Contributor Amit Kumar <amitkumar@openjdk.org> successfully added.

Copy link
Contributor

@RealLucy RealLucy left a comment

Choose a reason for hiding this comment

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

s390 changes look good.
Thank you, Amit, for working hard to get this done.

src/hotspot/cpu/s390/templateTable_s390.cpp Outdated Show resolved Hide resolved
src/hotspot/cpu/s390/templateTable_s390.cpp Outdated Show resolved Hide resolved
@matias9927
Copy link
Contributor Author

Thank you to all the reviewers for the detailed feedback, corrections, and improvements!
@theRealAph @dougxc @fparain @coleenp @RealFYang @RealLucy @turbanoff @TheRealMDoerr @calvinccheung

Also, thank you very much for completing the ports @reinrich, @DingliZhang, @zifeihan, and @offamitkumar!
/integrate

@openjdk
Copy link

openjdk bot commented Mar 28, 2023

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

  • 50a995f: 8304927: Update java/net/httpclient/BasicAuthTest.java to check basic auth over HTTP/2
  • ca745cb: 8291598: Matcher.appendReplacement should not create new StringBuilder instances
  • 1683a63: 8305098: [Backout] JDK-8303912 Clean up JavadocTokenizer
  • fab2357: 8304498: JShell does not switch to raw mode when there is no /bin/test
  • 1fc218c: 8303912: Clean up JavadocTokenizer
  • c1f5ca1: 8303623: Compiler should disallow non-standard UTF-8 string encodings
  • 695683b: 8304880: [PPC64] VerifyOops code in C1 doesn't work with ZGC
  • 83ce65e: 8305004: add @SPEC tags to langtools modules
  • 32ef452: 8304884: Update Bytecodes data to be mostly compile time constants
  • 927e674: 8300977: Retire java.io.ExpiringCache
  • ... and 166 more: https://git.openjdk.org/jdk/compare/55aa122462c34d8f4cafa58f4d1f2d900449c83e...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Mar 28, 2023

@matias9927 Pushed as commit 3fbbfd1.

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

@tstuefe
Copy link
Member

tstuefe commented Mar 31, 2023

This obviously breaks arm, since its implementation is missing. I opened https://bugs.openjdk.org/browse/JDK-8305387 to track this. This is unfortunate since it holds work on arm in other areas, in my case for #10907.

This change supports the following platforms: x86, aarch64, PPC, RISCV, and S390x

I wonder about the explicit exclusion of arm. Every other CPU seems to be taken care of, even those Oracle does not maintain. Just curious, was there a special reason for excluding arm?

@dougxc
Copy link
Member

dougxc commented Mar 31, 2023

It has also broken GraalVM Native Image. I'll open a JBS issue with a reproducer soon but here's hs-err from a slowdebug JDK build showing the problem:
hs_err_pid30379.log

@matias9927
Copy link
Contributor Author

This obviously breaks arm, since its implementation is missing. I opened https://bugs.openjdk.org/browse/JDK-8305387 to track this. This is unfortunate since it holds work on arm in other areas, in my case for #10907.

This change supports the following platforms: x86, aarch64, PPC, RISCV, and S390x

I wonder about the explicit exclusion of arm. Every other CPU seems to be taken care of, even those Oracle does not maintain. Just curious, was there a special reason for excluding arm?

There is no special reason ARM32 was excluded other than the fact no porter has picked it up yet. Fortunately I was able to get in contact with porters for the other platforms, but nobody took on the ARM port until now. Thank you for opening the issue!

@tstuefe
Copy link
Member

tstuefe commented Apr 3, 2023

This obviously breaks arm, since its implementation is missing. I opened https://bugs.openjdk.org/browse/JDK-8305387 to track this. This is unfortunate since it holds work on arm in other areas, in my case for #10907.

This change supports the following platforms: x86, aarch64, PPC, RISCV, and S390x

I wonder about the explicit exclusion of arm. Every other CPU seems to be taken care of, even those Oracle does not maintain. Just curious, was there a special reason for excluding arm?

There is no special reason ARM32 was excluded other than the fact no porter has picked it up yet. Fortunately I was able to get in contact with porters for the other platforms, but nobody took on the ARM port until now. Thank you for opening the issue!

I lack the time to do this atm; let's see if one of the porters can help. @bulasevich @snazarkin ?

@tstuefe
Copy link
Member

tstuefe commented Apr 3, 2023

I wonder about the explicit exclusion of arm. Every other CPU seems to be taken care of, even those Oracle does not maintain. Just curious, was there a special reason for excluding arm?

There is no special reason ARM32 was excluded other than the fact no porter has picked it up yet. Fortunately I was able to get in contact with porters for the other platforms, but nobody took on the ARM port until now. Thank you for opening the issue!

For future reference, we maintain a list of people working on ports: https://wiki.openjdk.org/display/HotSpot/Ports and we do have a mailing list for porters as well: porters-dev@openjdk.org . This makes it easier to find out who to contact.

Cheers, Thomas

Label resolved;

__ load_resolved_indy_entry(cache, index);
__ membar(MacroAssembler::AnyAny);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the AnyAny barrier used here?

Copy link
Member

Choose a reason for hiding this comment

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

Hi @sunny868, I'm working on removing these unnecessary barriers. RISC-V port uses more conservative barriers like this for some reasons (e.g.: [1][2][3]), we can just remove them.

  1. const int tags_offset = Array<u1>::base_offset_in_bytes();
    __ add(t0, x10, x13);
    __ la(t0, Address(t0, tags_offset));
    __ membar(MacroAssembler::AnyAny);
    __ lbu(t0, t0);
    __ membar(MacroAssembler::LoadLoad | MacroAssembler::LoadStore);
  2. // See if bytecode has already been quicked
    __ add(t0, x13, Array<u1>::base_offset_in_bytes());
    __ add(x11, t0, x9);
    __ membar(MacroAssembler::AnyAny);
    __ lbu(x11, x11);
    __ membar(MacroAssembler::LoadLoad | MacroAssembler::LoadStore);
  3. // See if bytecode has already been quicked
    __ add(t0, x13, Array<u1>::base_offset_in_bytes());
    __ add(x11, t0, x9);
    __ membar(MacroAssembler::AnyAny);
    __ lbu(x11, x11);
    __ membar(MacroAssembler::LoadLoad | MacroAssembler::LoadStore);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org