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

8310948: Fix ignored-qualifiers warning in Hotspot #14674

Closed
wants to merge 3 commits into from

Conversation

djelinski
Copy link
Member

@djelinski djelinski commented Jun 27, 2023

Please review this attempt to fix ignored-qualifiers warning.

Example warnings:

src/hotspot/share/oops/method.hpp:413:19: warning: 'volatile' type qualifier on return type has no effect [-Wignored-qualifiers]
   CompiledMethod* volatile code() const;
                   ^~~~~~~~~
src/hotspot/share/jfr/periodic/jfrModuleEvent.cpp:65:20: warning: type qualifiers ignored on cast result type [-Wignored-qualifiers]
    65 |   event.set_source((const ModuleEntry* const)from_module);
       |                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The proposed fix removes the ignored qualifiers.
In a few AD files I replaced const with constexpr where I noticed that the method is returning a compile-time constant, and other platforms use constexpr on the same method.

Release, debug and slowdebug builds on Aarch64 / x64 and Mac / Linux complete without errors. Cross-compile GHA builds also pass.


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-8310948: Fix ignored-qualifiers warning in Hotspot (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 14674

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 27, 2023

👋 Welcome back djelinski! 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 openjdk bot changed the title 8310948 8310948: Fix ignored-qualifiers warning in Hotspot Jun 27, 2023
@openjdk
Copy link

openjdk bot commented Jun 27, 2023

@djelinski The following labels will be automatically applied to this pull request:

  • build
  • hotspot
  • serviceability
  • shenandoah

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 serviceability serviceability-dev@openjdk.org hotspot hotspot-dev@openjdk.org build build-dev@openjdk.org shenandoah shenandoah-dev@openjdk.org labels Jun 27, 2023
@djelinski djelinski marked this pull request as ready for review June 27, 2023 14:51
@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 27, 2023
@mlbridge
Copy link

mlbridge bot commented Jun 27, 2023

Webrevs

@dholmes-ora
Copy link
Member

warning: 'volatile' type qualifier on return type has no effect

Can't say that I understand that warning. If I pass in a volatile pointer and return the same pointer then I would not expect to lose the volatile aspect of it. @kbarrett can you explain this one to me?

Copy link

@kimbarrett kimbarrett 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. Though mind-numbingly large; breaking something like this up into easier
to digest chunks can make reviewing easier.

@openjdk
Copy link

openjdk bot commented Jun 28, 2023

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

8310948: Fix ignored-qualifiers warning in Hotspot

Reviewed-by: kbarrett, dholmes

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

  • faf1b82: 8310656: RISC-V: __builtin___clear_cache can fail silently.
  • 0e3d91d: 8311215: [BACKOUT] JDK-8047998 Abort the vm if MaxNewSize is not the same as NewSize when MaxHeapSize is the same as InitialHeapSize
  • 09a4924: 8311145: Remove check_with_errno duplicates
  • 8abb9f5: 8047998: Abort the vm if MaxNewSize is not the same as NewSize when MaxHeapSize is the same as InitialHeapSize
  • d2e1159: 8311125: Remove unused parameter 'phase' in AllocateNode::Ideal_allocation
  • 8c8e9d9: 8309819: Clarify API note in Class::getName and MethodType::toMethodDescriptorString
  • 140b70f: 8311186: ProblemList javax/management/remote/mandatory/subjectDelegation/SubjectDelegation1Test.java on linux-aarch64
  • 971c2ef: 8303086: SIGSEGV in JavaThread::is_interp_only_mode()
  • f6bdccb: 8310829: guarantee(!HAS_PENDING_EXCEPTION) failed in ExceptionTranslation::doit
  • 456bf11: 8310173: Update --release 21 symbol information for JDK 21 build 29
  • ... and 67 more: https://git.openjdk.org/jdk/compare/15878360bf22c88a6e4038f05efa6db08d72b309...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 Jun 28, 2023
@djelinski
Copy link
Member Author

David: I think this part of the spec is relevant here:

A non-class non-array prvalue cannot be cv-qualified, [...]. (Note: a function call or cast expression may result in a prvalue of non-class cv-qualified type, but the cv-qualifier is generally immediately stripped out.)

source
given that the cv qualifiers are immediately stripped by the compiler, there's no point in providing them.

In the particular volatile pointer case: the function performs a volatile read to get the pointer value (address). That address can then be used in a non-volatile manner.

Kim: I realize that it's a big change, so thank you very much for reviewing it anyway! I was prepared to split it up, just wanted to know if this warning is something we want to fix.

@dean-long
Copy link
Member

In the example, was the intention perhaps volatile CompiledMethod* instead of CompiledMethod* volatile?

@djelinski
Copy link
Member Author

I don't think that was the intention. There's a comment on Method::_code stating that the pointer can change at any point (so the pointer was supposed to be volatile), and class CompiledMethod does not have any volatile - qualified methods.

There are similar cases where const pointer to a class was returned involving JavaThread, ReferenceProcessor, PSCardTable and ShenandoahHeapRegion; I suppose we could review if const could be added to the returned class, but that's outside of the scope of this PR.

@djelinski
Copy link
Member Author

Can I get another +1 on this? or should I proceed with splitting?

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

I will approve this as-is but have to wonder whether many of these cases of const return types were intending to declare const functions?

@@ -2285,7 +2285,7 @@ int HandlerImpl::emit_deopt_handler(CodeBuffer& cbuf)

//=============================================================================

const bool Matcher::match_rule_supported(int opcode) {
Copy link
Member

Choose a reason for hiding this comment

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

Have to wonder if these were all meant to be bool Match:xxx() const {?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I think that may have been the original intent. I'll add const on these functions.

Copy link
Member Author

Choose a reason for hiding this comment

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

...actually these methods are static, and static functions can't be const-qualified.

Copy link
Member

Choose a reason for hiding this comment

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

Ah okay :)

@dholmes-ora
Copy link
Member

P.S. Forgot to say thanks for dealing with this!

@djelinski
Copy link
Member Author

Thanks for the reviews!

/integrate

@openjdk
Copy link

openjdk bot commented Jul 3, 2023

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

  • 2c29705: 8309660: C2: failed: XMM register should be 0-15 (UseKNLSetting and ConvF2HF)
  • 52ee570: 8309209: C2 failed "assert(_stack_guard_state == stack_guard_reserved_disabled) failed: inconsistent state"
  • faf1b82: 8310656: RISC-V: __builtin___clear_cache can fail silently.
  • 0e3d91d: 8311215: [BACKOUT] JDK-8047998 Abort the vm if MaxNewSize is not the same as NewSize when MaxHeapSize is the same as InitialHeapSize
  • 09a4924: 8311145: Remove check_with_errno duplicates
  • 8abb9f5: 8047998: Abort the vm if MaxNewSize is not the same as NewSize when MaxHeapSize is the same as InitialHeapSize
  • d2e1159: 8311125: Remove unused parameter 'phase' in AllocateNode::Ideal_allocation
  • 8c8e9d9: 8309819: Clarify API note in Class::getName and MethodType::toMethodDescriptorString
  • 140b70f: 8311186: ProblemList javax/management/remote/mandatory/subjectDelegation/SubjectDelegation1Test.java on linux-aarch64
  • 971c2ef: 8303086: SIGSEGV in JavaThread::is_interp_only_mode()
  • ... and 69 more: https://git.openjdk.org/jdk/compare/15878360bf22c88a6e4038f05efa6db08d72b309...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jul 3, 2023

@djelinski Pushed as commit 055b4b4.

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

@djelinski djelinski deleted the ignored-qualifier branch July 3, 2023 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build build-dev@openjdk.org hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org shenandoah shenandoah-dev@openjdk.org
4 participants