On Fri, 13 Dec 2024 19:30:19 GMT, Henry Jen <henry...@openjdk.org> wrote:

>> This PR split out large array/set construction into separate factory methods 
>> to avoid oversized method trying to construct several of those.
>> 
>> In order to do that, we will need to generate those help methods on demand 
>> in the class builder. Here we have two approach, one is for dedup set, which 
>> is processed in advance so we can know what methods should be created.
>> 
>> Another is for random set, such as packages, thus we put those request into 
>> a queue to amend the class later.
>> 
>> To keep the optimization of caching built value that are references more 
>> than once, it was implemented using local vars, which doesn't work well for 
>> helper methods. The existing approach to populate local vars doesn't work 
>> well with larger scope of split operation, as the slot was allocated on 
>> lazily built, but the transfer is captured in advance, this count could 
>> mismatch as built time and run time.
>> 
>> So we make this build in advance, and use a static array for values referred 
>> more than once.
>> 
>> All the codegen instead of giving index to be loaded, the builder snippet 
>> now load the wanted set/array to the operand stack to be consistent.
>
> Henry Jen has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Move up Snippet setup as a builder

src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Snippets.java line 74:

> 72:             return cob ->
> 73:                     cob.loadConstant(value)
> 74:                        
> .invokestatic(ClassDesc.ofInternalName("java/lang/Integer"), "valueOf", 
> MethodTypeDesc.of(CD_Integer, CD_int));

Suggestion:

                       .invokestatic(CD_Integer, "valueOf", 
MethodTypeDesc.of(CD_Integer, CD_int));

src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ModuleDescriptorBuilder.java
 line 166:

> 164:                     .ownerClassDesc(ownerClassDesc)
> 165:                     .methodNamePrefix("module" + index + "Requires")
> 166:                     .pageSize(2000) // number safe for a single page 
> helper under 64K size limit

Nit: define a constant for this number like `STRING_PAGE_SIZE`

src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModulesPlugin.java
 line 1205:

> 1203:                 *     dedupSetValues[countOfStoredValues - 1] = ...
> 1204:                 * }
> 1205:                 */

This javadoc also needs update.   The helper method name no longer uses 
"Provider" suffix.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/21022#discussion_r1884638693
PR Review Comment: https://git.openjdk.org/jdk/pull/21022#discussion_r1884637126
PR Review Comment: https://git.openjdk.org/jdk/pull/21022#discussion_r1884635868

Reply via email to