-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
8312235: [JVMCI] ConstantPool should not force eager resolution #14927
Conversation
👋 Welcome back dnsimon! A progress list of the required criteria for merging this PR into |
Webrevs
|
@dougxc Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information. |
@@ -658,17 +663,18 @@ public Object lookupConstant(int cpi) { | |||
* "pseudo strings" (arbitrary live objects) patched into a String entry. Such | |||
* entries do not have a symbol in the constant pool slot. | |||
*/ | |||
return compilerToVM().resolvePossiblyCachedConstantInPool(this, cpi); | |||
return compilerToVM().lookupConstantInPool(this, cpi, true); |
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 is true because it's always safe to do so?
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 really know what these "pseudo strings" are. In any case, I don't think resolving them involves calling any Java code.
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.
Sounds good. It's not currently causing any problems and we can investigate further if we start restricting when we can_call_java
and problems show up here.
@dougxc 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:
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 42 new commits pushed to the
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 |
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 looks good! I just have a few small questions and concerns.
bool found_it; | ||
obj = cp->find_cached_constant_at(index, found_it, CHECK_NULL); | ||
if (!found_it) { | ||
return nullptr; |
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 there be some sort of exception or error checking here or in the caller? If the constant can't be found it either isn't resolved or the index is invalid, correct?
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 error checking is already done by the call to getTagAt
in HotSpotConstantPool.lookupConstant(int cpi, boolean resolve)
.
I'll add more javadoc to clarify when a null is returned.
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.
Note that the javadoc of lookupConstantInPool
already states:
* The behavior of this method is undefined if {@code cpi} does not denote one of the following
* entry types: {@code JVM_CONSTANT_Dynamic}, {@code JVM_CONSTANT_String},
* {@code JVM_CONSTANT_MethodHandle}, {@code JVM_CONSTANT_MethodHandleInError},
* {@code JVM_CONSTANT_MethodType} and {@code JVM_CONSTANT_MethodTypeInError}.
@@ -697,9 +697,18 @@ C2V_VMENTRY_NULL(jobject, getUncachedStringInPool, (JNIEnv* env, jobject, ARGUME | |||
return JVMCIENV->get_jobject(JVMCIENV->get_object_constant(obj)); | |||
C2V_END | |||
|
|||
C2V_VMENTRY_NULL(jobject, resolvePossiblyCachedConstantInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint index)) | |||
C2V_VMENTRY_NULL(jobject, lookupConstantInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint index, bool resolve)) |
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.
Maybe rename jint index
to cpi
, cp_index
, or something related. I am currently making an effort to replace index
with something more specific when used in relation to the Constant Pool, and I think it's best to exercise that here as well.
C2V_VMENTRY_0(int, resolveInvokeDynamicInPool, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint index)) | ||
if (!ConstantPool::is_invokedynamic_index(index)) { | ||
JVMCI_THROW_MSG_0(IllegalStateException, err_msg("not an invokedynamic index %d", index)); | ||
C2V_VMENTRY_0(int, invokeDynamicOperandToCPIndex, (JNIEnv* env, jobject, ARGUMENT_PAIR(cp), jint operand, jboolean resolve)) |
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 invokeDynamicOperand
the correct name here? From what I recall, the operand to an invokedynamic
instruction is a constant pool index which is later rewritten to an indy_index
. I think the term operand can be confusing here.
Given the way that this method works, the operand in question is always an encoded indy_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.
I've pushed a commit with better naming.
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 changes, approved!
Thanks for the reviews! /integrate |
Going to push as commit 86821a7.
Your commit was automatically rebased without conflicts. |
The existing
jdk.vm.ci.meta.ConstantPool.lookupConstant(int cpi)
method forces eager resolving of constants. ForDynamicConstant
,MethodHandle
andMethodType
, this can mean invoking bootstrap methods, something that should not be done during JIT compilation. To avoid this, this PR adds the following tojdk.vm.ci.meta.ConstantPool
:Likewise,
jdk.vm.ci.meta.ConstantPool.lookupBootstrapMethodInvocation
has been fixed to no longer invoke the associated bootstrap method.Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/14927/head:pull/14927
$ git checkout pull/14927
Update a local copy of the PR:
$ git checkout pull/14927
$ git pull https://git.openjdk.org/jdk.git pull/14927/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 14927
View PR using the GUI difftool:
$ git pr show -t 14927
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/14927.diff
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/14927/head:pull/14927
$ git checkout pull/14927
Update a local copy of the PR:
$ git checkout pull/14927
$ git pull https://git.openjdk.org/jdk.git pull/14927/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 14927
View PR using the GUI difftool:
$ git pr show -t 14927
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/14927.diff
Webrev
Link to Webrev Comment