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

8300255: Introduce interface for GC oop verification in the assembler #12443

Closed
wants to merge 3 commits into from

Conversation

fisk
Copy link
Contributor

@fisk fisk commented Feb 6, 2023

In the assembly code, there is some generic oop verification code. Said verification may or may not fit a particular GC. In particular, it has not worked well for ZGC for a while, and there is an if (UseZGC). This enhancement aims at generalizing this code, such that a collector can have its own oop verification policy.


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-8300255: Introduce interface for GC oop verification in the assembler

Reviewers

Contributors

  • Martin Doerr <mdoerr@openjdk.org>
  • Axel Boldt-Christmas <aboldtch@openjdk.org>
  • Yadong Wang <yadongwang@openjdk.org>

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 12443

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

Using diff file

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

@fisk
Copy link
Contributor Author

fisk commented Feb 6, 2023

/contributor add @TheRealMDoerr

@fisk
Copy link
Contributor Author

fisk commented Feb 6, 2023

/contributor add @xmas92

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 6, 2023

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

@fisk
Copy link
Contributor Author

fisk commented Feb 6, 2023

/contributor add @yadongw

@openjdk openjdk bot added the rfr Pull request is ready for review label Feb 6, 2023
@fisk
Copy link
Contributor Author

fisk commented Feb 6, 2023

PPC code contributed by @TheRealMDoerr and RISC-V code contributed by @yadongw. Could you please check that it works on your machines?

@openjdk
Copy link

openjdk bot commented Feb 6, 2023

@fisk
Contributor Martin Doerr <mdoerr@openjdk.org> successfully added.

@openjdk
Copy link

openjdk bot commented Feb 6, 2023

@fisk
Contributor Axel Boldt-Christmas <aboldtch@openjdk.org> successfully added.

@openjdk
Copy link

openjdk bot commented Feb 6, 2023

@fisk
Contributor Yadong Wang <yadongwang@openjdk.org> successfully added.

@openjdk
Copy link

openjdk bot commented Feb 6, 2023

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

@openjdk openjdk bot added the hotspot hotspot-dev@openjdk.org label Feb 6, 2023
@mlbridge
Copy link

mlbridge bot commented Feb 6, 2023

Webrevs

@TheRealMDoerr
Copy link
Contributor

PPC code contributed by @TheRealMDoerr and RISC-V code contributed by @yadongw. Could you please check that it works on your machines?

The default version of check_oop doesn't work for ZGC. I suggest to exclude the PPC64 parts here and ship them with the generational ZGC PR. That will reduce effort. Does that make sense?

@fisk
Copy link
Contributor Author

fisk commented Feb 7, 2023

PPC code contributed by @TheRealMDoerr and RISC-V code contributed by @yadongw. Could you please check that it works on your machines?

The default version of check_oop doesn't work for ZGC. I suggest to exclude the PPC64 parts here and ship them with the generational ZGC PR. That will reduce effort. Does that make sense?

Hmm. Looking at the changes of this patch, we used to call __ verify_oop, but now we call check_oop on the barrier set assembler, which in turn has a single implementation which calls __ verify_oop. It seems like this patch currently does not change the behaviour at all to what happened before? While I am perfectly fine removing the PPC changes, I don't think I understand what behaviour this patch changes for PPC.

Copy link
Member

@RealFYang RealFYang left a comment

Choose a reason for hiding this comment

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

Hi, seems we need two extra small changes to build on linux-riscv. Thanks.

@@ -99,6 +99,8 @@ class ZBarrierSetAssembler : public ZBarrierSetAssemblerBase {
void generate_c2_load_barrier_stub(MacroAssembler* masm,
ZLoadBarrierStubC2* stub) const;
#endif // COMPILER2

virtual void check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error);
Copy link
Member

Choose a reason for hiding this comment

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

Need to remove 'virtual' here.


#define __ masm->

void BarrierSetAssembler::check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error) {
Copy link
Member

Choose a reason for hiding this comment

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

Should be 'ZBarrierSetAssembler::check_oop' here.

@TheRealMDoerr
Copy link
Contributor

PPC code contributed by @TheRealMDoerr and RISC-V code contributed by @yadongw. Could you please check that it works on your machines?

The default version of check_oop doesn't work for ZGC. I suggest to exclude the PPC64 parts here and ship them with the generational ZGC PR. That will reduce effort. Does that make sense?

Hmm. Looking at the changes of this patch, we used to call __ verify_oop, but now we call check_oop on the barrier set assembler, which in turn has a single implementation which calls __ verify_oop. It seems like this patch currently does not change the behaviour at all to what happened before? While I am perfectly fine removing the PPC changes, I don't think I understand what behaviour this patch changes for PPC.

You're right. VerifyOops is already broken with ZGC on PPC64. You can keep the PPC64 parts as they are. The generational ZGC code will fix the problem. So, I'm fine with this PR.

@fisk
Copy link
Contributor Author

fisk commented Feb 7, 2023

PPC code contributed by @TheRealMDoerr and RISC-V code contributed by @yadongw. Could you please check that it works on your machines?

The default version of check_oop doesn't work for ZGC. I suggest to exclude the PPC64 parts here and ship them with the generational ZGC PR. That will reduce effort. Does that make sense?

Hmm. Looking at the changes of this patch, we used to call __ verify_oop, but now we call check_oop on the barrier set assembler, which in turn has a single implementation which calls __ verify_oop. It seems like this patch currently does not change the behaviour at all to what happened before? While I am perfectly fine removing the PPC changes, I don't think I understand what behaviour this patch changes for PPC.

You're right. VerifyOops is already broken with ZGC on PPC64. You can keep the PPC64 parts as they are. The generational ZGC code will fix the problem. So, I'm fine with this PR.

Okay great - thanks for checking!

@fisk
Copy link
Contributor Author

fisk commented Feb 7, 2023

Hi, seems we need two extra small changes to build on linux-riscv. Thanks.

Thanks for having a look! Hopefully fixed in the latest commit.

@RealFYang
Copy link
Member

RealFYang commented Feb 8, 2023

@fisk : Hi, I think we should also add following changes for riscv to make it work:

diff --git a/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp b/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp
index ed53fbf22c8..662de44de29 100644
--- a/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp
+++ b/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp
@@ -316,8 +316,7 @@ void BarrierSetAssembler::check_oop(MacroAssembler* masm, Register obj, Register
   __ mv(tmp2, (intptr_t) Universe::verify_oop_bits());

   // Compare tmp1 and tmp2.
-  __ xorr(tmp1, tmp1, tmp2);
-  __ bnez(tmp1, error);
+  __ bne(tmp1, tmp2, error);

   // Make sure klass is 'reasonable', which is not zero.
   __ load_klass(obj, obj, tmp1); // get klass
diff --git a/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp b/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp
index 0741869ddaf..1ebfb8f9e23 100644
--- a/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp
+++ b/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp
@@ -449,10 +449,10 @@ void ZBarrierSetAssembler::generate_c1_load_barrier_runtime_stub(StubAssembler*

 void ZBarrierSetAssembler::check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error) {
   // Check if mask is good.
-  // verifies that ZAddressBadMask & x10 == 0
-  __ ld(c_rarg3, Address(xthread, ZThreadLocalData::address_bad_mask_offset()));
-  __ andr(c_rarg2, x10, c_rarg3);
-  __ bnez(c_rarg2, error);
+  // verifies that ZAddressBadMask & obj == 0
+  __ ld(tmp2, Address(xthread, ZThreadLocalData::address_bad_mask_offset()));
+  __ andr(tmp1, obj, tmp2);
+  __ bnez(tmp1, error);

   BarrierSetAssembler::check_oop(masm, obj, tmp1, tmp2, error);
 }

@fisk
Copy link
Contributor Author

fisk commented Feb 8, 2023

@fisk : Hi, I think we should also add following changes for riscv to make it work:

diff --git a/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp b/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp
index ed53fbf22c8..662de44de29 100644
--- a/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp
+++ b/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp
@@ -316,8 +316,7 @@ void BarrierSetAssembler::check_oop(MacroAssembler* masm, Register obj, Register
   __ mv(tmp2, (intptr_t) Universe::verify_oop_bits());

   // Compare tmp1 and tmp2.
-  __ xorr(tmp1, tmp1, tmp2);
-  __ bnez(tmp1, error);
+  __ bne(tmp1, tmp2, error);

   // Make sure klass is 'reasonable', which is not zero.
   __ load_klass(obj, obj, tmp1); // get klass
diff --git a/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp b/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp
index 0741869ddaf..1ebfb8f9e23 100644
--- a/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp
+++ b/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp
@@ -449,10 +449,10 @@ void ZBarrierSetAssembler::generate_c1_load_barrier_runtime_stub(StubAssembler*

 void ZBarrierSetAssembler::check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error) {
   // Check if mask is good.
-  // verifies that ZAddressBadMask & x10 == 0
-  __ ld(c_rarg3, Address(xthread, ZThreadLocalData::address_bad_mask_offset()));
-  __ andr(c_rarg2, x10, c_rarg3);
-  __ bnez(c_rarg2, error);
+  // verifies that ZAddressBadMask & obj == 0
+  __ ld(tmp2, Address(xthread, ZThreadLocalData::address_bad_mask_offset()));
+  __ andr(tmp1, obj, tmp2);
+  __ bnez(tmp1, error);

   BarrierSetAssembler::check_oop(masm, obj, tmp1, tmp2, error);
 }

Fixed!

Copy link
Member

@xmas92 xmas92 left a comment

Choose a reason for hiding this comment

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

lgtm.


void ZBarrierSetAssembler::check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error) {
// Check if mask is good.
// verifies that ZAddressBadMask & r0 == 0
Copy link
Member

Choose a reason for hiding this comment

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

Update comment s/r0/obj

@fisk
Copy link
Contributor Author

fisk commented Feb 9, 2023

Thanks for the review @xmas92! Will fix the comment.

Copy link
Contributor

@coleenp coleenp left a comment

Choose a reason for hiding this comment

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

This change looks nice. Did you run tier8 or tier1 tests with -XX:+VerifyOops? I thought we ran some general testing in tier3 with -XX:+VerifyOops but we don't seem to be doing that. Thanks.

@openjdk
Copy link

openjdk bot commented Feb 9, 2023

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

8300255: Introduce interface for GC oop verification in the assembler

Co-authored-by: Martin Doerr <mdoerr@openjdk.org>
Co-authored-by: Axel Boldt-Christmas <aboldtch@openjdk.org>
Co-authored-by: Yadong Wang <yadongwang@openjdk.org>
Reviewed-by: fyang, aboldtch, coleenp

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

  • 723433d: 8302117: IgnoreUnrecognizedVMOptions flag causes failure in ArchiveHeapTestClass
  • e245620: 8293198: [vectorapi] Improve the implementation of VectorMask.indexInRange()
  • b814cfc: 8178806: Better exception logging in crypto code
  • 8c87a67: 8245654: Add Certigna Root CA
  • 97d0c87: 8302109: Trivial fixes to btree tests
  • 0aeebee: 8301988: VerifyLiveClosure::verify_liveness asserts on bad pointers outside heap
  • 4815566: 8228604: StackMapFrames are missing from redefined class bytes of retransformed classes
  • 5147969: 8272288: Funky multiresolution image breaks graphics context
  • 77ead44: 8302066: Counter _number_of_nmethods_with_dependencies should be atomic.
  • f4b72df: 8282379: [LOOM] vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod011 sometimes fails
  • ... and 62 more: https://git.openjdk.org/jdk/compare/522fa1327422e49eaa172d43185b3d85b2561036...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 Feb 9, 2023
Copy link
Member

@RealFYang RealFYang left a comment

Choose a reason for hiding this comment

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

Updated RISC-V part looks good. Thanks.

@fisk
Copy link
Contributor Author

fisk commented Feb 10, 2023

Updated RISC-V part looks good. Thanks.

Thanks!

@fisk
Copy link
Contributor Author

fisk commented Feb 10, 2023

This change looks nice. Did you run tier8 or tier1 tests with -XX:+VerifyOops? I thought we ran some general testing in tier3 with -XX:+VerifyOops but we don't seem to be doing that. Thanks.

Thanks for the review! I have run gc-test-suite locally on both an AArch64 machine and x86_64 machine, with -XX:+VerifyOops with ZGC and G1, and it looks fine. I think it exercises verify oops pretty well. Do you want me to run tier8 as well? Personally, I hesitate a bit to run off a tier8 job for this change if gc-test-suite is happy with -XX:+VerifyOops.

@coleenp
Copy link
Contributor

coleenp commented Feb 10, 2023

Tier8 is unnecessary as you've done general testing with it.

@fisk
Copy link
Contributor Author

fisk commented Feb 10, 2023

Tier8 is unnecessary as you've done general testing with it.

Okay, thanks!

@fisk
Copy link
Contributor Author

fisk commented Feb 13, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Feb 13, 2023

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

  • 99b6c0e: 8302289: RISC-V: Use bgez instruction in arraycopy_simple_check when possible
  • 57aef85: 8301838: PPC: continuation yield intrinsic: exception check not needed if yield succeeded
  • df93880: 8301942: java/net/httpclient/DigestEchoClientSSL.java fail with -Xcomp
  • 0025764: 8040793: vmTestbase/nsk/monitoring/stress/lowmem fails on calling isCollectionUsageThresholdExceeded()
  • 1f9c110: 8301958: Reduce Arrays.copyOf/-Range overheads
  • cb81073: 8300139: [AIX] Use pthreads to avoid JNI_createVM call from primordial thread
  • bbd8ae7: 8294194: [AArch64] Create intrinsics compress and expand
  • 4e327db: 8301499: Replace NULL with nullptr in cpu/zero
  • 0458d38: 6513512: MetalLookAndFeel.initClassDefaults does not install an entry for MetalMenuBarUI
  • f4b140b: 8296410: HttpClient throws java.io.IOException: no statuscode in response for HTTP2
  • ... and 95 more: https://git.openjdk.org/jdk/compare/522fa1327422e49eaa172d43185b3d85b2561036...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Feb 13, 2023

@fisk Pushed as commit f4d4fa5.

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

Successfully merging this pull request may close these issues.

5 participants