RFR: 8333893: Optimization for StringBuilder append boolean & null [v4]
Shaojin Wen
duke at openjdk.org
Wed Jun 12 13:41:18 UTC 2024
On Tue, 11 Jun 2024 11:35:28 GMT, Shaojin Wen <duke at openjdk.org> wrote:
>> After PR https://github.com/openjdk/jdk/pull/16245, C2 optimizes stores into primitive arrays by combining values into larger stores.
>>
>> This PR rewrites the code of appendNull and append(boolean) methods so that these two methods can be optimized by C2.
>
> Shaojin Wen has updated the pull request incrementally with one additional commit since the last revision:
>
> revert
In the AbstractStringBuilder#appendNull method, is it possible to not check the bounds based on the information from ensureCapacityInternal?
class AbstractStringBuilder {
private AbstractStringBuilder appendNull() {
int count = this.count;
ensureCapacityInternal(count + 4);
byte[] val = this.value;
if (isLatin1()) {
val[count ] = 'n';
val[count + 1] = 'u';
val[count + 2] = 'l';
val[count + 3] = 'l';
} else {
StringUTF16.putCharsAt(val, count, 'n', 'u', 'l', 'l');
}
this.count = count + 4;
return this;
}
}
-------------
PR Comment: https://git.openjdk.org/jdk/pull/19626#issuecomment-2163035274
More information about the core-libs-dev
mailing list