2 ms·
> Exceptions only cause overheard when they happen. They only execute instructions when they happen... but they still inhibit the optimizer when they don't. Ca
by Rusky 9y ago
> Exceptions only cause overheard when they happen.
They only execute instructions when they happen... but they still inhibit the optimizer when they don't. Calls that may throw act like branches in the control flow graph. They also introduce more code bloat for their landing pads.
> Rust’s model for errors is tied to a specific implementation.
The Rust ABI is unspecified for a reason. We're currently seeing a lot of optimization around struct and enum layout; I'm not sure why this couldn't be applied to the calling convention without any extra syntax for "throw."
- kindfellow92 9y agoIt’s not exactly tied to that implementation but because error sum types are runtime values, it’s not clear whether a statement like “return foo” should return a normal value or do stack unwinding.
- kindfellow92 9y ago> They only execute instructions when they happen... but they still inhibit the optimizer when they don't. Calls that may throw act like branches in the control flow graph. This is a fair point and elucidates the trade off being made. Perhaps this is the reason C++11 has the “nothrow” attribute.