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

8330153: C2: dump barrier information for all Mach nodes #18754

Closed

Conversation

robcasloz
Copy link
Contributor

@robcasloz robcasloz commented Apr 12, 2024

This debug-only changeset ensures that GC-specific barrier information is dumped (via BarrierSetC2::dump_barrier_data()) for all C2 Mach nodes, not just MachType ones. This makes it possible to e.g. write IR tests that verify barrier properties of CompareAndSwap/WeakCompareAndSwap Mach implementations, which do not inherit from MachTypeNode. An example of such a test can be found here.

The following program illustrates the effect of the change:

import java.lang.invoke.VarHandle;
import java.lang.invoke.MethodHandles;

public class Example {
    static class Outer {
        Object f;
    }

    static final VarHandle fVarHandle;
    static {
        MethodHandles.Lookup l = MethodHandles.lookup();
        try {
            fVarHandle = l.findVarHandle(Outer.class, "f", Object.class);
        } catch (Exception e) {
            throw new Error(e);
        }
    }

    static boolean testCompareAndSwap(Outer o, Object oldVal, Object newVal) {
        return fVarHandle.compareAndSet(o, oldVal, newVal);
    }

    public static void main(String[] args) {
        for (int i = 0; i < 10_000; i++) {
            Outer o = new Outer();
            Object oldVal = new Object();
            o.f = oldVal;
            Object newVal = new Object();
            testCompareAndSwap(o, oldVal, newVal);
        }
    }
}

Before this changeset, issuing this command:

$ java -Xbatch -XX:+UseZGC -XX:+ZGenerational -XX:CompileOnly=Example::testCompareAndSwap -XX:CompileCommand=PrintIdealPhase,Example::testCompareAndSwap,FINAL_CODE Example.java | grep zCompareAndSwapP

gives the following dump:

 R10     37  zCompareAndSwapP  === 28 35 38 54 22 41  [[ 40 42 36 27 56 25 ]]  !jvms: VarHandleReferences$FieldInstanceReadWrite::compareAndSet @ bci:44 (line 180) VarHandleGuards::guard_LLL_Z @ bci:50 (line 68) Example::testCompareAndSwap @ bci:6 (line 20)

After this changeset, we get:

 R10     37  zCompareAndSwapP  === 28 35 38 54 22 41  [[ 40 42 36 27 56 25 ]]  barrier(strong )  !jvms: VarHandleReferences$FieldInstanceReadWrite::compareAndSet @ bci:44 (line 180) VarHandleGuards::guard_LLL_Z @ bci:50 (line 68) Example::testCompareAndSwap @ bci:6 (line 20)

Note the additional barrier(strong ) field in the second dump.

Testing: tier1-3 (windows-x64, linux-x64, linux-aarch64, and macosx-x64; release and debug mode).


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-8330153: C2: dump barrier information for all Mach nodes (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 18754

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

Using diff file

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

Webrev

Link to Webrev Comment

…to include CompareAndSwap/WeakCompareAndSwap matches
@bridgekeeper
Copy link

bridgekeeper bot commented Apr 12, 2024

👋 Welcome back rcastanedalo! 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 Apr 12, 2024

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

8330153: C2: dump barrier information for all Mach nodes

Reviewed-by: kvn, thartmann

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

  • 58ad399: 8330821: Rename UnsafeCopyMemory
  • 1d52234: 8330704: Clean up non-standard use of /** comments in some langtools tests
  • 83c74d7: 8329717: Missing @since tags in elements in DocumentationTool and Taglet
  • 0b9350e: 8322992: Javac fails with StackOverflowError when compiling deeply nested synchronized blocks
  • 20be5e0: 8314846: Do not store Klass::_secondary_super_cache in CDS archive
  • 7e421ce: 8330585: Refactor/rename forwardee handling
  • 3e65d90: 8330820: Remove remnants of operator_new.cpp in build system
  • 936a47d: 8330607: Deprecate -XX:+UseEmptySlotsInSupers
  • ee7b2e9: 8330051: Small ObjectMonitor spinning code cleanups
  • 3e185c7: 8330154: Serial: Remove TenuredSpace::update_for_block
  • ... and 133 more: https://git.openjdk.org/jdk/compare/b04b3047ff5c5526bdf47925210e2a35ca191e6e...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
Copy link

openjdk bot commented Apr 12, 2024

@robcasloz 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.

@openjdk openjdk bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Apr 12, 2024
@robcasloz robcasloz marked this pull request as ready for review April 12, 2024 13:14
@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 12, 2024
@mlbridge
Copy link

mlbridge bot commented Apr 12, 2024

Webrevs

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.

Can you add a simple IR test to show case it?

@robcasloz
Copy link
Contributor Author

Can you add a simple IR test to show case it?

Done, the new test fails before this change and passes afterwards.

Copy link
Member

@TobiHartmann TobiHartmann 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 Apr 22, 2024
@robcasloz
Copy link
Contributor Author

Thanks for reviewing, Tobias!

@vnkozlov: I added a simple IR test as requested, could I get a second review? Thanks!

@vnkozlov
Copy link
Contributor

I don't see GHA testing for this repo. Did you enabled it?

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.

@robcasloz
Copy link
Contributor Author

I don't see GHA testing for this repo. Did you enabled it?

Interesting. GHA testing is enabled for the repo (see https://github.com/robcasloz/jdk/actions), but it seems to run only for some branches, see e.g. my recent PR #18108 from the same repo. I will investigate.

@robcasloz
Copy link
Contributor Author

Thanks for reviewing, Vladimir!

@robcasloz
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Apr 23, 2024

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

  • 58ad399: 8330821: Rename UnsafeCopyMemory
  • 1d52234: 8330704: Clean up non-standard use of /** comments in some langtools tests
  • 83c74d7: 8329717: Missing @since tags in elements in DocumentationTool and Taglet
  • 0b9350e: 8322992: Javac fails with StackOverflowError when compiling deeply nested synchronized blocks
  • 20be5e0: 8314846: Do not store Klass::_secondary_super_cache in CDS archive
  • 7e421ce: 8330585: Refactor/rename forwardee handling
  • 3e65d90: 8330820: Remove remnants of operator_new.cpp in build system
  • 936a47d: 8330607: Deprecate -XX:+UseEmptySlotsInSupers
  • ee7b2e9: 8330051: Small ObjectMonitor spinning code cleanups
  • 3e185c7: 8330154: Serial: Remove TenuredSpace::update_for_block
  • ... and 133 more: https://git.openjdk.org/jdk/compare/b04b3047ff5c5526bdf47925210e2a35ca191e6e...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Apr 23, 2024

@robcasloz Pushed as commit 57ebd04.

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

Successfully merging this pull request may close these issues.

3 participants