On Tue, 28 May 2024 17:30:24 GMT, Scott Gibbons <sgibb...@openjdk.org> wrote:

>> src/hotspot/cpu/x86/c2_stubGenerator_x86_64_string.cpp line 278:
>> 
>>> 276:   __ bind(L_nextCheck);
>>> 277:   __ testq(haystack_len_p, haystack_len_p);
>>> 278:   __ je(L_zeroCheckFailed);
>> 
>> This check could be removed as the next check covers this one.
>
> No.  This is checking for a zero length haystack.  The following compare 
> checks for needle length longer than haystack, regardless of the value in 
> each.  The comparison is signed, so a haystack length of 0 with a needle 
> length of -1 will pass the following test and assume validity.

But we have already checked for needle length to be greater than 0 in the 
following lines:
__ cmpq(needle_len_p, 0);
 __ jg_b(L_nextCheck);

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16753#discussion_r1617857240

Reply via email to