Skip to content
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

Use relatives jumps #4804

Merged
merged 12 commits into from
Jul 18, 2023
Merged

Use relatives jumps #4804

merged 12 commits into from
Jul 18, 2023

Conversation

vaivaswatha
Copy link
Contributor

Description

Switch the compiler to use relative jumps instead of absolute jumps.

  1. The function relocate_control_flow is now removed. It used to move basic blocks around in case absolute addresses crossed the easily addressable boundary. The code movement can then avoid having to load the address to a register and using indirect jumps. This is unlikely to happen with relative jumps. But if it does, the existing algorithm wouldn't work anyway. So we can add a new one when required later.
  2. In the case of function call jumps, we use $pc to save the return address for the callee. This is a bit inefficient as it involves 3 extra computations: $$reta = ($pc - $is) / 4 + offset_to_return_point. We could change this to the following: Since we already have a common return point for every function, compute the relative offset from that point to the callee return point statically and use that. We don't have the infrastructure to do that right now, but it shouldn't be too difficult an extension.

Fixes #4443

@vaivaswatha vaivaswatha self-assigned this Jul 17, 2023
@vaivaswatha vaivaswatha marked this pull request as ready for review July 17, 2023 14:07
@vaivaswatha vaivaswatha requested a review from a team July 17, 2023 14:07
@IGI-111 IGI-111 requested a review from a team July 18, 2023 08:12
@vaivaswatha vaivaswatha enabled auto-merge (squash) July 18, 2023 15:49
@vaivaswatha vaivaswatha merged commit 01ee3cb into master Jul 18, 2023
27 checks passed
@vaivaswatha vaivaswatha deleted the vaivaswatha/reljmps branch July 18, 2023 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch over the compiler to use relative jumps
3 participants