Skip to content

Conversation

@afshin-zafari
Copy link
Contributor

@afshin-zafari afshin-zafari commented Aug 4, 2023

The JVM options that are in range of int type are converted in globals.hpp and other files where affected.

Tests

tiers 1-4 passed for linux-x64, linux-x64-debug, windows-x64, windows-x64-debug
tier1 all passed.


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-8308850: Change JVM options with small ranges that get -Wconversion warnings to 32 bits (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 15164

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 4, 2023

👋 Welcome back azafari! 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 Aug 4, 2023

@afshin-zafari 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 4, 2023
@afshin-zafari afshin-zafari marked this pull request as ready for review August 4, 2023 19:53
@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 4, 2023
@mlbridge
Copy link

mlbridge bot commented Aug 4, 2023

Webrevs

"switch") \
\
develop(intx, StopInterpreterAt, 0, \
develop(int, StopInterpreterAt, 0, \
Copy link
Member

Choose a reason for hiding this comment

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

Some cpu ports access this from assembly, so changing the size is gong to require cpu-specific changes. I'd rather see this and BytecodeCounter::_counter_value both changed to uint64_t.

Copy link
Contributor

Choose a reason for hiding this comment

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

share/interpreter/bytecodeHistogram.cpp:int BytecodeCounter::_counter_value = 0;

Maybe this should be inx instead.

Copy link
Member

Choose a reason for hiding this comment

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

The only reason to use intx is if this should be 32-bit on 32-bit and 64-bit on 64-bit. I don't think that is the case here.

Copy link
Contributor

Choose a reason for hiding this comment

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

The reason that this should be reverted is that to fix it, you have to fix all the platform code and that seems out of scope for fixing Wconversion warnings.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually this counts bytecodes, so it could easily become 64 bit on 64 bit platforms.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is complicated. BytecodeCounter::_counter_value is an int, and StopInterpreterAt compares to that in shared code, which is fine because it'll promote the former to intx. The cpu-specific code fetches the former as int and the latter as intx, except in one place so fixing either is going to be work. The one place that complains on x86 is

src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp:1865:12: warning: conversion from 'intx' {aka 'long int'} to 'int32_t' {aka 'int'} may change value [-Wconversion]
1865 | StopInterpreterAt,
| ^~~~~~~~~~~~~~~~~

  __ cmp32(ExternalAddress((address) &BytecodeCounter::_counter_value),
           StopInterpreterAt,
           rscratch1);

We could just static_cast StopInterpreterAt to int here.

Copy link
Member

Choose a reason for hiding this comment

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

Actually this counts bytecodes, so it could easily become 64 bit on 64 bit platforms.

I thought this was the count within a method, in which case the bytecode limit is the same for 32-bit and 64-bit.

Copy link
Contributor

Choose a reason for hiding this comment

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

It is not.

uint step_size = AllocatePrefetchStepSize;
uint distance = AllocatePrefetchDistance;
int step_size = AllocatePrefetchStepSize;
int distance = AllocatePrefetchDistance;
Copy link
Member

Choose a reason for hiding this comment

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

I think this is a step in the wrong direction. Shouldn't these remain uint?

Copy link
Member

Choose a reason for hiding this comment

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

This change also doesn't fit the PR description. There is no need to change this in this PR (or even at all).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay. Reverted back.

@dean-long
Copy link
Member

I know HotSpot code is not very careful about distinguishing between int and uint, but shouldn't we prefer uint for values that can't be negative? The disadvantage of uint though is will we get more -Wsign-conversion warnings to fix when that warning gets turned on.

@coleenp
Copy link
Contributor

coleenp commented Aug 5, 2023

The argument checking code gives a nice error if you pass a negative value for a parameter in the range of 0 .. positive-number if the argument is an int, and a bad one if the argument is uint. That's why in previous changes, I've preferred changing to int. We could file an RFE to improve the error message though. I don't know how hard that would be to fix.

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 think the basic change from intx to int is sound - there is no reason for these flags to have a different size depending on the platform. But you need to check any other references to these flags (e.g. printing) are changed appropriately.

The issue of signed versus unsigned is a topic for a different day IMO.

Thanks.

uint step_size = AllocatePrefetchStepSize;
uint distance = AllocatePrefetchDistance;
int step_size = AllocatePrefetchStepSize;
int distance = AllocatePrefetchDistance;
Copy link
Member

Choose a reason for hiding this comment

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

This change also doesn't fit the PR description. There is no need to change this in this PR (or even at all).

Comment on lines 1878 to 1879
int step_size = AllocatePrefetchStepSize;
int distance = AllocatePrefetchDistance;
Copy link
Member

Choose a reason for hiding this comment

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

Ditto no need to change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay.
Reverted back.

"switch") \
\
develop(intx, StopInterpreterAt, 0, \
develop(int, StopInterpreterAt, 0, \
Copy link
Member

Choose a reason for hiding this comment

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

The only reason to use intx is if this should be 32-bit on 32-bit and 64-bit on 64-bit. I don't think that is the case here.

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 looks good with the minor issue of removing a blank space.

"switch") \
\
develop(intx, StopInterpreterAt, 0, \
develop(intx, StopInterpreterAt, 0, \
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this add a blank? Should be aligned.

@openjdk
Copy link

openjdk bot commented Aug 8, 2023

@afshin-zafari 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:

8308850: Change JVM options with small ranges that get -Wconversion warnings to 32 bits

Reviewed-by: dholmes, coleenp, dlong

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

  • 43462a3: 8313224: Avoid calling JavaThread::current() in MemAllocator::Allocation constructor
  • 9abb2a5: 8312461: JNI warnings in SunMSCApi provider
  • 42758cb: 8312882: Update the CONTRIBUTING.md with pointers to lifecycle of a PR
  • 88b4e3b: 8304292: Memory leak related to ClassLoader::update_class_path_entry_list
  • 6f5c903: 8313899: JVMCI exception Translation can fail in TranslatedException.
  • d97de82: 8313633: [macOS] java/awt/dnd/NextDropActionTest/NextDropActionTest.java fails with java.lang.RuntimeException: wrong next drop action!
  • 79be8d9: 8312259: StatusResponseManager unused code clean up
  • 1875b28: 8314061: [JVMCI] DeoptimizeALot stress logic breaks deferred barriers
  • bd1b942: 8313905: Checked_cast assert in CDS compare_by_loader
  • 9b53251: 8313654: Test WaitNotifySuspendedVThreadTest.java timed out
  • ... and 15 more: https://git.openjdk.org/jdk/compare/360f65d7b15b327e2f160c42f318945cc6548bda...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 Aug 8, 2023
@coleenp
Copy link
Contributor

coleenp commented Aug 8, 2023

Hi, I thought you were going to change this one too: LogEventsBufferEntries ?

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 only checked the last two flags but in both cases found related changes. Please make sure all the uses of these flags has been checked. Thanks.

Comment on lines +1745 to 1748
product(int, PerfDataSamplingInterval, 50, \
"Data sampling interval (in milliseconds)") \
range(PeriodicTask::min_interval, max_jint) \
constraint(PerfDataSamplingIntervalFunc, AfterErgo) \
Copy link
Member

Choose a reason for hiding this comment

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

You need to change the type of the PerfDataSamplingIntervalFunc as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed this and checked for the other options I changed.

"Hit breakpoint when mallocing/freeing this pointer") \
\
develop(intx, StackPrintLimit, 100, \
develop(int, StackPrintLimit, 100, \
Copy link
Member

Choose a reason for hiding this comment

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

You can remove this cast now:

./share/utilities/vmError.cpp:    const int limit = max_frames == -1 ? StackPrintLimit : MIN2(max_frames, (int)StackPrintLimit);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@openjdk
Copy link

openjdk bot commented Aug 9, 2023

@afshin-zafari 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 wconv_jvm_options
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 merge-conflict Pull request has merge conflict with target branch and removed ready Pull request is ready to be integrated labels Aug 9, 2023
@openjdk openjdk bot added ready Pull request is ready to be integrated and removed merge-conflict Pull request has merge conflict with target branch labels Aug 9, 2023
@afshin-zafari
Copy link
Contributor Author

I also changed the type of LogEventsBufferEntries in runtime/globals.hpp which fixes the Wconversion warnings in utilities/events.hpp.

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.

Updates look good.

Thanks

"Enable the various ring buffer event logs") \
\
product(uintx, LogEventsBufferEntries, 20, DIAGNOSTIC, \
product(int, LogEventsBufferEntries, 20, DIAGNOSTIC, \
Copy link
Member

Choose a reason for hiding this comment

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

I was going to say this should keep its unsignedness but it is treated as an int everywhere anyway.

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.

Just noticed that AllocatePrefetchStyle should also be included in this.

Thanks

@coleenp
Copy link
Contributor

coleenp commented Aug 10, 2023

The criteria for choosing flags was whether they were causing -Wconversion warnings, which this one doesn't. That said, it would be consistent to change this one since other AllocatePrefetch flags are changed. There are likely many other flags that can be int not intx. They can be changed in a different patch.

@dholmes-ora
Copy link
Member

The criteria for choosing flags was whether they were causing -Wconversion warnings,

There is nothing in the PR or JBS to indicate this is the case. I assumed this would fix all oversized flags as the title indicates. If this is only a restricted subset perhaps the title and description should be updated to reflect that. Thanks.

@afshin-zafari afshin-zafari changed the title 8308850: Change JVM options with small ranges from 64 to 32 bits, for globals.hpp Change JVM options with small ranges from 64 to 32 bits that get -Wconversion warnings Aug 10, 2023
@afshin-zafari afshin-zafari changed the title Change JVM options with small ranges from 64 to 32 bits that get -Wconversion warnings Change JVM options with small ranges that get -Wconversion warnings to 32 bits Aug 10, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Aug 10, 2023
@afshin-zafari afshin-zafari changed the title Change JVM options with small ranges that get -Wconversion warnings to 32 bits 8308850: Change JVM options with small ranges that get -Wconversion warnings to 32 bits Aug 10, 2023
@openjdk openjdk bot added ready Pull request is ready to be integrated rfr Pull request is ready for review labels Aug 10, 2023
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.

Still good.

Comment on lines +256 to +261
do_int_flag(AllocateInstancePrefetchLines) \
do_int_flag(AllocatePrefetchDistance) \
do_intx_flag(AllocatePrefetchInstr) \
do_intx_flag(AllocatePrefetchLines) \
do_intx_flag(AllocatePrefetchStepSize) \
do_intx_flag(AllocatePrefetchStyle) \
do_int_flag(AllocatePrefetchLines) \
do_int_flag(AllocatePrefetchStepSize) \
do_int_flag(AllocatePrefetchStyle) \
Copy link
Member

Choose a reason for hiding this comment

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

Why is AllocatePrefetchInstr not changed? It seems to use 0-3 only.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like from the constraints, it's allowed to be max_intx on some platforms, so changing this would be a functional change.

JVMFlag::Error AllocatePrefetchInstrConstraintFunc(intx value, bool verbose) {
  intx max_value = max_intx;
#if defined(X86)
  max_value = 3;
#endif

Copy link
Member

Choose a reason for hiding this comment

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

OK, that sounds reasonable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fwiw, only x86 uses AllocatePrefetchInstr. Other platforms never use it, so its value for those is meaningless.

@afshin-zafari
Copy link
Contributor Author

Thank you Coleen, Dean, David, Thomas and Ioi for your comments.
/integrate

@openjdk
Copy link

openjdk bot commented Aug 14, 2023

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

  • 5bfb82e: 8314119: G1: Fix -Wconversion warnings in G1CardSetInlinePtr::card_pos_for
  • 06aa3c5: 8314118: Update JMH devkit to 1.37
  • 4164693: 8313372: [JVMCI] Export vmIntrinsics::is_intrinsic_available results to JVMCI compilers.
  • 049b55f: 8314019: Add gc logging to jdk/jfr/event/gc/detailed/TestZAllocationStallEvent.java
  • a39ed10: 8314116: C2: assert(false) failed: malformed control flow after JDK-8305636
  • 1de5bf1: 8314106: C2: assert(is_valid()) failed: must be valid after JDK-8305636
  • 5c91622: 8314117: RISC-V: Incorrect VMReg encoding in RISCV64Frame.java
  • 6bbcef5: 8313948: Remove unnecessary static fields defaultUpper/defaultLower in sun.net.PortConfig
  • b88c273: 8313743: Make fields final in sun.nio.ch
  • ec0cc63: 8313904: [macos] All signing tests which verifies unsigned app images are failing
  • ... and 30 more: https://git.openjdk.org/jdk/compare/360f65d7b15b327e2f160c42f318945cc6548bda...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Aug 14, 2023

@afshin-zafari Pushed as commit 823f5b9.

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

@afshin-zafari afshin-zafari deleted the wconv_jvm_options branch June 13, 2025 10:17
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 integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

6 participants