Skip to content

8359227: Code cache/heap size options should be size_t #25791

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

Closed
wants to merge 12 commits into from

Conversation

kimbarrett
Copy link

@kimbarrett kimbarrett commented Jun 13, 2025

Please review this change that makes the various code cache/heap size options
consistently be of type size_t.

The shared declarations for these options were all uintx. These options all
may have platform-defined values. Some of those platform-specific definitions
were uintx, some were size_t, and some were intx(!). This change makes them
all consistently size_t.

More details in the first comment.

Testing: mach5 tier1-6
GHA testing in-progress


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-8359227: Code cache/heap size options should be size_t (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 25791

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 13, 2025

👋 Welcome back kbarrett! 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 Jun 13, 2025

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

8359227: Code cache/heap size options should be size_t

Reviewed-by: mhaessig, tschatzl

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:

  • b7fcd0b: 8359889: java/awt/MenuItem/SetLabelTest.java inadvertently triggers clicks on items pinned to the taskbar

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
Copy link

openjdk bot commented Jun 13, 2025

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

@kimbarrett kimbarrett marked this pull request as ready for review June 13, 2025 06:59
@kimbarrett
Copy link
Author

In addition to adjusting the types, there are some code changes to deal with
some inconsistencies, benefit from the change (mostly in the form of removal
of some casts), or address issues discovered while examining uses of the
options. The changes in the PR are broken up into a series of commits, mostly
by option or a couple of closely related options. It might be easier to review
parts of the change by looking at some of those individual commits, in order
to more easily see the code changes related to specific options.

One change in particular to note is the change in compilationPolicy.cpp. The
calculation of max_count, depending on explicit option values and such, could
potentially overflow its prior int type, effectively having a random value.
There is still a possibility of a nonsense result if ReservedCodeCacheSize and
CodeCacheMinimumUseSpace are poorly chosen. I'm leaving that pre-existing
issue to the compiler team to deal with.

The reason for my looking at these options in the first place is the incorrect
format strings for error messages in CompilerConfig::check_args_consistency.
They weren't previously noticed because the messages are printed using
jio_fprintf. It might be these should be using UL warnings, but I'm leaving
that to the compiler team to decide.

@openjdk openjdk bot added the rfr Pull request is ready for review label Jun 13, 2025
@kimbarrett kimbarrett changed the title 8359227: code cache/heap size options should be size_t 8359227: Code cache/heap size options should be size_t Jun 13, 2025
@mlbridge
Copy link

mlbridge bot commented Jun 13, 2025

Webrevs

Copy link
Contributor

@mhaessig mhaessig left a comment

Choose a reason for hiding this comment

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

Thank you for working on this, @kimbarrett. Good to see more consistent types here.

The changes overall look good to me. I only have a question and some minor suggestions.

One change in particular to note is the change in compilationPolicy.cpp. The
calculation of max_count, depending on explicit option values and such, could
potentially overflow its prior int type, effectively having a random value.
There is still a possibility of a nonsense result if ReservedCodeCacheSize and
CodeCacheMinimumUseSpace are poorly chosen. I'm leaving that pre-existing
issue to the compiler team to deal with.

Thank you for pointing this out. I'm currently looking at that part of the code in #25770 and will fix it there.

Comment on lines 60 to 61
#include <type_traits>

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this related to this change? I cannot find any usages from this header in the diff.

Copy link
Author

Choose a reason for hiding this comment

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

Oops. Leftover from an abandoned idea. Removed now.

Comment on lines +546 to +550
#define ADD_BOOL_FLAG(name) ADD_FLAG(bool, name, BOXED_BOOLEAN)
#define ADD_INT_FLAG(name) ADD_FLAG(int, name, BOXED_LONG)
#define ADD_SIZE_T_FLAG(name) ADD_FLAG(size_t, name, BOXED_LONG)
#define ADD_INTX_FLAG(name) ADD_FLAG(intx, name, BOXED_LONG)
#define ADD_UINTX_FLAG(name) ADD_FLAG(uintx, name, BOXED_LONG)
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
#define ADD_BOOL_FLAG(name) ADD_FLAG(bool, name, BOXED_BOOLEAN)
#define ADD_INT_FLAG(name) ADD_FLAG(int, name, BOXED_LONG)
#define ADD_SIZE_T_FLAG(name) ADD_FLAG(size_t, name, BOXED_LONG)
#define ADD_INTX_FLAG(name) ADD_FLAG(intx, name, BOXED_LONG)
#define ADD_UINTX_FLAG(name) ADD_FLAG(uintx, name, BOXED_LONG)
#define ADD_BOOL_FLAG(name) ADD_FLAG(bool, name, BOXED_BOOLEAN)
#define ADD_INT_FLAG(name) ADD_FLAG(int, name, BOXED_LONG)
#define ADD_SIZE_T_FLAG(name) ADD_FLAG(size_t, name, BOXED_LONG)
#define ADD_INTX_FLAG(name) ADD_FLAG(intx, name, BOXED_LONG)
#define ADD_UINTX_FLAG(name) ADD_FLAG(uintx, name, BOXED_LONG)

Feel free to ignore, but since you are already touching this, we might as well align it.

Copy link
Author

Choose a reason for hiding this comment

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

I'd rather not. I'm not a fan of this kind of formatting. I moved the ADD_FLAG calls over to
maintain the pre-existing formatting after adding the longer than anything else ADD_SIZE_T_FLAG,
but the ADD_FLAG arguments were not lined up and I'd just as soon leave them that way.

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 being a fan or not is sufficient reason...

Copy link
Author

Choose a reason for hiding this comment

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

Leaving it as is maintains the status quo. I'm not proposing to delete the extra whitespace in front of
ADD_FLAG, which would be my preferred layout. And the comment does say "feel free to ignore".

@@ -2448,7 +2448,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, JVMFlagOrigin
"Invalid maximum code cache size: %s.\n", option->optionString);
return JNI_EINVAL;
}
if (FLAG_SET_CMDLINE(ReservedCodeCacheSize, (uintx)long_ReservedCodeCacheSize) != JVMFlag::SUCCESS) {
if (FLAG_SET_CMDLINE(ReservedCodeCacheSize, (size_t)long_ReservedCodeCacheSize) != JVMFlag::SUCCESS) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this cast correct on a 32-bit platform, where size_t is not the same as uint64_t?

Copy link
Author

Choose a reason for hiding this comment

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

This isn't any different from the previous code, as uintx is also a 32/64 bit
type on 32/64 bit platforms. And it's fine, as the default for the maximum
value for parse_memory_size is max_uintx.

@@ -37,7 +37,7 @@

public class UintxTest {
private static final String FLAG_NAME = "VerifyGCStartAt";
private static final String FLAG_DEBUG_NAME = "CodeCacheMinimumUseSpace";
private static final String FLAG_DEBUG_NAME = "StopInterpreterAt";
Copy link
Member

Choose a reason for hiding this comment

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

Hi, Does this change is a mistake. Why do we change the FLAG_DEBUG_NAME

Copy link
Author

Choose a reason for hiding this comment

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

Because CodeCacheMinimumUseSpace is no longer uintx-typed, it's now size_t. So the test needs to use
some other uintx-typed option.

Copy link
Contributor

@mhaessig mhaessig left a comment

Choose a reason for hiding this comment

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

Thank you for addressing the comments. Looks good to me!

@openjdk
Copy link

openjdk bot commented Jun 18, 2025

@kimbarrett this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout code-cache-sizes
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Jun 18, 2025
@kimbarrett
Copy link
Author

Sigh, there are new merge conflicts after the one I just pushed a fix for.

@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label Jun 18, 2025
@kimbarrett
Copy link
Author

Sorry to request re-review, but there was a merge conflict, which I fixed, and
then another merge conflict appeared while I was testing that one. Sigh :(

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 18, 2025
@kimbarrett
Copy link
Author

Thanks for reviews @mhaessig and @tschatzl

@kimbarrett
Copy link
Author

/integrate

@openjdk
Copy link

openjdk bot commented Jun 18, 2025

Going to push as commit 7bc0d82.
Since your change was applied there has been 1 commit pushed to the master branch:

  • b7fcd0b: 8359889: java/awt/MenuItem/SetLabelTest.java inadvertently triggers clicks on items pinned to the taskbar

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jun 18, 2025
@openjdk openjdk bot closed this Jun 18, 2025
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Jun 18, 2025
@kimbarrett kimbarrett deleted the code-cache-sizes branch June 18, 2025 18:05
@openjdk openjdk bot removed the rfr Pull request is ready for review label Jun 18, 2025
@openjdk
Copy link

openjdk bot commented Jun 18, 2025

@kimbarrett Pushed as commit 7bc0d82.

💡 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
Development

Successfully merging this pull request may close these issues.

5 participants