Skip to content
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

(0.44.0) Removes incorrect check in fast path indexOf code #19513

Merged

Conversation

IBMJimmyk
Copy link
Contributor

@IBMJimmyk IBMJimmyk commented May 17, 2024

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

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 <[email protected]>
Copy link
Contributor

@zl-wang zl-wang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double delivery. LG.

@pshipton pshipton merged commit b069931 into eclipse-openj9:v0.44.0-release May 17, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants