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

8265129: Add intrinsic support for JVM.getClassId #3470

Closed
wants to merge 16 commits into from

Conversation

@D-D-H
Copy link
Contributor

@D-D-H D-D-H commented Apr 13, 2021


Progress

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

Issue

  • JDK-8265129: Add intrinsic support for JVM.getClassId

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 3470

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

Using diff file

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

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Apr 13, 2021

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

Loading

@openjdk
Copy link

@openjdk openjdk bot commented Apr 13, 2021

@D-D-H The following label will be automatically applied to this pull request:

  • hotspot

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.

Loading

@openjdk openjdk bot added the hotspot label Apr 13, 2021
@D-D-H D-D-H marked this pull request as draft Apr 13, 2021
@openjdk openjdk bot added rfr and removed rfr labels Apr 13, 2021
@D-D-H D-D-H force-pushed the JDK-8265129 branch 3 times, most recently from f4efb7b to 81c300f Apr 17, 2021
@D-D-H D-D-H marked this pull request as ready for review Apr 21, 2021
@D-D-H
Copy link
Contributor Author

@D-D-H D-D-H commented Apr 21, 2021

/label remove hotspot

Loading

@openjdk openjdk bot added rfr and removed hotspot labels Apr 21, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Apr 21, 2021

@D-D-H
The hotspot label was successfully removed.

Loading

@D-D-H
Copy link
Contributor Author

@D-D-H D-D-H commented Apr 21, 2021

/label add hotspot-jfr,hotspot-compiler

Loading

@openjdk
Copy link

@openjdk openjdk bot commented Apr 21, 2021

@D-D-H
The hotspot-jfr label was successfully added.

The hotspot-compiler label was successfully added.

Loading

@D-D-H
Copy link
Contributor Author

@D-D-H D-D-H commented Apr 21, 2021

Hi,

Could I have a review of this change that adding intrinsic support for JVM.getClassId.

In the current patch, I didn't completely implement c1 intrinsic support on arm/ppc/s390 platform, but I believe it can be easily achieved,
but before that, I hope someone can do a preliminary review of this patch because I am not familiar with the implementation of jit.

JMH benchmark:

@State(Scope.Benchmark)
public class MyBenchmark {

    @Setup
    public void setup() {
        JVM.getJVM().createNativeJFR();
    }

    @Benchmark
    @Fork(value=1, jvmArgs = {"--add-exports", "jdk.jfr/jdk.jfr.internal=ALL-UNNAMED"})
    @Warmup(iterations = 5, time = 1)
    public void testIntrinsic(Blackhole bh) {
        bh.consume(JVM.getClassId(boolean.class));
        bh.consume(JVM.getClassId(void.class));
        bh.consume(JVM.getClassId(MyBenchmark.class));
    }

    @Benchmark
    @Fork(value=1, jvmArgs = {"--add-exports", "jdk.jfr/jdk.jfr.internal=ALL-UNNAMED"})
    @Warmup(iterations = 5, time = 1)
    public void testNoIntrinsic(Blackhole bh) {
        bh.consume(JVM.getClassIdNonIntrinsic(boolean.class));
        bh.consume(JVM.getClassIdNonIntrinsic(void.class));
        bh.consume(JVM.getClassIdNonIntrinsic(MyBenchmark.class));
    }

    @TearDown
    public void tearDown() {
      if (JVM.getClassIdNonIntrinsic(boolean.class) != JVM.getClassId(boolean.class)
          || JVM.getClassIdNonIntrinsic(void.class) != JVM.getClassId(void.class)
          || JVM.getClassIdNonIntrinsic(MyBenchmark.class) != JVM.getClassId(MyBenchmark.class)) {
          throw new RuntimeException();
      }
    }
}

result on x86_64:

Benchmark                           Mode  Samples          Score  Score error  Units
o.s.MyBenchmark.testIntrinsic      thrpt       20  195662934.056   566744.281  ops/s
o.s.MyBenchmark.testNoIntrinsic    thrpt       20    7997200.373     6424.038  ops/s

Loading

@mlbridge
Copy link

@mlbridge mlbridge bot commented Apr 21, 2021

Loading

@D-D-H
Copy link
Contributor Author

@D-D-H D-D-H commented Apr 27, 2021

Hi,
Could I have a review of this PR?
Thanks!

Loading

Copy link
Member

@kelthuzadx kelthuzadx left a comment

There are some comments rather than a real review that should be done by reviewers.

Loading

src/hotspot/share/c1/c1_LIRGenerator.cpp Outdated Show resolved Hide resolved
Loading
src/hotspot/share/c1/c1_LIRGenerator.cpp Outdated Show resolved Hide resolved
Loading
@@ -112,9 +112,15 @@ bool Jfr::on_start_flight_recording_option(const JavaVMOption** option, char* de
return JfrOptionSet::parse_start_flight_recording_option(option, delimiter);
}

#ifdef JFR_HAVE_INTRINSICS
JRT_LEAF(void, Jfr::trace_id_load_barrier(Klass * klass))

Choose a reason for hiding this comment

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

please declare as const, as in Jfr::trace_id_load_barrier(const Klass* klass);"

Loading

Copy link
Contributor Author

@D-D-H D-D-H May 21, 2021

Choose a reason for hiding this comment

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

fixed

Loading

@@ -60,9 +55,10 @@ class Jfr : AllStatic {
static bool is_excluded(Thread* thread);
static void include_thread(Thread* thread);

#ifdef JFR_HAVE_INTRINSICS
// get_class_id intrinsic support
static void trace_id_load_barrier(Klass* klass);

Choose a reason for hiding this comment

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

I think we can make this general, because it is not necessarily specialized for the intrinsic use. Can we rename this to "get_class_id(const Klass* klass): instead? Then we can remove the comment // get_class_id intrinsic support., thanks

Loading

Choose a reason for hiding this comment

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

Hmm, perhaps that was not such a good idea after all - it would require that you have tested for tagging at the call site. But "get_class_id_intrinsic(const Klass* klass):" might perhaps be ok.

Loading

Copy link
Contributor Author

@D-D-H D-D-H May 21, 2021

Choose a reason for hiding this comment

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

Good idea, updated.

Loading

@@ -29,7 +29,9 @@
#include "compiler/compileBroker.hpp"
#include "compiler/compileLog.hpp"
#include "gc/shared/barrierSet.hpp"
#if INCLUDE_JFR

Choose a reason for hiding this comment

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

It is custom to put the conditional includes at the end, not inlined (please see other files for conditional includes). Thanks.

Loading

Copy link
Contributor Author

@D-D-H D-D-H May 21, 2021

Choose a reason for hiding this comment

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

fixed

Loading

@@ -60,9 +55,10 @@ class Jfr : AllStatic {
static bool is_excluded(Thread* thread);
static void include_thread(Thread* thread);

#ifdef JFR_HAVE_INTRINSICS
// get_class_id intrinsic support

Choose a reason for hiding this comment

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

"Klass" needs a fwd declaration.

Loading

Copy link
Contributor Author

@D-D-H D-D-H May 21, 2021

Choose a reason for hiding this comment

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

added

Loading

Copy link

@mgronlun mgronlun left a comment

Thanks Denghui, good work.

Markus

Loading

@openjdk
Copy link

@openjdk openjdk bot commented May 21, 2021

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

8265129: Add intrinsic support for JVM.getClassId

Reviewed-by: kvn, mgronlun

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 1 new commit pushed to the master branch:

  • b4d4884: 8267126: javadoc should show "line and caret" for diagnostics.

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.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@vnkozlov, @mgronlun) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

Loading

@openjdk openjdk bot added the ready label May 21, 2021
Copy link
Contributor

@vnkozlov vnkozlov left a comment

Good.
What testing you did?

Loading

@D-D-H
Copy link
Contributor Author

@D-D-H D-D-H commented May 22, 2021

Good.
What testing you did?

fastdebug on Linux x86_64
jtreg hotspot/jtreg/compiler jdk/jdk/jfr/

Loading

@D-D-H
Copy link
Contributor Author

@D-D-H D-D-H commented May 22, 2021

/integrate

Loading

@openjdk openjdk bot added the sponsor label May 22, 2021
@openjdk
Copy link

@openjdk openjdk bot commented May 22, 2021

@D-D-H
Your change (at version f99186b) is now ready to be sponsored by a Committer.

Loading

@openjdk openjdk bot added ready and removed ready labels May 22, 2021
@vnkozlov
Copy link
Contributor

@vnkozlov vnkozlov commented May 24, 2021

Passed tier1-3 and jdk/jfr in my testing.

Loading

@vnkozlov
Copy link
Contributor

@vnkozlov vnkozlov commented May 24, 2021

/sponsor

Loading

@openjdk
Copy link

@openjdk openjdk bot commented May 24, 2021

@vnkozlov @D-D-H Unable to acquire the integration lock; aborting sponsored integration. The error has been logged and will be investigated.

Loading

@vnkozlov
Copy link
Contributor

@vnkozlov vnkozlov commented May 24, 2021

@D-D-H please update change to latest sources.

Loading

@openjdk openjdk bot removed the sponsor label May 25, 2021
@D-D-H
Copy link
Contributor Author

@D-D-H D-D-H commented May 25, 2021

@D-D-H please update change to latest sources.

@vnkozlov Updated, Thank you.

Loading

@D-D-H
Copy link
Contributor Author

@D-D-H D-D-H commented May 25, 2021

/integrate

Loading

@openjdk openjdk bot added the sponsor label May 25, 2021
@openjdk
Copy link

@openjdk openjdk bot commented May 25, 2021

@D-D-H
Your change (at version 82a0768) is now ready to be sponsored by a Committer.

Loading

@vnkozlov
Copy link
Contributor

@vnkozlov vnkozlov commented May 25, 2021

/sponsor

Loading

@openjdk
Copy link

@openjdk openjdk bot commented May 25, 2021

@vnkozlov @D-D-H Since your change was applied there have been 2 commits pushed to the master branch:

  • 123cdd1: 8264973: AArch64: Optimize vector max/min/add reduction of two integers with NEON pairwise instructions
  • b4d4884: 8267126: javadoc should show "line and caret" for diagnostics.

Your commit was automatically rebased without conflicts.

Pushed as commit 2e8812d.

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

Loading

@D-D-H D-D-H deleted the JDK-8265129 branch May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
7 participants