Interesting talk on abstractions in C++ by Chandler, in particular the part about
unique_ptr starting at https://youtu.be/rHIkrotSwcc?t=1053.
From what I understand, Rust doesn't have this problem, right? Our
repr(transparent) (I would not have expected that to make such a big difference, nice to see examples of the kind of code it avoids) and we have destructive moves.
Lol no we don't have this problem. We have other problems where we don't actually optimize our abstractions to be zero cost, but boxes aren't one of these problems
I can't read the assembly right now, but panic handling seems to have some overhead here: https://rust.godbolt.org/z/n7d-Li
I'm surprised that
example::baz don't get folded
And how is the code at the end of
foo reached (the
@Laurențiu Nicola :
example:baz not folded liley due to
box_free doesn't seem to be called.. however I share your surprise at the main question: how would the panic unwind path be hit?..
IIRC, at least on linux, the standard way is to encode via DWARF an unwind table that says where to jump to based on current stack layout (including the ability to do arbitrary operations on registers/memory to "unwind" to the appropriate place)
(this is how exceptions in C++ work as well as our panics, or backtrace gathering for example)
I'm not sure how windows does it -- but probably something somewhat similar
box_free is also
#[inline].. Good point about the unwinding, though.