News for hackers. Stuff that matters.
Re:The Rust Calling Convention We Deserve by fleventynine on Friday April 19, 2024 @03:56AM (#40084370)
The current calling convention is terrible for small platforms, especially when using Result<> in return position. For large enums, the compiler should put the discriminant in a register and the large variants on the stack. As is, you pay a significant code size penalty for idiomatic rust error handling.
Re:The Rust Calling Convention We Deserve by planede on Friday April 19, 2024 @04:46AM (#40084591)
There were proposals for optimizing this kind of stuff for C++ in particular for error handling, like:

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p07...

> Throwing such values behaves as-if the function returned union{R;E;}+bool where on success the function returns the normal return value R and on error the function returns the error value type E, both in the same return channel including using the same registers. The discriminant can use an unused CPU flag or a register

Re:The Rust Calling Convention We Deserve by mananaysiempre on Friday April 19, 2024 @02:50PM (#40090641)
IBM BIOS and MS DOS calls used the carry flag as a boolean return or error indicator (the 8086 has instructions for manually setting and resetting it). I don’t think people do that these days except in manually-coded assembly, unfortunately (which the relevant parts of both BIOS and DOS also were of course).