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

Cleanup Rust fallback functions #699

Closed
randomPoison opened this issue Jan 30, 2024 · 1 comment
Closed

Cleanup Rust fallback functions #699

randomPoison opened this issue Jan 30, 2024 · 1 comment
Labels
low priority Issues that we would like to address at some point in the future

Comments

@randomPoison
Copy link
Collaborator

randomPoison commented Jan 30, 2024

For each of the routines that is implemented in platform-specific assembly, there are Rust fallback routines (originally C fallback routines) that are used when rav1d is built with asm disabled. A large part of this code is still raw c2rust output because cleanup of these routines wasn't necessary during the initial phases of development (initial development specifically focused on asm support, so the fallback routines weren't necessary).

Cleanup of these routines is also more difficult than other transpiled code because these routines need maintain an unsafe extern "C" interface since they replace unsafe asm calls. This often means that arguments can't be made fully safe, limiting how safe the body of the function can be. In general we try to split these functions into two parts:

  • foo_c_erased - An unsafe extern "C" function that acts as the fallback an asm routine.
  • foo_rust - A (hopefullly) safe implementation of the fallback routine.

The _c_erased variant takes the raw arguments that are passed to the asm routine and converts them to safe arguments to then pass to the _rust variant. This isn't always possible, though, and we may need to use unsafe arguments/operations in the _rust version.

@thedataking thedataking added the low priority Issues that we would like to address at some point in the future label Jan 31, 2024
@randomPoison
Copy link
Collaborator Author

The work covered by this task is now being tracked by the more general #839 and #835 issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
low priority Issues that we would like to address at some point in the future
Projects
None yet
Development

No branches or pull requests

2 participants