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

8314651: G1: Fix -Wconversion warnings in static fields of HeapRegion #15360

Closed

Conversation

albertnetymk
Copy link
Member

@albertnetymk albertnetymk commented Aug 21, 2023

Use unsigned type for heap-region-size related shifts in HeapRegion.

Test: tier1-3


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-8314651: G1: Fix -Wconversion warnings in static fields of HeapRegion (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 15360

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 21, 2023

👋 Welcome back ayang! 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 8314651 8314651: G1: Fix -Wconversion warnings in static fields of HeapRegion Aug 21, 2023
@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 21, 2023
@openjdk
Copy link

openjdk bot commented Aug 21, 2023

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

  • graal
  • hotspot

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 graal graal-dev@openjdk.org hotspot hotspot-dev@openjdk.org labels Aug 21, 2023
@mlbridge
Copy link

mlbridge bot commented Aug 21, 2023

Webrevs

@albertnetymk
Copy link
Member Author

/label hotspot-gc

@openjdk openjdk bot added the hotspot-gc hotspot-gc-dev@openjdk.org label Aug 25, 2023
@openjdk
Copy link

openjdk bot commented Aug 25, 2023

@albertnetymk
The hotspot-gc label was successfully added.

Comment on lines 135 to 137
uint region_size_log_mb = HeapRegion::LogOfHRGrainBytes > LOG_M
? HeapRegion::LogOfHRGrainBytes - LOG_M
: 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

I would just assert that HeapRegion::LogOfHRGrainBytes >= LOG_M here. People messing with with minimum region size would need to check this code anyway.

Further, LOG_M should probably be calculated as log2_exact(HeapRegion::min_size()) instead of using the constant directly (and renamed appropriately, something like Log[Of]MinHeapRegionSize/GrainBytes).

Then there would be no need to do the maximum calculation (my original suggestion would have been MAX2(HeapRegion::LogOfHRGrainBytes - LOG_M, 0u) btw)

Copy link
Member Author

Choose a reason for hiding this comment

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

Checking how it's used around G1RemSetArrayOfCardsEntriesBase, log_m is more about 1MB. The very fact that min-heap-region is 1M seems an accident. Kept the original name and added assertion.


if (FLAG_IS_DEFAULT(G1RemSetArrayOfCardsEntries)) {
uint max_cards_in_inline_ptr = G1CardSetConfiguration::max_cards_in_inline_ptr(HeapRegion::LogOfHRGrainBytes - CardTable::card_shift());
uint max_cards_in_inline_ptr = G1CardSetConfiguration::max_cards_in_inline_ptr(HeapRegion::LogCardsPerRegion);
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure how this change has anything to do with -Wconversion, but okay :)

@@ -31,7 +31,7 @@

inline uint G1CardTable::region_idx_for(CardValue* p) {
size_t const card_idx = pointer_delta(p, _byte_map, sizeof(CardValue));
return (uint)(card_idx >> (HeapRegion::LogOfHRGrainBytes - _card_shift));
return (uint)(card_idx >> HeapRegion::LogCardsPerRegion);
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure how this change has anything to do with -Wconversion but okay :)

@@ -817,7 +817,7 @@
#if INCLUDE_G1GC

#define VM_STRUCTS_JVMCI_G1GC(nonstatic_field, static_field) \
static_field(HeapRegion, LogOfHRGrainBytes, int)
static_field(HeapRegion, LogOfHRGrainBytes, uint32_t)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
static_field(HeapRegion, LogOfHRGrainBytes, uint32_t)
static_field(HeapRegion, LogOfHRGrainBytes, uint)

Seems to compile just fine here.

Copy link
Member Author

Choose a reason for hiding this comment

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

That was my original attempt, but JVMCI related tests failed with uint.

@@ -158,13 +158,13 @@ void G1BarrierSetC1::post_barrier(LIRAccess& access, LIR_Opr addr, LIR_Opr new_v
__ logical_xor(xor_res, new_val, xor_res);
__ move(xor_res, xor_shift_res);
__ unsigned_shift_right(xor_shift_res,
LIR_OprFact::intConst(HeapRegion::LogOfHRGrainBytes),
LIR_OprFact::intConst(static_cast<jint>(HeapRegion::LogOfHRGrainBytes)),
Copy link
Contributor

Choose a reason for hiding this comment

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

One could maybe argue that this should be a checked_cast, but given that the value bounds are known there is no point...

Copy link
Contributor

@tschatzl tschatzl left a comment

Choose a reason for hiding this comment

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

Lgtm.

@openjdk
Copy link

openjdk bot commented Aug 29, 2023

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

8314651: G1: Fix -Wconversion warnings in static fields of HeapRegion

Reviewed-by: tschatzl, iwalulya

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

  • e22762c: 8314932: G1: Fix -Wconversion warnings for simple cases inside g1 folder
  • 762b652: 8314573: G1: Heap resizing at Remark does not take existing eden regions into account
  • a4e97aa: 8314753: Remove support for @beaninfo, @todo, @since.unbundled, and @note
  • 5cc64cc: 8309463: IGV: Dynamic graph layout algorithm

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.

➡️ 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 Aug 29, 2023
@albertnetymk
Copy link
Member Author

Thanks for the review.

/integrate

@openjdk
Copy link

openjdk bot commented Aug 30, 2023

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

  • 876a725: 8315206: RISC-V: hwprobe query is_set return wrong value
  • ed1ea5f: 8314024: SIGSEGV in PhaseIdealLoop::build_loop_late_post_work due to bad immediate dominator info
  • f3aeb02: 8315213: java/lang/ProcessHandle/TreeTest.java test enhance output of children
  • 1e7e2bc: 8315214: Do not run sun/tools/jhsdb tests concurrently
  • ce2a7ea: 8314056: Remove runtime platform check from frem/drem
  • 1c598c2: 8312428: PKCS11 tests fail with NSS 3.91
  • b2728cb: 8189685: need PerfMemory class update and a volatile_static_field support in VMStructs
  • e22762c: 8314932: G1: Fix -Wconversion warnings for simple cases inside g1 folder
  • 762b652: 8314573: G1: Heap resizing at Remark does not take existing eden regions into account
  • a4e97aa: 8314753: Remove support for @beaninfo, @todo, @since.unbundled, and @note
  • ... and 1 more: https://git.openjdk.org/jdk/compare/1d0250709a6ee97f5647edff589761bd9d0b7f4c...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Aug 30, 2023

@albertnetymk Pushed as commit cb3f968.

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

@albertnetymk albertnetymk deleted the g1-heap-region-log-uint branch August 30, 2023 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
graal graal-dev@openjdk.org hotspot hotspot-dev@openjdk.org hotspot-gc hotspot-gc-dev@openjdk.org integrated Pull request has been integrated
3 participants