nothrow by default
Gregor Mückl
gregormueckl at gmx.de
Fri Jan 10 14:52:45 UTC 2020
On Friday, 10 January 2020 at 07:06:31 UTC, Walter Bright wrote:
> On 1/9/2020 7:42 PM, Gregor Mückl wrote:
>> What exactly is the execution overhead for non-throwing code
>> paths?
>>
>> I believe I understand the overhead once stack unwinding needs
>> to be performed, but how is code generation affected for the
>> normal path?
>
> You need a mechanism for jumping to the scope guard code. Can't
> do any code motion optimizations across the boundaries of such
> code. Can't do register assignments for variables that are
> "live" across that boundary.
>
> Just write some code with destructors in C++, compile it with
> and without exceptions enabled, and dump the generated
> assembler.
I played around with this as you suggested. The most concise
example that I could find where -fno-exceptions makes a
difference is this:
https://godbolt.org/z/WxnsOm
The version with exceptions reserves a register for something at
the start of the function (rbp in this case), but I can't tell
what it's for. It is used in the unwinding handler that is
appended to the function after the ret instruction.
More information about the Digitalmars-d
mailing list