RFR: 8321413: IllegalArgumentException: Code length outside the allowed range while creating a jlink image [v8]

Henry Jen henryjen at openjdk.org
Tue Oct 29 17:38:08 UTC 2024


On Mon, 28 Oct 2024 05:15:18 GMT, Henry Jen <henryjen at 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:
> 
>   Fix regression failed to setup helper methods properly

The latest changes have snippets for paginating array, and can build set on top of that. Tests on the snippets should ensure the pagination code working properly.
The ModuleDescriptorBuilder is brought into a separate file, ModuleInfoLoader, which can be used to generate bytecode to load a ModuleDesceriptor element onto the operand stack.
Then we use the paginated array to ensure construction of arrays/set will be paginated properly given we setup the generated helper method properly in the class.

This change should eliminate limitation on generated code size due to large array or set and shift the limitation factor to be the constant pool size.

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

PR Comment: https://git.openjdk.org/jdk/pull/21022#issuecomment-2444935228


More information about the core-libs-dev mailing list