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

8265135: Reduce work initializing VarForms #3472

Closed
wants to merge 5 commits into from

Conversation

cl4es
Copy link
Member

@cl4es cl4es commented Apr 13, 2021

This patch reduces work done initializing VarForms - mostly observed when loading each VarHandle implementation class.

  • Lazily resolve MemberNames.
  • Streamline MethodType creation. This reduces the number of MethodTypes created.

Net effect is a reduction in bytecode executed per VH class by 50-60%.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3472/head:pull/3472
$ git checkout pull/3472

Update a local copy of the PR:
$ git checkout pull/3472
$ git pull https://git.openjdk.java.net/jdk pull/3472/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 3472

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/3472.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 13, 2021

👋 Welcome back redestad! 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 openjdk bot added the rfr Pull request is ready for review label Apr 13, 2021
@openjdk
Copy link

openjdk bot commented Apr 13, 2021

@cl4es The following label will be automatically applied to this pull request:

  • core-libs

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the core-libs core-libs-dev@openjdk.org label Apr 13, 2021
@mlbridge
Copy link

mlbridge bot commented Apr 13, 2021

Webrevs

Copy link
Member

@PaulSandoz PaulSandoz left a comment

Choose a reason for hiding this comment

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

Very nice.

Comment on lines 128 to 130
} catch (NoSuchMethodException | IllegalAccessException e) {
throw new UnsupportedOperationException();
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
} catch (NoSuchMethodException | IllegalAccessException e) {
throw new UnsupportedOperationException();
}
} catch (ReflectiveOperationException e) {
throw newInternalError("Failed resolving VarHandle member name", ex);
}

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for reviewing!

Is there's a way to provoke this exception through the public API? If not then the suggested behavior change seems reasonable.

Copy link
Member

Choose a reason for hiding this comment

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

No, since VarHandles are not publicly extensible, the exception should not occur unless something has gone very wrong (the correspondence between access mode and implementing method is broken).

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately the change to InternalError breaks a number of tests, since the UOE does bubble up through the public API. I also found a few failing tests I had overlooked due VarHandle.isAccessModeSupported throwing rather than returning false, so I had to slightly rework the patch.

Copy link
Member

Choose a reason for hiding this comment

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

Oops, my bad. I got confused and forgot that VH implementations can avoid implementing access mode methods that would just throw UOE. This slightly complicates lazily resolution.

We don't cache the result of a failed method resolution, which would require a non-null sentinel value, probably does not matter.

Using resolveOrNull seems a better fit rather than catching and dropping ROE, less work performed too.

@openjdk
Copy link

openjdk bot commented Apr 13, 2021

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

8265135: Reduce work initializing VarForms

Reviewed-by: psandoz, mchung

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

  • e167577: 8265078: jpackage tests on Windows leave large temp files
  • 05f851e: 8265236: ProblemList java/foreign/TestUpcall.java on macosx-aarch64
  • d1b28e7: 8265231: (fc) ReadDirect and WriteDirect tests fail after fix for JDK-8264821
  • 57f86a0: 8265235: ProblemList java/foreign/TestIntrinsics.java on macosx-aarch64
  • 4c83d24: 8058176: [mlvm] tests should not allow code cache exhaustion
  • 9406744: 8264976: Minor numeric bug in AbstractSplittableWithBrineGenerator.makeSplitsSpliterator
  • 80026d8: 8265174: Update Class.getDeclaredMethods to discuss synthetic and bridge methods
  • ffb3771: 8265019: Update tests for additional TestNG test permissions
  • 7e4cd48: 8264821: DirectIOTest fails on a system with large block size
  • 0afcbd4: 8264412: AArch64: CPU description should refer DMI
  • ... and 41 more: https://git.openjdk.java.net/jdk/compare/e604320bbde3328b725a8ddbcc713f9847d2e867...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 Apr 13, 2021
Copy link
Member

@mlchung mlchung 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. I also agree with Paul's suggestion to throw InternalError for errors that should never happen.

MethodType type = methodType_table[value.at.ordinal()].insertParameterTypes(0, VarHandle.class);
return memberName_table[mode]
= MethodHandles.Lookup.IMPL_LOOKUP
.resolveOrFail(REF_invokeStatic, implClass, methodName, type);
Copy link
Member

@mlchung mlchung Apr 14, 2021

Choose a reason for hiding this comment

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

An alternative way can be:

final MemberName getMemberName(int mode) {
     MemberName mn = getMemberNameOrNull(mode);
     if (mn == null) {
           throw new UnsupportedOperationException();
     }
 }       

This way resolveMemberName(int mode) can simply call IMPL_LOOKUP.resolveOrNull.

@cl4es
Copy link
Member Author

cl4es commented Apr 19, 2021

Thanks for reviewing, Mandy and Paul

/integrate

@openjdk openjdk bot closed this Apr 19, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Apr 19, 2021
@openjdk
Copy link

openjdk bot commented Apr 19, 2021

@cl4es Since your change was applied there have been 123 commits pushed to the master branch:

  • d9e40dd: 8199407: Skip Rebuild Remset Phase if there are no rebuild candidates
  • 8dbf7aa: 8241306: Add SignatureMethodParameterSpec subclass for RSASSA-PSS params
  • b14e0ee: 8265371: Change to Visual Studio 2019 16.9.3 for building on Windows at Oracle
  • c887148: 8265079: Implement VarHandle invoker caching
  • b64a3fb: 8265325: Optimize StubRoutines::dpow() for Math.pow(x, 0.5)
  • d1c8c9e: 8197811: Test java/awt/Choice/PopupPosTest/PopupPosTest.java fails on Windows
  • 7d01c98: 8265414: Variable assigned but not used in G1FreeHumongousRegionClosure
  • d9e19f1: 8265226: (dc) API note in DatagramChannel.open should link to StandardProtocolFamily.UNIX
  • 49b9e68: 8262165: NMT report should state how many callsites had been skipped
  • e390e55: 8265066: Split ReservedSpace constructor to avoid default parameter
  • ... and 113 more: https://git.openjdk.java.net/jdk/compare/e604320bbde3328b725a8ddbcc713f9847d2e867...master

Your commit was automatically rebased without conflicts.

Pushed as commit 5303ccb.

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

@cl4es cl4es deleted the varform_startup branch April 19, 2021 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants