RFR: 8294961: Convert java.base/java.lang.reflect.ProxyGenerator to use the Classfile API to generate proxy classes [v3]

Adam Sotona asotona at openjdk.org
Thu Dec 21 01:36:52 UTC 2023


On Thu, 21 Dec 2023 01:12:07 GMT, Adam Sotona <asotona at openjdk.org> wrote:

>> java.base java.lang.reflect.ProxyGenerator uses ASM to generate proxy classes.
>> 
>> This patch converts it to use Classfile API.
>> 
>> It is continuation of https://github.com/openjdk/jdk/pull/10991
>> 
>> Any comments and suggestions are welcome.
>> 
>> Please review.
>> 
>> Thank you,
>> Adam
>
> Adam Sotona has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - performance improvements
>  - SplitConstantPool performance fix

Profiling of the benchmarks revealed several slowdowns:

- many expensive conversions from `Class<?>` to `ClassDesc` to `ClassEntry`, or even more expensive `MethodTypeDesc`
- building proxy class from scratch from symbols also involves a lot of `String` concatenations, hashing, encoding and comparisons
- computation of stack maps is also still expensive
- `SplitConstantPool` was ineffective in some specific cases

Proposed performance improvements use pre-generated template class and each proxy is then transformed with share constant pool.
Frequently used constant pool entries are materialized in the template class constant pool to avoid expensive conversions, comparisons and hashing.
Stack maps are generated manually.

Performance fixes related to ClassFile API `SplitConstantPool` and `StackCounter` may be separated into another PR. 
For now I keep them together to measure synergic effect.

Full benchmark numbers will be ready soon.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/17121#issuecomment-1865353203


More information about the core-libs-dev mailing list