-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
transparent long branches #100
Comments
Hi @neumannt, thank you for the suggestion. @kawakami-k If ja(farLabel); generates ja(nearL);
b(nextL);
L(nearL);
b(farLabel);
L(nextL); . |
One difficulty here is that you might not have seen |
Sorry, I intended for the previous Label farLabel;
L(farLabel);
// huge code
ja(farLabel); If Label farLabel;
ja(farLabel, T_FAR); // forward references
// huge code
L(farLabel); If |
But using T_FAR pessimizes the generated code for something that rarely happens. I think it is better to generate jump thunks on demand instead of always generating them. I can try to write a prototype implementation to show you what I mean. It should not affect the current Xbyak_aarch64 interface, everything is internal. |
@neumannt , I see. Could you make a pull request for the feature? We'll check it. |
Conditional branches can only jump of to 1MB, which can be a problem for large generated code. xbyak could handle that transparently by branching to an unconditional branch instruction if needed, which can then breach 128MB.
We have a need for supporting large generated code and could contribute a patch. Would you be willing to accept such functionality? If yes, do you have any suggestions how to integrate that into the code base?
Our plan would be to patch the LabelManager to check the distances, and if a label is unreachable we would create a branch to a (pending) thunk instruction that then jumps unconditionally. These instructions would be emitted at the next convenient moment, e.g., after the next unconditional branch. In the unlikely event that there is no unconditional branch anywhere within 1MB of the original branch we would have to insert one, but that should never happen in reality.
The advantage of fixing this problem in xbyak instead of in the application is that xbyak can keep track of pending distances, which is not easily possible in the application itself.
The text was updated successfully, but these errors were encountered: