Skip to content

Conversation

@jsikstro
Copy link
Member

@jsikstro jsikstro commented May 15, 2025

Hello,

This RFE improves utility for converting to/from, iterating over and defining structures that are indexed using the ZPageAge type.

Converting to/from ZPageAge and its underlying type (uint8_t, often just uint) is currently done via using static_cast. This works fine because sane values are converted in all use cases. However, to make conversion safer (and also more readable), I propose we add a to_zpageage and a corresponding untype that checks that the conversion is valid. Such conversion methods should be used instead of calling static_cast<uint/ZPageAge>.

We currently define a value called ZPageAgeMax, which is defined as static_cast<uint>(ZPageAge::old). The majority of places that use this value actualy use ZPageAgeMax + 1, which is equivalent to the number of ages. Instead, I propose we define and use a value that represents the number of possible ages, called ZPageAgeCount.

Lastly, to make iterating over ages more accessible, I propose we create an intreface of enum iterators of ZPageAge. This will also create a foundation for generating values that require a ZPageAge in the future. Since the end of the enum iterators are exclusive, I've opted to use the following value as end for the iterators:

constexpr ZPageAge ZPageAgeLastPlusOne = static_cast<ZPageAge>(ZPageAgeCount);

I see us using either this or a sentinel/dummy value at the end of the enum class, but I prefer having a value similar to ZPageAgeLastPlusOne over a dummy value.

Testing:

  • Oracle's tier 1-4
  • GHA

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-8357053: ZGC: Improved utility for ZPageAge (Enhancement - P4)

Reviewers

Contributors

  • Axel Boldt-Christmas <aboldtch@openjdk.org>

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 25251

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented May 15, 2025

👋 Welcome back jsikstro! 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 May 15, 2025

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

8357053: ZGC: Improved utility for ZPageAge

Co-authored-by: Axel Boldt-Christmas <aboldtch@openjdk.org>
Reviewed-by: sjohanss, stefank

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 no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential 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 rfr Pull request is ready for review label May 15, 2025
@openjdk
Copy link

openjdk bot commented May 15, 2025

@jsikstro 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 May 15, 2025
@jsikstro
Copy link
Member Author

/label remove hotspot
/label add hotspot-gc

@openjdk openjdk bot removed the hotspot hotspot-dev@openjdk.org label May 15, 2025
@openjdk
Copy link

openjdk bot commented May 15, 2025

@jsikstro
The hotspot label was successfully removed.

@openjdk openjdk bot added the hotspot-gc hotspot-gc-dev@openjdk.org label May 15, 2025
@openjdk
Copy link

openjdk bot commented May 15, 2025

@jsikstro
The hotspot-gc label was successfully added.

@jsikstro
Copy link
Member Author

/contributor add @xmas92

@openjdk
Copy link

openjdk bot commented May 15, 2025

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

@mlbridge
Copy link

mlbridge bot commented May 15, 2025

Webrevs

@ky0n
Copy link

ky0n commented May 15, 2025

copyright-year update is missing on at least 2 files

Copy link
Member

@stefank stefank left a comment

Choose a reason for hiding this comment

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

A couple of questions before fully reviewing this?

Copy link
Member

@stefank stefank 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 but I found a couple nits.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label May 27, 2025
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label May 30, 2025
Copy link
Contributor

@kstefanj kstefanj left a comment

Choose a reason for hiding this comment

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

Looks really nice. As discussed offline, adding a gtest to make sure that the ranges cover the expected ages could be an additional nice addition.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 4, 2025
@jsikstro
Copy link
Member Author

jsikstro commented Jun 9, 2025

Thank you for the reviews!
/integrate

@openjdk
Copy link

openjdk bot commented Jun 9, 2025

Going to push as commit 1c72b35.

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

openjdk bot commented Jun 9, 2025

@jsikstro Pushed as commit 1c72b35.

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

@jsikstro jsikstro deleted the JDK-8357053_zpageage_utility branch June 27, 2025 09:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-gc hotspot-gc-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

4 participants