Skip to content

Conversation

@chhagedorn
Copy link
Member

@chhagedorn chhagedorn commented Aug 6, 2024

It is currently not possible to write IR tests with @Stable annotations because one need to somehow add the IR test classes to the boot classpath. This patch provides support to write such IR tests. I've added a section to the README to provide guidance on how this can be done.

This is motivated by #19635.

I've tested this patch by taking the current patch of #19635, dropping the RestrictStable flag and modifying the tests to work with the new IR framework feature:

TestFramework testFramework = new TestFramework();
testFramework
        .addFlags("-XX:-TieredCompilation",
                  "-XX:+UseParallelGC")
        .addTestClassesToBootClassPath()
        .start();

Thanks,
Christian


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-8337876: [IR Framework] Add support for IR tests with @Stable (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 20477

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 6, 2024

👋 Welcome back chagedorn! 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.

@chhagedorn
Copy link
Member Author

@shipilev @liach Since you've already looked at this idea in #19635, I'm kindly asking you to also have a look at this PR, thanks!

@openjdk
Copy link

openjdk bot commented Aug 6, 2024

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

8337876: [IR Framework] Add support for IR tests with @Stable

Reviewed-by: shade, kvn

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

  • 55c5097: 8337331: crash: pinned virtual thread will lead to jvm crash when running with the javaagent option
  • 9f08a01: 8338010: WB_IsFrameDeoptimized miss ResourceMark
  • e7a0b5b: 8334780: Crash: assert(h_array_list.not_null()) failed: invariant
  • bfb75b9: 8336926: jdk/internal/util/ReferencedKeyTest.java can fail with ConcurrentModificationException
  • 53c9f03: 8336849: Remove .llvm_addrsig section from JDK/VM static libraries (.a files)
  • 9695f09: 8337683: Fix -Wconversion problem with arrayOop.hpp
  • 78773b1: 8338015: Fix "Java Java" typo in package info file of java.lang.classfile
  • 6a9a867: 8337994: [REDO] Native memory leak when not recording any events
  • 4b740d8: 8225209: jdk/jfr/event/compiler/TestCodeSweeper.java fails
  • ddbd7a7: 8337320: Update ProblemList.txt with tests known to fail on XWayland
  • ... and 29 more: https://git.openjdk.org/jdk/compare/f92c60e1a9968620cbc92b52aa546b57c09da487...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 rfr Pull request is ready for review label Aug 6, 2024
@openjdk
Copy link

openjdk bot commented Aug 6, 2024

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

  • hotspot-compiler

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.

@mlbridge
Copy link

mlbridge bot commented Aug 6, 2024

Webrevs

Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

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

Looks okay, I just think we don't need to mention @Stable.

Comment on lines 160 to 161
### 2.5 IR Tests with `@Stable` annotation
To run tests with `@Stable` annotations, one need to add the test classes to the boot classpath. This can easily be achieved by calling `TestFramework.addTestClassesToBootClassPath()` on the test framework object:
Copy link
Member

Choose a reason for hiding this comment

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

I think mentioning @Stable here is overly specific. This guidance applies to any code that expects to be run in privileged mode, whether it is @Stable, @Contended, @ReservedStackAccess, etc. I say it should be e.g. "2.5 IR Tests With Privileged Classes" or some such.

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 the quick review! You're right, that's too specific. I've pushed an update according to your suggestion.


/**
* Add test classes to boot classpath. This adds all classes found on path {@link jdk.test.lib.Utils#TEST_CLASSES}
* to the boot classpath with "-Xbootclasspath/a". This is useful when trying to run tests with @Stable annotations.
Copy link
Member

Choose a reason for hiding this comment

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

Again, @Stable is overly specific here. This is "just" about the privileged code.

cmds.add("-Xbootclasspath/a:.");
String bootClassPath = "-Xbootclasspath/a:.";
if (testClassesOnBootClassPath) {
// Add test classes themselves to boot classpath. This is required, for example, for IR tests with @Stable.
Copy link
Member

Choose a reason for hiding this comment

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

Here too, drop the mention of @Stable?

Comment on lines 106 to 107
// Ignore CompileThreshold and CompileCommand flags which have an impact on the profiling information.
List<String> jtregVMFlags = Arrays.stream(Utils.getTestJavaOpts()).filter(s -> !s.contains("CompileThreshold")).toList();
Copy link
Member

Choose a reason for hiding this comment

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

This hunk seems unnecessary? I would like to have IR Framework patch that is easily backportable and does not contain additional, non-essential hunks :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair point, could be done separately, dropped :)

Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

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

Looks fine, except one nit. I think we should maybe do a simple test to confirm this works on both Linux and Windows?

String bootClassPath = "-Xbootclasspath/a:.";
if (testClassesOnBootClassPath) {
// Add test classes themselves to boot classpath to make them privileged.
bootClassPath += ":" + Utils.TEST_CLASSES;
Copy link
Member

Choose a reason for hiding this comment

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

I think : is not portable, and should instead be File.pathSeparator?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch! Fixed.

Copy link
Member Author

@chhagedorn chhagedorn left a comment

Choose a reason for hiding this comment

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

Sorry for the delay. That is definitely a good idea to add a simple test to check the new feature. I've added such a test with @Stable that fails when not adding the test class to the boot classpath and works otherwise.

String bootClassPath = "-Xbootclasspath/a:.";
if (testClassesOnBootClassPath) {
// Add test classes themselves to boot classpath to make them privileged.
bootClassPath += ":" + Utils.TEST_CLASSES;
Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch! Fixed.

Copy link
Member

@shipilev shipilev left a comment

Choose a reason for hiding this comment

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

OK, thanks.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Aug 8, 2024
@chhagedorn
Copy link
Member Author

Thanks Aleksey for your review!

@shipilev
Copy link
Member

shipilev commented Aug 8, 2024

Can/should we get some more reviews here? I would like to get the @Stable PR, which depends on it, moving :)

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

Good.

@chhagedorn
Copy link
Member Author

Thanks Vladimir for your review!

/integrate

@openjdk
Copy link

openjdk bot commented Aug 9, 2024

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

  • 00aac40: 8338058: map_or_reserve_memory_aligned Windows enhance remap assertion
  • 9ab8c6b: 8335130: The test "javax/swing/plaf/synth/ComponentsOrientationSupport/5033822/bug5033822.java" fails because the background color of the tabs is displayed incorrectly.
  • 0c1e911: 8338019: Fix simple -Wzero-as-null-pointer-constant warnings in riscv code
  • 55c5097: 8337331: crash: pinned virtual thread will lead to jvm crash when running with the javaagent option
  • 9f08a01: 8338010: WB_IsFrameDeoptimized miss ResourceMark
  • e7a0b5b: 8334780: Crash: assert(h_array_list.not_null()) failed: invariant
  • bfb75b9: 8336926: jdk/internal/util/ReferencedKeyTest.java can fail with ConcurrentModificationException
  • 53c9f03: 8336849: Remove .llvm_addrsig section from JDK/VM static libraries (.a files)
  • 9695f09: 8337683: Fix -Wconversion problem with arrayOop.hpp
  • 78773b1: 8338015: Fix "Java Java" typo in package info file of java.lang.classfile
  • ... and 32 more: https://git.openjdk.org/jdk/compare/f92c60e1a9968620cbc92b52aa546b57c09da487...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Aug 9, 2024

@chhagedorn Pushed as commit c01f53a.

💡 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

hotspot-compiler [email protected] integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

3 participants