Implements String.indexOf by scanning for the first and last characters of the 
needle within the haystack and using those found characters to compare the rest 
of the needle to the haystack substring. It supports both Latin1 and UTF-16 
encodings, and cases where the haystack is UTF-16 and the needle is Latin1.

Support for arbitrary-length needles is present, but needles of length 1 are 
handled via the `string_indexof_char_sve` helper instead.

The benchmarks below are compared to the commit `64e0cf4`, and used the 
TEST="micro:IndexOf.*" pattern.
The Delta column is the relative multiplier of the avgt metric (ms/op) as 
measured on the Arm Neoverse V2 and Arm Neoverse V3 platforms. Lower is better.

| Benchmark                                                | Arm Neoverse V2 
Delta | Arm Neoverse V3 Delta |
| -------------------------------------------------------- | 
--------------------- | --------------------- |
| StringIndexOf.advancedWithMediumSub                      |                 
0.592 |                 0.723 |
| StringIndexOf.advancedWithShortSub1                      |                 
1.083 |                 1.075 |
| StringIndexOf.advancedWithShortSub2                      |                 
0.752 |                 0.684 |
| StringIndexOf.constantPattern                            |                 
0.422 |                 0.931 |
| StringIndexOf.searchChar16LongSuccess                    |                 
1.000 |                 0.986 |
| StringIndexOf.searchChar16LongWithOffsetSuccess          |                 
1.025 |                 1.0   |
| StringIndexOf.searchChar16MediumSuccess                  |                 
0.995 |                 1.0   |
| StringIndexOf.searchChar16MediumWithOffsetSuccess        |                 
1.000 |                 1.0   |
| StringIndexOf.searchChar16ShortSuccess                   |                 
1.003 |                 0.996 |
| StringIndexOf.searchChar16ShortWithOffsetSuccess         |                 
1.000 |                 0.99  |
| StringIndexOf.searchCharLongSuccess                      |                 
1.000 |                 0.988 |
| StringIndexOf.searchCharLongWithOffsetSuccess            |                 
1.003 |                 1.001 |
| StringIndexOf.searchCharMediumSuccess                    |                 
0.960 |                 0.993 |
| StringIndexOf.searchCharMediumWithOffsetSuccess          |                 
0.996 |                 1.005 |
| StringIndexOf.searchCharShortSuccess                     |                 
1.001 |                 1.005 |
| StringIndexOf.searchCharShortWithOffsetSuccess           |                 
1.006 |                 0.989 |
| StringIndexOf.searchString16LongLatinSuccess             |                 
0.497 |                 0.42  |
| StringIndexOf.searchString16LongSuccess                  |                 
0.502 |                 0.445 |
| StringIndexOf.searchString16LongWithOffsetLatinSuccess   |                 
0.550 |                 0.492 |
| StringIndexOf.searchString16LongWithOffsetSuccess        |                 
0.556 |                 0.477 |
| StringIndexOf.searchString16MediumLatinSuccess           |                 
0.493 |                 0.472 |
| StringIndexOf.searchString16MediumSuccess                |                 
0.499 |                 0.49  |
| StringIndexOf.searchString16MediumWithOffsetLatinSuccess |                 
0.575 |                 0.571 |
| StringIndexOf.searchString16MediumWithOffsetSuccess      |                 
0.552 |                 0.533 |
| StringIndexOf.searchString16ShortLatinSuccess            |                 
0.503 |                 0.491 |
| StringIndexOf.searchString16ShortSuccess                 |                 
0.547 |                 0.767 |
| StringIndexOf.searchString16ShortWithOffsetLatinSuccess  |                 
1.036 |                 1.077 |
| StringIndexOf.searchString16ShortWithOffsetSuccess       |                 
0.869 |                 0.931 |
| StringIndexOf.success                                    |                 
0.848 |                 1.015 |
| StringIndexOf.successBig                                 |                 
0.391 |                 0.376 |
| StringIndexOfHuge.search16HugeEarlyMatch                 |                 
1.003 |                 0.286 |
| StringIndexOfHuge.search16HugeEarlyMatch16               |                 
1.036 |                 0.263 |
| StringIndexOfHuge.search16HugeLargeSubstring             |                 
0.999 |                 0.692 |
| StringIndexOfHuge.search16HugeLargeSubstring16           |                 
0.999 |                 0.558 |
| StringIndexOfHuge.search16HugeLargeSubstringNoMatch      |                 
0.994 |                 0.035 |
| StringIndexOfHuge.search16HugeLargeSubstringNoMatch16    |                 
1.029 |                 0.029 |
| StringIndexOfHuge.search16HugeLateMatch                  |                 
0.998 |                 0.468 |
| StringIndexOfHuge.search16HugeLateMatch16                |                 
1.027 |                 0.463 |
| StringIndexOfHuge.search16HugeMiddleMatch                |                 
0.995 |                 0.638 |
| StringIndexOfHuge.search16HugeMiddleMatch16              |                 
0.999 |                 0.558 |
| StringIndexOfHuge.search16HugeNoMatch                    |                 
1.000 |                 1.456 |
| StringIndexOfHuge.search16HugeNoMatch16                  |                 
0.996 |                 0.871 |
| StringIndexOfHuge.search16HugeWorstCase                  |                 
1.006 |                 0.407 |
| StringIndexOfHuge.search16HugeWorstCase16                |                 
1.048 |                 0.413 |
| StringIndexOfHuge.search16SmallEarlyMatch                |                 
0.999 |                 0.948 |
| StringIndexOfHuge.search16SmallEarlyMatch16              |                 
1.003 |                 0.553 |
| StringIndexOfHuge.search16SmallLateMatch                 |                 
0.244 |                 1.025 |
| StringIndexOfHuge.search16SmallLateMatch16               |                 
0.263 |                 0.846 |
| StringIndexOfHuge.search16SmallMidMatch                  |                 
0.723 |                 1.165 |
| StringIndexOfHuge.search16SmallMidMatch16                |                 
0.721 |                 0.924 |
| StringIndexOfHuge.search16SubstringLongerThanString      |                 
0.038 |                 0.977 |
| StringIndexOfHuge.search16SubstringLongerThanString16    |                 
0.037 |                 1.005 |
| StringIndexOfHuge.searchHugeEarlyMatch                   |                 
0.385 |                 0.286 |
| StringIndexOfHuge.searchHugeLargeSubstring               |                 
0.380 |                 0.494 |
| StringIndexOfHuge.searchHugeLargeSubstringNoMatch        |                 
0.457 |                 0.023 |
| StringIndexOfHuge.searchHugeLateMatch                    |                 
0.461 |                 0.321 |
| StringIndexOfHuge.searchHugeMiddleMatch                  |                 
2.112 |                 0.85  |
| StringIndexOfHuge.searchHugeNoMatch                      |                 
1.341 |                 0.787 |
| StringIndexOfHuge.searchHugeWorstCase                    |                 
0.325 |                 0.276 |
| StringIndexOfHuge.searchSmallEarlyMatch                  |                 
0.307 |                 0.551 |
| StringIndexOfHuge.searchSmallLateMatch                   |                 
0.844 |                 0.997 |
| StringIndexOfHuge.searchSmallMidMatch                    |                 
0.518 |                 1.049 |
| StringIndexOfHuge.searchSubstringLongerThanString        |                 
0.673 |                 1.004 |




---------
- [x] I confirm that I make this contribution in accordance with the [OpenJDK 
Interim AI Policy](https://openjdk.org/legal/ai).

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

Commit messages:
 - 8393101: Add support for SVE String.indexOf

Changes: https://git.openjdk.org/jdk/pull/33493/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=33493&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8393101
  Stats: 436 lines in 7 files changed: 340 ins; 0 del; 96 mod
  Patch: https://git.openjdk.org/jdk/pull/33493.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/33493/head:pull/33493

PR: https://git.openjdk.org/jdk/pull/33493

Reply via email to