8274242: Implement fast-path for ASCII-compatible CharsetEncoders on x86

Reviewed-by: naoto, thartmann
This commit is contained in:
Claes Redestad 2021-09-29 12:58:14 +00:00
parent c4d115701d
commit aaa36cc006
28 changed files with 428 additions and 391 deletions

View file

@ -46,7 +46,7 @@ class StringCoding {
@IntrinsicCandidate
public static int implEncodeISOArray(byte[] sa, int sp,
byte[] da, int dp, int len) {
byte[] da, int dp, int len) {
int i = 0;
for (; i < len; i++) {
char c = StringUTF16.getChar(sa, sp++);
@ -57,4 +57,18 @@ class StringCoding {
return i;
}
@IntrinsicCandidate
public static int implEncodeAsciiArray(char[] sa, int sp,
byte[] da, int dp, int len)
{
int i = 0;
for (; i < len; i++) {
char c = sa[sp++];
if (c >= '\u0080')
break;
da[dp++] = (byte)c;
}
return i;
}
}

View file

@ -2419,6 +2419,10 @@ public final class System {
return String.decodeASCII(src, srcOff, dst, dstOff, len);
}
public int encodeASCII(char[] src, int srcOff, byte[] dst, int dstOff, int len) {
return StringCoding.implEncodeAsciiArray(src, srcOff, dst, dstOff, len);
}
public void setCause(Throwable t, Throwable cause) {
t.setCause(cause);
}