Skip to content

Bsm refactor #24878

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Bsm refactor #24878

wants to merge 1 commit into from

Conversation

jdksjolen
Copy link
Contributor

@jdksjolen jdksjolen commented Apr 25, 2025

Hi,

This is the first commit in #23250 (hash 616f941 ) with some small changes.

Change to BootstrapMethods attribute storage

This refactoring changes how we store and access the BootstrapMethods attribute in the constant pool.

As a reminder, the BSMs attribute has the following format[0]:

BootstrapMethods_attribute {
    u2 attribute_name_index;
    u4 attribute_length;
    u2 num_bootstrap_methods;
    {   u2 bootstrap_method_ref;
        u2 num_bootstrap_arguments;
        u2 bootstrap_arguments[num_bootstrap_arguments];
    } bootstrap_methods[num_bootstrap_methods];
}

Note that each entry in the bootstraps_methods array may have a different size, as they may have a different num_bootstrap_arguments. That means that in order to access the nth element in the bootstraps_methods array you need to know at what byte offset that nth element starts. The way we can do that is to have a supplementary array consisting of u4s which indicate at which byte offset each entry starts. This PR changes where we store that array.

We used to have one single array, called operands, which stored both the offsets and BSM attribute together, one after the other. It looked a bit like this:

operands
     +-----------------------\+/
+--+-++--+--+--+-o-+----+----++---+-----+-----+-----+
|  |  |  |  |  |u2 |u2  | a0 | u2 | u2  | a0  | a1  |  ...
|  |  |offsets |  Entry #1   |   Entry #2           |
++-+--+--+--+--++--+----+----+----+-----+-----+-----+
 |             /|\
 |              |
 +--------------+

This PR splits them into two: _bsm_attribute_entries for storing the actual entries, and _bsm_attribute_offsets for storing the offsets of each entry into that array.

It looks like this:

offsets
+--+--+-------------------------+
|  |  |  ...                    |
++-+\-+-------------------------+
 |   |
\|/  ---------------\+/
++---+---+----+----+-+-+----+----+-----+------+
| u2 | u2|  a0| a1 | u2| u2 | a0 | a1  |   a2 |...
+----+---+----+----+---+----+---- -----+------+
entries

Add BootstrapMethodAttributeEntry

Instead of having many BSM attribute specific methods in the ConstantPool class, we introduce the BSMAE class and use that instead. You ask the constant pool for a particular BSMAE and you use that to get out the arguments, arg count, etc.

The other stuff

There's some other stuff in here, still figuring that out.

[0] https://docs.oracle.com/javase/specs/jvms/se24/html/jvms-4.html#jvms-4.7.23


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

Warnings

 ⚠️ Patch contains a binary file (src/java.desktop/share/classes/java/awt/doc-files/BorderLayout-1.gif)
 ⚠️ Patch contains a binary file (src/java.desktop/share/classes/java/awt/doc-files/FlowLayout-1.gif)
 ⚠️ Patch contains a binary file (src/java.desktop/share/classes/java/awt/doc-files/GridBagLayout-1.gif)
 ⚠️ Patch contains a binary file (src/java.desktop/share/classes/java/awt/doc-files/GridBagLayout-2.gif)
 ⚠️ Patch contains a binary file (src/java.desktop/share/classes/java/awt/doc-files/GridLayout-1.gif)
 ⚠️ Patch contains a binary file (src/java.desktop/share/classes/java/awt/doc-files/GridLayout-2.gif)

Contributors

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 24878

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 25, 2025

👋 Welcome back jsjolen! 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 Apr 25, 2025

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

@openjdk
Copy link

openjdk bot commented Apr 25, 2025

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

  • graal
  • hotspot
  • serviceability

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.

@jdksjolen
Copy link
Contributor Author

/contributor add rose00

@openjdk
Copy link

openjdk bot commented Apr 28, 2025

@jdksjolen rose00 was not found in the census.

Syntax: /contributor (add|remove) [@user | openjdk-user | Full Name <email@address>]. For example:

  • /contributor add @openjdk-bot
  • /contributor add duke
  • /contributor add J. Duke <[email protected]>

User names can only be used for users in the census associated with this repository. For other contributors you need to supply the full name and email address.

@jdksjolen
Copy link
Contributor Author

/contributor add @rose00

@openjdk
Copy link

openjdk bot commented Apr 28, 2025

@jdksjolen
Contributor John R Rose <[email protected]> successfully added.

@jdksjolen jdksjolen force-pushed the bsm-refactor branch 2 times, most recently from 31afffc to 03f26e0 Compare May 5, 2025 18:14
@jdksjolen jdksjolen force-pushed the bsm-refactor branch 3 times, most recently from 7b8c50e to 063f607 Compare May 7, 2025 12:48
Comment on lines 54 to 58
#if INCLUDE_CDS
void ResolvedIndyEntry::remove_unshareable_info() {
u2 saved_resolved_references_index = _resolved_references_index;
u2 saved_cpool_index = _cpool_index;
memset(this, 0, sizeof(*this));
_resolved_references_index = saved_resolved_references_index;
_cpool_index = saved_cpool_index;
_method = nullptr; // resolution sets this pointer; the rest is static
_flags &= ~(1 << resolution_failed_shift);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This needs to be double checked.

@openjdk
Copy link

openjdk bot commented May 14, 2025

@jdksjolen 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 bsm-refactor
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 May 14, 2025
@jdksjolen jdksjolen force-pushed the bsm-refactor branch 8 times, most recently from 24b3f1e to a36bff7 Compare May 14, 2025 16:08
@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label May 15, 2025
@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Jun 5, 2025
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