RFR: 8307818: Convert Indify tool to Classfile API [v17]

Oussama Louati duke at openjdk.org
Mon Aug 12 09:35:19 UTC 2024


> An indify tool in j.l.i tests (also in vmTestBase) convert some source-code private static methods with MT_ MH_, and INDY_ prefixes into MethodHandle, MethodType, and CallSite constants.
> ### Purpose of Indify
> 
> -  **Transformation Tool**: `Indify` transforms existing class files to leverage `invokedynamic` and other JSR 292 features. This transformation allows for dynamic method calls.
> 
> ### Key Functions
> 
> - **Method Handle and Method Type Constants**:
>     - **MH_x and MT_x Methods**: These methods are used to generate `MethodHandle` and `MethodType` constants. The tool transforms calls to these methods into `CONSTANT_MethodHandle` and `CONSTANT_MethodType` "ldc" (load constant) instructions.
> -  **Invokedynamic Call Sites**:
>     - **INDY_x Methods**: These methods generate `invokedynamic` call sites. Each `INDY_x` method starts with a call to an `MH_x` method, which acts as the bootstrap method. This is followed by an `invokeExact` call.
>     - **Transformation**: The tool transforms pairs of calls (to `INDY_x` followed by `invokeExact`) into `invokedynamic` instructions. This mimics the JVM's handling of `invokedynamic` instructions, creating dynamic call sites that are linked at runtime.
> 
> It currently uses ad-hoc code to process class files and intends to migrate to ASM; but since we have the Classfile API, we can migrate to Classfile API instead.

Oussama Louati has updated the pull request incrementally with 10 additional commits since the last revision:

 - Update test/jdk/java/lang/invoke/indify/Indify.java
   
   Co-authored-by: ExE Boss <3889017+ExE-Boss at users.noreply.github.com>
 - Update test/jdk/java/lang/invoke/indify/Indify.java
   
   Co-authored-by: ExE Boss <3889017+ExE-Boss at users.noreply.github.com>
 - Update test/jdk/java/lang/invoke/indify/Indify.java
   
   Co-authored-by: ExE Boss <3889017+ExE-Boss at users.noreply.github.com>
 - Update test/jdk/java/lang/invoke/indify/Indify.java
   
   Co-authored-by: ExE Boss <3889017+ExE-Boss at users.noreply.github.com>
 - Update test/jdk/java/lang/invoke/indify/Indify.java
   
   Co-authored-by: ExE Boss <3889017+ExE-Boss at users.noreply.github.com>
 - Update test/jdk/java/lang/invoke/indify/Indify.java
   
   Co-authored-by: ExE Boss <3889017+ExE-Boss at users.noreply.github.com>
 - Update test/jdk/java/lang/invoke/indify/Indify.java
   
   Co-authored-by: ExE Boss <3889017+ExE-Boss at users.noreply.github.com>
 - Update test/jdk/java/lang/invoke/indify/Indify.java
   
   Co-authored-by: ExE Boss <3889017+ExE-Boss at users.noreply.github.com>
 - Update test/jdk/java/lang/invoke/indify/Indify.java
   
   Co-authored-by: ExE Boss <3889017+ExE-Boss at users.noreply.github.com>
 - Update test/jdk/java/lang/invoke/indify/Indify.java
   
   Co-authored-by: ExE Boss <3889017+ExE-Boss at users.noreply.github.com>

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/18841/files
  - new: https://git.openjdk.org/jdk/pull/18841/files/02347415..8cedaeaf

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=18841&range=16
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=18841&range=15-16

  Stats: 11 lines in 1 file changed: 0 ins; 0 del; 11 mod
  Patch: https://git.openjdk.org/jdk/pull/18841.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/18841/head:pull/18841

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


More information about the core-libs-dev mailing list