The CompactStrings JEP added intrinsic support for StringCoding.hasNegatives() on x86. We should implement an intrinsic for SPARC as well since CompactStrings is enabled by default.
The hasNegatives intrinsic is used to determine if a String in an ASCII-compatible encoding (for example, ISO-8859-1 (Latin1) or UTF-8) has only ASCII characters. If so, we can use a simple Arraycopy for some encodings/decodings. For example:
- Decoding from an ASCII-compatible representation to a Latin1 String can be done by a simple arraycopy if the input has only 7-bit ASCII characters.
- Encoding to an ASCII-compatible representation from a Latin1 String can be done by a simple arraycopy if the input has only 7-bit ASCII characters.