Stream: general

Topic: There are no zero-cost abstractions

RalfJ (Oct 22 2019 at 07:28, on Zulip):

Interesting talk on abstractions in C++ by Chandler, in particular the part about unique_ptr starting at
From what I understand, Rust doesn't have this problem, right? Our Box is 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.

oli (Oct 22 2019 at 09:41, on Zulip):

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

Laurențiu Nicola (Oct 22 2019 at 10:46, on Zulip):

I can't read the assembly right now, but panic handling seems to have some overhead here:

Laurențiu Nicola (Oct 22 2019 at 10:50, on Zulip):

I'm surprised that alloc::alloc::box_free and example::baz don't get folded

Laurențiu Nicola (Oct 22 2019 at 10:51, on Zulip):

And how is the code at the end of foo reached (the _Unwind_Resume block)?

Anton Tagunov (Oct 25 2019 at 01:33, on Zulip):

@Laurențiu Nicola : example:baz not folded liley due to #[inline(never)], 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?..

simulacrum (Oct 25 2019 at 01:59, on Zulip):

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)

simulacrum (Oct 25 2019 at 01:59, on Zulip):

(this is how exceptions in C++ work as well as our panics, or backtrace gathering for example)

simulacrum (Oct 25 2019 at 02:00, on Zulip):

I'm not sure how windows does it -- but probably something somewhat similar

Laurențiu Nicola (Oct 25 2019 at 06:11, on Zulip):

But box_free is also #[inline].. Good point about the unwinding, though.

Last update: Jun 04 2020 at 18:45UTC