On Wed, 20 May 2026 15:54:18 GMT, Aleksey Shipilev <[email protected]> wrote:

>> src/hotspot/cpu/aarch64/stubGenerator_aarch64.cpp line 8551:
>> 
>>> 8549: 
>>> 8550:       Label default_loop;
>>> 8551:       __ BIND(default_loop);
>> 
>> How many iterations does this loop do when `length` is `0`? The `sub` below 
>> would underflow to `-1`, right? Is it possible to get here with `length == 
>> 0`?
>
> I think x86 has an explicit test for `length == 0`:
> https://github.com/openjdk/jdk/blob/6fb07f9b26bcd23f622a50c6ca5f23363b432f85/src/hotspot/cpu/x86/stubGenerator_x86_64_poly_mont.cpp#L740-L742

There is certainly the possibility of this happening. Most subtypes employ a 
hard-wired non-zero limb count but the constructor for 
`IntegerPolynomialModBinP` accepts a limb count argument which could certainly 
be passed as zero -- with zero length arrays then being employed for the limb 
data (obviously a negative count won't cut it). I'm not clear whether that 
would trip over other assumptions before a mult call could occur but it costs 
little to defend against the possibility that it might not so probably best to 
be safe?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/30941#discussion_r3279862454

Reply via email to