On Tue, 11 Jun 2024 11:35:28 GMT, Shaojin Wen <d...@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

Ah, another issue is method inlining. It seems that in 1.2, the method is not 
inlined:
` 103  StoreB  === 88 78 101 80  [[ 18 ]]  @byte[int:>=0] 
(java/lang/Cloneable,java/io/Serializable):exact+any *, idx=5;  Memory: 
@byte[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, 
idx=5; !jvms: StringUTF16::putChar @ bci:52 (line 72)`
In the extra information I only see `StringUTF16::putChar @ bci:52 (line 72)`, 
so this method was not inlined. So of course there are only the 2 stores to be 
merged from `putChar`. Maybe you can do something about this with 
`@ForceInline`. 

In 2.2 I see there is more inlining:
`  865  StoreB  === 656 839 863 45  [[ 885 ]]  @byte[int:>=0] 
(java/lang/Cloneable,java/io/Serializable):exact+any *, idx=10;  Memory: 
@byte[int:>=0] (java/lang/Cloneable,java/io/Serializable):NotNull:exact+any *, 
idx=10; !jvms: StringUTF16::putChar0 @ bci:19 (line 1587) 
StringUTF16::putCharsAt @ bci:34 (line 1572) AbstractStringBuilder::appendNull 
@ bci:63 (line 647) AbstractStringBuilder::append @ bci:5 (line 587) 
StringBuilder::append @ bci:2 (line 179)`
Though I cannot seem to map it to your java code, maybe you pasted things 
together wrongly here.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/19626#issuecomment-2162118831

Reply via email to