8339635: StringConcatFactory optimization for CompactStrings off

Reviewed-by: liach
This commit is contained in:
Shaojin Wen 2024-09-06 18:37:29 +00:00 committed by Chen Liang
parent 8e580ec538
commit fbe2629303
3 changed files with 15 additions and 1 deletions

View file

@ -2642,6 +2642,10 @@ public final class System {
return new StringConcatHelper.Concat1(constants);
}
public byte stringInitCoder() {
return String.COMPACT_STRINGS ? String.LATIN1 : String.UTF16;
}
public int getCharsLatin1(long i, int index, byte[] buf) {
return StringLatin1.getChars(i, index, buf);
}

View file

@ -1196,9 +1196,14 @@ public final class StringConcatFactory {
/**
* Construct the MethodType of the coder method. The first parameter is the initialized coder.
* Only parameter types which can be UTF16 are added. Returns null if no such parameter exists.
* Only parameter types which can be UTF16 are added.
* Returns null if no such parameter exists or CompactStrings is off.
*/
private static MethodTypeDesc coderArgsIfMaybeUTF16(MethodType concatArgs) {
if (JLA.stringInitCoder() != 0) {
return null;
}
int parameterCount = concatArgs.parameterCount();
int maybeUTF16Count = 0;