Skip to content

8358696: Assert with extreme values for -XX:BciProfileWidth #26139

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

sarannat
Copy link
Contributor

@sarannat sarannat commented Jul 4, 2025

Issue
Extreme values for BciProfileWidth flag such as java -XX:BciProfileWidth=-1 -version and java -XX:BciProfileWidth=100000 -version results in assert failure assert(allocates2(pc)) failed: not in CodeBuffer memory: 0x0000772b63a7a3a0 <= 0x0000772b63b75159 <= 0x0000772b63b75158 . This is observed in a x86 machine.

Analysis
On debugging the issue, I found that increasing the size of the interpreter using the InterpreterCodeSize variable in src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp prevented the above mentioned assert from failing for large values of BciProfileWidth.

Proposal
Considering the fact that larger BciProfileWidth results in slower profiling, I have proposed a range between 0 to 5000 to restrict the value for BciProfileWidth for x86 machines. This maximum value is based on modifying the InterpreterCodeSize variable in src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp using the smallest InterpreterCodeSize for all the architectures. As for the lower bound, a value of -1 would be the same as 0, as this simply means no return bci's will be recorded in ret profile.

Issue in AArch64
Additionally running the command java -XX:BciProfileWidth= 10000 -version (or larger values) results in a different failure assert(offset_ok_for_immed(offset(), size)) failed: must be, was: 32768, 3 on an AArch64 machine.This is an issue of maximum offset for ldr/str in AArch64 which can be fixed using form_address as mentioned in JDK-8342736. In my preliminary fix using form_address on AArch64 machine. I had to modify 3 ldr and 1 str instruction (in file src/hotspot/cpu/aarch64/interp_masm_aarch64.cpp at line number 926, 983, and 997). With this fix using form_address, BciProfileWidth works for maximum of 5000 after which it crashes withassert(allocates2(pc)) failed: not in CodeBuffer memory: 0x0000772b63a7a3a0 <= 0x0000772b63b75159 <= 0x0000772b63b75158 . Without this fix BciProfileWidth works for a maximum value of 1300. Currently, I have suggested to restrict the upper bound on AArch64 to 1000 instead of fixing it with form_address.

Question to reviewers
Do you think this is a reasonable fix ? For AArch64 do you suggest fixing using form_address ? If yes, do I fix it under this PR or create another one ?


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-8358696: Assert with extreme values for -XX:BciProfileWidth (Bug - P4)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 26139

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jul 4, 2025

👋 Welcome back snatarajan! 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 Jul 4, 2025

❗ This change is not yet ready to be integrated.
See the Progress checklist in the description for automated requirements.

@openjdk openjdk bot changed the title JDK-8358696: Assert with extreme values for -XX:BciProfileWidth 8358696: Assert with extreme values for -XX:BciProfileWidth Jul 4, 2025
@openjdk
Copy link

openjdk bot commented Jul 4, 2025

@sarannat The following label will be automatically applied to this pull request:

  • hotspot-runtime

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.

@sarannat
Copy link
Contributor Author

sarannat commented Jul 4, 2025

/cc hotspot-compiler

@openjdk
Copy link

openjdk bot commented Jul 4, 2025

@sarannat
The hotspot-compiler label was successfully added.

@sarannat sarannat marked this pull request as ready for review July 21, 2025 13:08
@openjdk openjdk bot added the rfr Pull request is ready for review label Jul 21, 2025
@mlbridge
Copy link

mlbridge bot commented Jul 21, 2025

Webrevs

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.

1 participant