fujitsu / xbyak_aarch64

Apache License 2.0
186 stars 39 forks source link

transparently handle long jumps #102

Closed neumannt closed 2 months ago

neumannt commented 2 months ago

Conditional branch instructions can only cross +-1MB (and bit test instructions only +-32KB), which can become a problem for large generated code. This commit fixes the problem by introducing jump thunks, i.e., when a target is out of reach for a conditional branch, it instead branches to an unconditional branch instruction, which can cross 128MB of code.

For branches to undefined labels we keep track of the next deadline when the target must appear at latest. If we do not see the label before the deadline we introduce an unconditional branch, too, to make sure that the target is reachable.

Jump thunks are omitted when convenient, i.e., preferably after other unconditional branches. If no unconditional branch is found before the next deadline an unconditional branch is introduced that skips the jump thunks.

herumi commented 2 months ago

Thank you for the patch. Please wait a moment.

neumannt commented 2 months ago

I have found a different solution to that problem, I will close this pull request.