Integrated: 8358329: AArch64: emit direct branches in static stubs for small code caches
Mikhail Ablakatov
mablakatov at openjdk.org
Wed Jun 18 11:51:37 UTC 2025
On Mon, 9 Jun 2025 19:17:53 GMT, Mikhail Ablakatov <mablakatov at openjdk.org> wrote:
> In the A64 ISA, the B (direct branch) instruction can encode a target within a ±128MB range relative to the instruction. Due to this limitation, when generating static stubs, HotSpot conservatively emits indirect branches for calls to c2i interface stubs. These indirect branches are implemented using a four-instruction sequence: three instructions to materialize the target address in a register, followed by a BR instruction to perform the jump.
>
> This patch optimizes static stub generation when the code cache is small enough to guarantee that the target entry point of the c2i interface stub lies within the direct branch range. In such cases, a single direct B instruction can be used instead of the indirect sequence, saving 3 instructions (12 bytes) per static stub.
>
> Below is an example of the optimization's impact, measured using the movie-lens benchmark from the Renaissance benchmark suite:
>
> | Metric | Before | After | Difference |
> |-------------|---------------|---------------|------------|
> | totalInHeap | Avg: 1883.875 | Avg: 1871.667 | -0.65% |
> | | Sum: 6653848 | Sum: 6616344 | -0.56% |
> | stubCode | Avg: 103.164 | Avg: 87.285 | -15.38% |
> | | Sum: 364376 | Sum: 308552 | -15.33% |
>
> Full jtreg passed on AArch64.
This pull request has now been integrated.
Changeset: ba32b78b
Author: Mikhail Ablakatov <mablakatov at openjdk.org>
Committer: Evgeny Astigeevich <eastigeevich at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/ba32b78bfaf83f69003f83333ab6975b35343fde
Stats: 173 lines in 5 files changed: 154 ins; 13 del; 6 mod
8358329: AArch64: emit direct branches in static stubs for small code caches
Reviewed-by: aph, eastigeevich
-------------
PR: https://git.openjdk.org/jdk/pull/25702
More information about the hotspot-dev
mailing list