Integrated: 8360271: String.indexOf intrinsics fail with +EnableX86ECoreOpts and -CompactStrings
Volodymyr Paprotski
vpaprotski at openjdk.org
Thu Jan 15 23:14:55 UTC 2026
On Thu, 15 Jan 2026 04:24:24 GMT, Volodymyr Paprotski <vpaprotski at openjdk.org> 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 <vpaprotski at openjdk.org>
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
More information about the hotspot-compiler-dev
mailing list