-
Notifications
You must be signed in to change notification settings - Fork 5.9k
8357987: [JVMCI] Add Support for Retrieving All Non-Static Methods of a ResolvedJavaType. #25498
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
Hi @teshull, welcome to this OpenJDK project and thanks for contributing! We do not recognize you as Contributor and need to ensure you have signed the Oracle Contributor Agreement (OCA). If you have not signed the OCA, please follow the instructions. Please fill in your GitHub username in the "Username" field of the application. Once you have signed the OCA, please let us know by writing If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please use "Add GitHub user teshull" as summary for the issue. If you are contributing this work on behalf of your employer and your employer has signed the OCA, please let us know by writing |
❗ This change is not yet ready to be integrated. |
/covered |
Thank you! Please allow for a few business days to verify that your employer has signed the OCA. Also, please note that pull requests that are pending an OCA check will not usually be evaluated, so your patience is appreciated! |
src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaMethod.java
Outdated
Show resolved
Hide resolved
src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java
Outdated
Show resolved
Hide resolved
if (isConstructor() || isStatic()) { | ||
return false; | ||
} | ||
return !compilerToVM().isOverpass(this); |
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 you can do this with a direct flag check:
boolean isOverpass = (getConstMethodFlags() & config().constMethodIsOverpass) != 0;
return isOverpass;
See #20256 as an example of the other changes needed for this.
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.
good call. changed
@@ -365,6 +366,13 @@ default ResolvedJavaMethod[] getDeclaredMethods(boolean forceLink) { | |||
throw new UnsupportedOperationException(); | |||
} | |||
|
|||
/** | |||
* Returns a list containing all the non-static methods present within this type. |
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.
Point out that the returned list is unmodifiable (like the API for Stream.toList()
does).
src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/CompilerToVM.java
Outdated
Show resolved
Hide resolved
*/ | ||
ResolvedJavaMethod[] getDeclaredMethods(HotSpotResolvedObjectTypeImpl klass) { | ||
return getDeclaredMethods(klass, klass.getKlassPointer()); | ||
} | ||
|
||
native ResolvedJavaMethod[] getDeclaredMethods(HotSpotResolvedObjectTypeImpl klass, long klassPointer); | ||
|
||
/** | ||
* Gets the {@link ResolvedJavaMethod}s for all instance methods of {@code klass}. |
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.
instance -> non-static
Instance -> NonStatic
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 realized NonStatic is not accurate - we return everything except <init>s
and <clinit>
- so I switched to NonInitializerMethods
everywhere. Does that seem fair?
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.
thinking about it more, it's probably better if we do no filtering and return all methods in InstanceKlass->_methods
. How about something like getAllMethods
:
/**
* Returns a list containing all methods present within this type. This list can include
* methods implicitly created and used by the VM.
* The returned List is unmodifiable; calls to any mutator method
* will always cause {@code UnsupportedOperationException} to be thrown.
*
* @param forceLink if {@code true}, forces this type to be {@link #link linked}
*/
List<ResolvedJavaMethod> getAllMethods(boolean forceLink);
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.
Yes, that's a good idea - it's more future proof and lets the caller do the filtering.
This list can include methods implicitly created and used by the VM that are not present in {@link #getDeclaredMethods}.
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 changed it now to be getAllMethods
@@ -176,6 +176,17 @@ boolean isCompilable(HotSpotResolvedJavaMethodImpl method) { | |||
|
|||
private native boolean isCompilable(HotSpotResolvedJavaMethodImpl method, long methodPointer); | |||
|
|||
/** |
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.
Delete this method - it's no longer used.
@@ -577,6 +577,11 @@ C2V_VMENTRY_0(jboolean, isCompilable,(JNIEnv* env, jobject, ARGUMENT_PAIR(method | |||
return !method->is_not_compilable(CompLevel_full_optimization); | |||
C2V_END | |||
|
|||
C2V_VMENTRY_0(jboolean, isOverpass,(JNIEnv* env, jobject, ARGUMENT_PAIR(method))) |
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.
Delete this method - it's no longer used.
@@ -3280,6 +3312,7 @@ JNINativeMethod CompilerToVM::methods[] = { | |||
{CC "methodIsIgnoredBySecurityStackWalk", CC "(" HS_METHOD2 ")Z", FN_PTR(methodIsIgnoredBySecurityStackWalk)}, | |||
{CC "setNotInlinableOrCompilable", CC "(" HS_METHOD2 ")V", FN_PTR(setNotInlinableOrCompilable)}, | |||
{CC "isCompilable", CC "(" HS_METHOD2 ")Z", FN_PTR(isCompilable)}, | |||
{CC "isOverpass", CC "(" HS_METHOD2 ")Z", FN_PTR(isOverpass)}, |
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.
delete
for (Class<?> c : classes) { | ||
ResolvedJavaType type = metaAccess.lookupJavaType(c); | ||
Set<ResolvedJavaMethod> allMethods = new HashSet<>(type.getAllMethods(true)); | ||
boolean included = Arrays.stream(type.getDeclaredMethods()).allMatch(m -> allMethods.contains(m)); |
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.
You can produce a more helpful error message by collecting the entries from getDeclaredMethods, getDeclaredConstructors and the class initialized that are not in allMethods
.
I also updated the title of https://bugs.openjdk.org/browse/JDK-8357987 to Not Be All Capitalized so you'll need to fix the title of this PR. |
Currently from ResolvedJavaType one can retrieve all declared methods, static methods, and constructors of the given type. However, internally in HotSpot there are also VM-internal methods, such as overpass methods, associated with a given type which we cannot access via the API.
To correct this, we should add a new method which enables VM-internal methods, such as overpass methods, to be accessed.
Progress
Integration blocker
Warning
8357987: [JVMCI] Add Support for Retrieving All Non-Static Methods of a ResolvedJavaType.
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/25498/head:pull/25498
$ git checkout pull/25498
Update a local copy of the PR:
$ git checkout pull/25498
$ git pull https://git.openjdk.org/jdk.git pull/25498/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 25498
View PR using the GUI difftool:
$ git pr show -t 25498
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/25498.diff
Using Webrev
Link to Webrev Comment