-
Notifications
You must be signed in to change notification settings - Fork 5.9k
8357220: Introduce a BSMAttributeEntry struct #25298
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
base: master
Are you sure you want to change the base?
Conversation
👋 Welcome back jsjolen! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
@jdksjolen The following labels will be automatically applied to this pull request:
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. |
/contributor /contributor add @rose00 |
@jdksjolen Syntax:
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. |
/contributor add @rose00 |
@jdksjolen |
Webrevs
|
private static int INDY_BSM_OFFSET = 0; | ||
private static int INDY_ARGC_OFFSET = 1; | ||
private static int INDY_ARGV_OFFSET = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the SA code that references these fields still correct? It seems the references are from the ClassWriter, which we don't have very good test coverage for. Probably this is a bug that is not being detected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The references are still correct, as we haven't changed the struct layout. We're also not planning on doing so. I don't think that there is a bug here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. It's just unusual to see constants like these that are needed by SA but serve no purpose in hotspot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does seem like you want to mirror these constants from the vmStructs side like it was rather than defining them here in the SA. I see why you did this but maybe you can add the constants to BSMAttributeEntry and declare them constants using declare_constant(BSMAttributeEntry::_indy...).
In case you change them at some later time.
enum { | ||
_indy_bsm_offset = 0, // CONSTANT_MethodHandle bsm | ||
_indy_argc_offset = 1, // u2 argc | ||
_indy_argv_offset = 2 // u2 argv[argc] | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@plummercj , this is where the enum constants come from.
private static int INDY_BSM_OFFSET = 0; | ||
private static int INDY_ARGC_OFFSET = 1; | ||
private static int INDY_ARGV_OFFSET = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The references are still correct, as we haven't changed the struct layout. We're also not planning on doing so. I don't think that there is a bug here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good, a couple of comments below.
@@ -77,6 +77,36 @@ class CPKlassSlot { | |||
} | |||
}; | |||
|
|||
class BSMAttributeEntry { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This?
// The first part of the operands array consists of an index into the second part.
// Extract a 32-bit index value from the first part.
Wouldn't it be better to leave it where it is, but add a comment ahead of the structure?
u2* argument_indexes() { | ||
return reinterpret_cast<u2*>(this + 1); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We typically keep a space before we change access modifier, let's keep that pattern in here. We can tighten up the rest of the code according to your suggestions, however.
} | ||
|
||
int argument_index(int n) const { | ||
assert(checked_cast<u2>(n) < _argument_count, "oob"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the assert contain a check that _argument_count is >= 0 as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, it's a u2
so that's just part of its type.
int next_offset = bootstrap_operand_limit(cp_index)); | ||
assert(end_offset == next_offset, "matched ending"); | ||
return argc; | ||
int bsmai = bootstrap_methods_attribute_index(cp_index); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "matched ending" assert was the only code that used bootstrap_operand_limit(), so that method could be removed as well. This comment applies to bootstrap_operand_base() as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
private static int INDY_BSM_OFFSET; | ||
private static int INDY_ARGC_OFFSET; | ||
private static int INDY_ARGV_OFFSET; | ||
private static int INDY_BSM_OFFSET = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the copyright of this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the review Lois! I've addressed most of your comments, but I didn't add any documentation for the BSMAttributeEntry
(yet).
u2* argument_indexes() { | ||
return reinterpret_cast<u2*>(this + 1); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We typically keep a space before we change access modifier, let's keep that pattern in here. We can tighten up the rest of the code according to your suggestions, however.
} | ||
|
||
int argument_index(int n) const { | ||
assert(checked_cast<u2>(n) < _argument_count, "oob"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, it's a u2
so that's just part of its type.
int next_offset = bootstrap_operand_limit(cp_index)); | ||
assert(end_offset == next_offset, "matched ending"); | ||
return argc; | ||
int bsmai = bootstrap_methods_attribute_index(cp_index); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
@@ -77,6 +77,36 @@ class CPKlassSlot { | |||
} | |||
}; | |||
|
|||
class BSMAttributeEntry { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This?
// The first part of the operands array consists of an index into the second part.
// Extract a 32-bit index value from the first part.
Wouldn't it be better to leave it where it is, but add a comment ahead of the structure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks like a nice improvement but I thought operands was going to turn into two arrays? Also there's probably a better name than 'operands' maybe bsm_operands?
private static int INDY_BSM_OFFSET = 0; | ||
private static int INDY_ARGC_OFFSET = 1; | ||
private static int INDY_ARGV_OFFSET = 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does seem like you want to mirror these constants from the vmStructs side like it was rather than defining them here in the SA. I see why you did this but maybe you can add the constants to BSMAttributeEntry and declare them constants using declare_constant(BSMAttributeEntry::_indy...).
In case you change them at some later time.
Hi,
The constant pool currently has a lot of methods specific to extracting parts of the operands array. What this array actually is, is a sequence of bootstrap method attribute entries, where each entry has the following components:
We can removes some of these operands array specific methods, and instead allows you to extract BSMAttributeEntrys which you can then use to extract its piece wise components. This makes for a nicer interface, and a bit easier to come into as a reader of the code, as it more closely mirrors the JVMS.
Please consider!
Testing: Currently GHA, running tier1-tier3
Progress
Issue
Contributors
<[email protected]>
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25298/head:pull/25298
$ git checkout pull/25298
Update a local copy of the PR:
$ git checkout pull/25298
$ git pull https://git.openjdk.org/jdk.git pull/25298/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 25298
View PR using the GUI difftool:
$ git pr show -t 25298
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25298.diff
Using Webrev
Link to Webrev Comment