News for hackers. Stuff that matters.
Re:The Rust Calling Convention We Deserve by leni536 on Friday April 19, 2024 @02:26AM (#40083952)
Yep. Also whether passing in registers is faster or not also depends on the function body. It doesn't make much sense if the first thing the function does is to take the address of the parameter and passes it to some opaque function. Then it needs to be spilled onto the stack anyway.

It would be interesting to see calling convention optimizations based on function body. I think that would be safe for static functions in C, as long as their address is not taken.

Re:The Rust Calling Convention We Deserve by __s on Friday April 19, 2024 @09:06AM (#40086328)
Dynamic calling conventions also won't work with dynamic linking
Re:The Rust Calling Convention We Deserve by kevincox on Saturday April 20, 2024 @04:42PM (#40100853)
Even when dynamic linking a lot of calls will be internal to each library. So you can either:

1. Use a stable calling convention for external interfaces.

2. Use a stable calling convention for everything, but generate trampolines for external calls.

Swift is actually pretty cool here. It basically does 2. But you can also specify which dependencies are "pinned" so that even if they are dynamically linked they can't be updated without a recompile. Then you can use the unstable calling convention when calling those dependencies.