JDK-8307137: aarch64 MacroAssembler::lookup_interface_method could use conditional compare instead of branch

Peter Kessler OS peter.kessler at os.amperecomputing.com
Tue May 2 00:42:04 UTC 2023


> CCMP is error prone, being difficult to read and write.

Using CCMP does make one's head explode at first.  All the more reason to put some infrastructure around using it, and to provide some good examples of how to use it, and where not to use it.  I think searching key-value arrays is fairly common activity, not limited to the loops in itable stubs.

                                                ... peter

From: hotspot-dev <hotspot-dev-retn at openjdk.org> on behalf of Andrew Haley <aph-open at littlepinkcloud.com>
Date: Sunday, April 30, 2023 at 03:06
To: hotspot-dev at openjdk.org <hotspot-dev at openjdk.org>
Subject: Re: JDK-8307137: aarch64 MacroAssembler::lookup_interface_method could use conditional compare instead of branch
On 4/29/23 01:18, Peter Kessler OS wrote:
> I notice that src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp MacroAssembler::lookup_interface_method loops over the itable list with code that uses two branches: one to check for a null indicating the end of the list, and one to see if the appropriate entry has been found.  aarch64 has a "ccmp" instruction that can be used to evaluate two conditions with only one branch.  On an out-of-order implementation with more integer execution units than branch units, the trading of a branch for a ccmp can be beneficial.  The downside is that one has to check, after the loop has exited, which of the conditions cause the loop to exit, but if the loop executes more than once or twice, that is still a win.

I doubt that it'd be a win, but maybe. On out-of-order AArch64 boxes I know,
branch prediction tends to be very effective, so it won't make much difference.

Also, CCMP is error prone, being difficult to read and write. Unless
there's a significant advantage I wouldn't do it. Benchmarking might be hard
to do, though.

--
Andrew Haley  (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/hotspot-dev/attachments/20230502/655d9cbf/attachment.htm>


More information about the hotspot-dev mailing list