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.14) Fix and re-enable vectorized String.indexOf on 64-bit Power #5287

Merged

Conversation

aviansie-ben
Copy link
Contributor

As discussed in #5211, the fix for vectorized String.indexOf on 64-bit Power was merged after the 0.14 code split to allow further testing to weed out any possible issues before it was added to 0.14.

I've been watching both internal and external tests since the original change was merged and haven't seen any failures that could be attributed to this code being enabled again. Based on that, it should be safe to enable this code for the 0.14 release.

Due to the way that sign- and zero-extension of byte and char values
works on Power, the target character passed into the intrinsicIndexOf
helpers was sometimes sign-extended and sometimes not. However, the
evaluators responsible for generating the vectorized code for these
helpers was assuming that these values would always be zero-extended.
This was specifically causing problems when searching for bytes with
negative values, as they were sometimes sign-extended.

This has been fixed by making the evaluators always mask off the upper
bits before performing the initial scalar comparison, which is the only
part of the code which is making this assumption.

Signed-off-by: Ben Thomas <ben@benthomas.ca>
Previously, the code for inlining intrinsicIndexOf on Power was making
the assumption that the upper 32 bits of the registers containing the
array indices were well-defined (i.e. either zero extended or sign
extended). As it turns out, many 32-bit operations on Power can cause
the upper 32 bits of a register to be undefined. By making use of those
bits, we were causing undefined behaviour and, in some cases, would read
far beyond the end of the array, resulting in a segfault.

This has been corrected and the evaluator responsible for inlining the
vectorized versions of these methods will now correctly sign extend the
indices before making use of them.

Signed-off-by: Ben Thomas <ben@benthomas.ca>
Previously, the vectorized helpers for String.indexOf were disabled on
Power due to some difficult to reproduce segfaults that they appeared to
be causing. Now that these have (hopefully) been resolved, it should now
be safe to re-enable the vectorized versions of the helpers.

Note that these have only been re-enabled on 64-bit. These versions were
never intended to run on 32-bit and should not have been enabled.

Signed-off-by: Ben Thomas <ben@benthomas.ca>
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