RFR: 8365265: x86 short forward jump exceeds 8-bit offset in methodHandles_x86.cpp when using Intel APX

Andrew Haley aph at openjdk.org
Tue Aug 12 10:39:13 UTC 2025


On Tue, 12 Aug 2025 10:19:54 GMT, Aleksey Shipilev <shade at openjdk.org> wrote:

> > Well, yes. I'm suggesting that we should generate short branches automagically.
> 
> We do generate short branches auto-magically, but only for back-branches, where we know where the target is at the time we emit the jump. So _forward jumps_ get the short (pun intended) end of the stick.
> 
> I thought about this a bit a few years back: I can imagine how could one do multiple scratch emits that try to progressively figure out which forward jumps can be shortened. That would need to be iterative, because shortening an _inner_ jump likely opens opportunities for shortening more _outer_ jumps. Or maybe you can do this from the end, would that guarantee completeness?

Why would we want to guarantee anything? I'm tempted to quote Emerson here about "A foolish consistency..."
Do it once.

> Anyway, this opens a question how this all impacts compilation time. I guess it is not prohibitive for small code blobs like stubs. But then, going through all this hassle to only optimize stubs?

Yes. So that neither you nor I ever has to look at one of these PRs again.

> We might as well spend this time hand-optimizing the forward jumps by hand :)

But that's _boring_. Fixing the problem properly would be fun.

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

PR Comment: https://git.openjdk.org/jdk/pull/26731#issuecomment-3178765649


More information about the hotspot-compiler-dev mailing list