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

Nice, thanks for the extra logs. Ok, the optimization is at least working. 
Maybe not always fully. In 1.2 we see that only 2 stores were merged, those 
from lines 71 and 72. So that would be a potential loss of performance. That 
could be interesting to debug. Can you create a stand-alone reproducer, so just 
a single java file, where the code looks as similar as here, an where it 
produces the same kind of `TraceMergeStores` output? I could look into that.

Also: do you expect only the "not" `isLatin1()` case to merge the stores, or 
also in the `isLatin1()` case? It would be interesting here to extract the 
relevant (and only the relevant) assembly code. There we would be looking for 
the stores. These would be byte-stores if not merged, and fewer but larger 
stores if merged. Since the assembly is annotated with the methods, you can 
find it relatively easily. You will be looking for `mov` kinds of instructions 
that store register values into addresses. You can easily learn more about 
assembly and `mov` instructions online.

General explanations of `mov` instructions:
https://c9x.me/x86/html/file_module_x86_id_176.html
https://www.felixcloutier.com/x86/mov

About the suffixes, i.e. `movq` vs `movl` etc.
https://stackoverflow.com/questions/67690999/assembly-do-we-need-the-endings

I hope this helps ;)

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

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

Reply via email to