On Thu, 15 Jan 2026 04:24:24 GMT, Volodymyr Paprotski <[email protected]>
wrote:
> Failure always for UU case, needle=2, len=17
> - (Note: `len=len-offset` in `library_call.cpp`, ie. stub does not see the
> same len as the test case)
>
> Following down the code layout:
>
> if len==0
> return 0
> if len>needle
> return -1
> if len<=16|32 && needle<=3|6
> optimized_short_cases
> if len>16|32
> // big switch
> switch(needle) {
> default >10
> cases 2..10 // BUG IS HERE: len 17|34, needle 2|4, case=4
> }
> else
> // small switch
> switch(needle) {
> cases 7..10
> // others under optimized_short_cases
> }
>
> Furthermore.. big switch case itself has two cases..
>
> if len-needle>31
> // works
> // loop
> else // len-needle<=31
> // BUG HERE
>
> The else case corrects mask misalignment; the 'correction shift' is off-by-1
> for the UTF16 case.
>
> -----
> Why not found before?
> - testcase issue, needle was UTF8 for UTF16 case
>
> Why only needle==2?
> - Possibly because the mask for words has two bits, so tolerated off-by-one
This pull request has now been integrated.
Changeset: 1d889b92
Author: Volodymyr Paprotski <[email protected]>
URL:
https://git.openjdk.org/jdk/commit/1d889b92bde5dfcb1fbe6cddb389a77f92eb1ce7
Stats: 19 lines in 2 files changed: 11 ins; 0 del; 8 mod
8360271: String.indexOf intrinsics fail with +EnableX86ECoreOpts and
-CompactStrings
Reviewed-by: thartmann, jbhateja, sviswanathan
-------------
PR: https://git.openjdk.org/jdk/pull/29242