-
Notifications
You must be signed in to change notification settings - Fork 738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove incorrect check in fast path indexOf code #19503
Conversation
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. Signed-off-by: jimmyk <jimmyk@ca.ibm.com>
I tested my changes across a large variety of inputs to Investigation into this problem initially started from this issue: #18974 As a result, I have removed the WIP tag. @zl-wang Could you take a look at this change and provide feedback on if anything needs to be changed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Jenkins test sanity.functional aix jdk8,jdk11,jdk17 |
plinux testing is skipped for the time being, due to UNB machine problem. jimmy personally tested plinux already. |
@IBMJimmyk pls create a PR against v0.44.0-release |
I created the v0.44.0 PR here: |
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