Re: RFR: 8294960: Convert java.base/java.lang.invoke package to use the Classfile API to generate lambdas and method handles [v14]

2024-06-06 Thread ExE Boss
On Wed, 5 Jun 2024 17:32:14 GMT, Adam Sotona  wrote:

>> java.base java.lang.invoke package heavily uses ASM to generate lambdas and 
>> method handles.
>> 
>> This patch converts ASM calls to Classfile API.
>> 
>> This PR is continuation of https://github.com/openjdk/jdk/pull/12945
>> 
>> Any comments and suggestions are welcome.
>> 
>> Please review.
>> 
>> Thank you,
>> Adam
>
> Adam Sotona has updated the pull request with a new target base due to a 
> merge or a rebase. The pull request now contains 24 commits:
> 
>  - Merge branch 'master' into JDK-8294960-invoke
>
># Conflicts:
>#  
> src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java
>  - Merge branch 'master' into JDK-8294960-invoke
>
># Conflicts:
>#  src/java.base/share/classes/java/lang/classfile/Attributes.java
>  - fixed CodeBuilder use in j.l.invoke
>  - Merge branch 'master' into JDK-8294960-invoke
>  - Merge pull request #4 from cl4es/boxunbox_holder
>
>Only create box/unbox MethodRefEntries on request
>  - Only create box/unbox MethodRefEntries on request
>  - Merge pull request #3 from cl4es/minor_init_improvements
>
>Reduce init overhead of InvokeBytecodeGenerator and StackMapGenerator
>  - Remove stray MRE_LF_interpretWithArguments
>  - Reduce init overhead of InvokeBytecodeGenerator and StackMapGenerator
>  - Deferred initialization of attributes map by moving into a holder class
>
>Co-authored-by: Claes Redestad 
>  - ... and 14 more: https://git.openjdk.org/jdk/compare/f73922b2...9360b0eb

These can all use `ReferenceClassDescImpl​::ofValidated(…)`:

src/java.base/share/classes/jdk/internal/classfile/impl/StackMapGenerator.java 
line 1259:

> 1257: LONG_ARRAY_TYPE = 
> referenceType(ClassDesc.ofDescriptor("[J")),
> 1258: DOUBLE_ARRAY_TYPE = 
> referenceType(ClassDesc.ofDescriptor("[D")),
> 1259: FLOAT_ARRAY_TYPE = 
> referenceType(ClassDesc.ofDescriptor("[F")),

Suggestion:

INT_ARRAY_TYPE = 
referenceType(ReferenceClassDescImpl.ofValidated("[I")),
BOOLEAN_ARRAY_TYPE = 
referenceType(ReferenceClassDescImpl.ofValidated("[Z")),
BYTE_ARRAY_TYPE = 
referenceType(ReferenceClassDescImpl.ofValidated("[B")),
CHAR_ARRAY_TYPE = 
referenceType(ReferenceClassDescImpl.ofValidated("[C")),
SHORT_ARRAY_TYPE = 
referenceType(ReferenceClassDescImpl.ofValidated("[S")),
LONG_ARRAY_TYPE = 
referenceType(ReferenceClassDescImpl.ofValidated("[J")),
DOUBLE_ARRAY_TYPE = 
referenceType(ReferenceClassDescImpl.ofValidated("[D")),
FLOAT_ARRAY_TYPE = 
referenceType(ReferenceClassDescImpl.ofValidated("[F")),

src/java.base/share/classes/jdk/internal/classfile/impl/StackMapGenerator.java 
line 1325:

> 1323: 
> 1324: private static final ClassDesc CD_Cloneable = 
> ClassDesc.ofDescriptor("Ljava/lang/Cloneable;");
> 1325: private static final ClassDesc CD_Serializable = 
> ClassDesc.ofDescriptor("Ljava/io/Serializable;");

Suggestion:

private static final ClassDesc CD_Cloneable = 
ReferenceClassDescImpl.ofValidated("Ljava/lang/Cloneable;");
private static final ClassDesc CD_Serializable = 
ReferenceClassDescImpl.ofValidated("Ljava/io/Serializable;");

-

PR Review: https://git.openjdk.org/jdk/pull/17108#pullrequestreview-2100944857
PR Review Comment: https://git.openjdk.org/jdk/pull/17108#discussion_r1628870728
PR Review Comment: https://git.openjdk.org/jdk/pull/17108#discussion_r1628871015


Re: RFR: 8294960: Convert java.base/java.lang.invoke package to use the Classfile API to generate lambdas and method handles [v14]

2024-06-05 Thread Adam Sotona
> java.base java.lang.invoke package heavily uses ASM to generate lambdas and 
> method handles.
> 
> This patch converts ASM calls to Classfile API.
> 
> This PR is continuation of https://github.com/openjdk/jdk/pull/12945
> 
> Any comments and suggestions are welcome.
> 
> Please review.
> 
> Thank you,
> Adam

Adam Sotona has updated the pull request with a new target base due to a merge 
or a rebase. The pull request now contains 24 commits:

 - Merge branch 'master' into JDK-8294960-invoke
   
   # Conflicts:
   #
src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java
 - Merge branch 'master' into JDK-8294960-invoke
   
   # Conflicts:
   #src/java.base/share/classes/java/lang/classfile/Attributes.java
 - fixed CodeBuilder use in j.l.invoke
 - Merge branch 'master' into JDK-8294960-invoke
 - Merge pull request #4 from cl4es/boxunbox_holder
   
   Only create box/unbox MethodRefEntries on request
 - Only create box/unbox MethodRefEntries on request
 - Merge pull request #3 from cl4es/minor_init_improvements
   
   Reduce init overhead of InvokeBytecodeGenerator and StackMapGenerator
 - Remove stray MRE_LF_interpretWithArguments
 - Reduce init overhead of InvokeBytecodeGenerator and StackMapGenerator
 - Deferred initialization of attributes map by moving into a holder class
   
   Co-authored-by: Claes Redestad 
 - ... and 14 more: https://git.openjdk.org/jdk/compare/f73922b2...9360b0eb

-

Changes: https://git.openjdk.org/jdk/pull/17108/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk=17108=13
  Stats: 2113 lines in 10 files changed: 422 ins; 861 del; 830 mod
  Patch: https://git.openjdk.org/jdk/pull/17108.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/17108/head:pull/17108

PR: https://git.openjdk.org/jdk/pull/17108