On Wed, 25 Sep 2024 23:49:18 GMT, Chen Liang <li...@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. > > test/jdk/tools/jlink/JLink3500Packages.java line 35: > >> 33: /* >> 34: * @test >> 35: * @summary Make sure that 4000 packages in a uber jar can be linked >> using jlink. > > Should we mention that the number 3500 or 4000 is an arbitrary large number > greater than `ModuleDescriptorBuilder.SET_SIZE_THRESHOLD` to trigger the > provider method generation? The bug reported 3300+, I was planning for 4000 but realized we can only do 3500+ so changed to that later due to the byte code we generated for each export. The SET_SIZE_THRESHOLD is an arbitrary number. I will add a comment to mention that. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/21022#discussion_r1776176190