-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8294961: Convert java.base/java.lang.reflect.ProxyGenerator to use the Classfile API to generate proxy classes #10991
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
Conversation
…e and added test (openjdk#11)
…lang.reflect.AccesFlag in Classfile API and tests
…andleInfo implemented RebuildingTransformation and added to Transforms and CorpusTest reduced CorpusTestHelper output and adjusted TEST.properties
MethodParameterInfo name parameter changed to Optional added MethodParameterInfo::ofParameter(Optional<String>,int) implemented TemporaryConstantPool::stringEntry adjusted BoundAttribute and RebuildingTransformation test helper
EnclosingMethodAttribute factory method changed to accept Optionals added EnclosingMethodAttribute::of(ClassDesc,Optional<String>,Optional<MethodTypeDesc>) added EnclosingMethodAttribute accessor methods InnerClassInfo all factory methods changed to accept Optionals added NestHostAttribute::of(ClassDesc) added SourceIDAttribute::of(String) changes reflected in BoundAttribute and RebuildTransformation test helper
* added TypeAnnotation factory methods accepting ClassDesc and AnnotationElement... AnnotationValue.OfConstant sub-classed to allow switch pattern matching RebuildingTransformation test helper adjusted * added TypeAnnotation.TargetInfo factory methods with validity checking for multi-target types adjusted RebuildTransformation test helper
…Symbol (openjdk#13) refactored to FieldModel::fieldTypeSymbol and MethodModel::methodTypeSymbol (openjdk#13) added round testing of signatures in RebuildTransformation test helper
… a frame type. Doing so, make the chop size available to consumers of frames.
…ptor argument slots
| return i; | ||
| } | ||
| private Frame getFrame(int offset) { | ||
| for (var f : frames) { |
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.
How large is the frames list expected to be? We can probably perform binary searches if the list is too large.
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 number of frames is usually low, however I'll try to benchmark the difference.
Thanks.
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.
For ProxyGenerator the difference was insignificant, however in benchmarks transforming also more complex code it improved StackMapGenerator performance by approx. 7%.
| for (int i = 0; i < paramTypes.length; i++) { | ||
| paramTypes[i] = ClassDesc.ofDescriptor(types.get(i + 1)); | ||
| } | ||
| return new MethodTypeDescImpl(ret, paramTypes); |
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 have an alternative implementation in #13186 which somewhat speeds up for no-arg method types too; the code there no longer copies the parameter arrays on parameterList() calls, might help too (as a few places in Classfile API uses MethodTypeDesc.parameterList())
|
@asotona This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
|
Keep-alive. I believe the changes to cache ClassDesc symbol in ClassEntry and avoid re-computing hash in Utf8Entry can be in a separate patch delivered before the current migration patch. For the StackMapGenerator changes, I don't agree with replacing I also question the design to move away from var slots = type.parameterCount()
for (var param : type.parameterList()) // when parameterList is optimized
if (param.isPrimitive() && (param.descriptorString.charAt(0) == 'D' || param.descriptorString.charAt(0) == 'J')) slots++;Same for processing invoke instructions: if we can reuse the |
|
I agree, setting this PR back to draft. |
|
WRT MethodTypeDesc descriptor strings, you might get some performance improvements out of caching the string in MethodTypeDescImpl: Where Also, you can initialize this field directly in (FWIW, I don't think doing this is worth it for ClassDesc, since it already stores the descriptor directly). |
Frequently, |
| .map(ClassDesc::descriptorString) | ||
| .collect(Collectors.joining()), | ||
| returnType().descriptorString()); | ||
| var sb = new StringBuilder(); |
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.
Its not clear why this was changed, but if its for performance consider pre-sizing the StringBuilder.
Or consider an alternative using StringJoiner to avoid creating extra strings:
StringJoiner sj = new StringJoiner("", "(", returnType.descriptorString());
for (int i=0; i<parameterCount(); i++) {
sj.add(parameterType(i).descriptorString());
}
sj.add(")");
return sj.toString(); // toString performs the concatenation
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 would be better if StringJoiner can specify the number of elements it joins (we want parameterCount() + 3; unfortunately it can't.
|
@asotona This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration! |
|
@asotona This pull request has been inactive for more than 16 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the |
|
This PR cannot be rebased or merged, so it continues as #17121 |
java.base java.lang.reflect.ProxyGenerator uses ASM to generate proxy classes and this patch converts it to use Classfile API.
Please review.
Thank you,
Adam
Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/10991/head:pull/10991$ git checkout pull/10991Update a local copy of the PR:
$ git checkout pull/10991$ git pull https://git.openjdk.org/jdk.git pull/10991/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 10991View PR using the GUI difftool:
$ git pr show -t 10991Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/10991.diff
Webrev
Link to Webrev Comment