(0.44.0) Removes incorrect check in fast path indexOf code #19513
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
For the recognized method
JITHelpers.intrinsicIndexOfLatin1
, the ch parameter is meant to be interpreted as an unsigned byte with a value of 0x00-0xFF. However, it gets passes into the method as a signed byte. This means for values 0x80-0xFF the data is sign extended inside of the register.The fast path code generated by
inlineIntrinsicIndexOf_P10
has a check the checks if the bits other than the lowest 8 bits are 0 and returns -1 early if this is the case. But, this check is wrong. It is possible to have a valid parameter where there upper bits are not 0 due to the sign extension.This fix removes the check and instead zeros out the bits other than the lowest 8 bits. This is safe to do since it is known in advance that the byte data is meant to be interpreted as an unsigned byte and it is not possible to pass in an invalid value to this parameter. Also, this is needed since the byte parameter is eventually compared against a loaded byte that was zero extended.
Fixes #18974
Port of #19503