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

8346781: [JVMCI] Limit ServiceLoader to class initializers #22869

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dougxc
Copy link
Member

@dougxc dougxc commented Dec 23, 2024

In the context of libgraal, the current use of ServiceLoader in JVMCI is problematic as libgraal does all class loading at image build time. There are static fields such as JVMCIServiceLocator.cachedLocators that need to be initialized via reflection when building libgraal.

This PR removes the need for such reflection by moving all use of ServiceLoader in JVMCI into <clinit> methods. These methods are executed when building libgraal. It also removes a few other public methods and fields that are no longer used by Graal. Given that JVMCI is still experimental and only has qualified exports to Graal, I don't think this needs a CSR.


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-8346781: [JVMCI] Limit ServiceLoader to class initializers (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22869

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 23, 2024

👋 Welcome back dnsimon! 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 Dec 23, 2024

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

8346781: [JVMCI] Limit ServiceLoader to class initializers

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

  • 62a4544: 8205051: Poor Performance with UseNUMA when cpu and memory nodes are misaligned
  • 68c6623: 8345840: Add missing TLS handshake messages to SSLHandshake.java

Please see this link for an up-to-date comparison between the source branch of this pull request and 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 Dec 23, 2024

@dougxc 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 Dec 23, 2024
@@ -107,7 +107,7 @@ private static synchronized void remove(Cleaner cl) {
/**
* Remove the cleaners whose referents have become weakly reachable.
*/
static void clean() {
public static void clean() {
Copy link
Member Author

Choose a reason for hiding this comment

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

Making this public avoids the need for a method substitution.

@dougxc dougxc marked this pull request as ready for review December 23, 2024 18:02
@openjdk openjdk bot added the rfr Pull request is ready for review label Dec 23, 2024
@mlbridge
Copy link

mlbridge bot commented Dec 23, 2024

Webrevs

* from (being compiled into) the library. Such code must be directly guarded by an {@code if}
* statement on this field - the guard cannot be behind a method call.
*/
public static final boolean IS_BUILDING_NATIVE_IMAGE = Boolean.parseBoolean(VM.getSavedProperty("jdk.vm.ci.services.aot"));
Copy link
Member Author

Choose a reason for hiding this comment

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

This field is no longer used in JVMCI and I will remove its usages in Graal.

* @throws SecurityException if a security manager is present and it denies <tt>
* {@link RuntimePermission}("jvmci")</tt>
*/
public static <S> Iterable<S> load(Class<S> service) {
Copy link
Member Author

Choose a reason for hiding this comment

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

There are no usages of this method in JVMCI or Graal.

* @throws SecurityException if a security manager is present and it denies <tt>
* {@link RuntimePermission}("jvmci")</tt>
*/
public static <S> S loadSingle(Class<S> service, boolean required) {
Copy link
Member Author

Choose a reason for hiding this comment

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

There are no usages of this method in JVMCI or Graal.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 23, 2024
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 ready Pull request is ready to be integrated rfr Pull request is ready for review
Development

Successfully merging this pull request may close these issues.

2 participants