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
-------------
Commit messages:
- whitespace
- off-by-1 in UU/UL case
Changes: https://git.openjdk.org/jdk/pull/29242/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29242&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8360271
Stats: 19 lines in 2 files changed: 11 ins; 0 del; 8 mod
Patch: https://git.openjdk.org/jdk/pull/29242.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/29242/head:pull/29242
PR: https://git.openjdk.org/jdk/pull/29242