Why exceptions for error handling is so important
via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jan 13 13:23:43 PST 2015
On Tuesday, 13 January 2015 at 03:05:57 UTC, Walter Bright wrote:
> On 1/12/2015 4:40 PM, deadalnix wrote:
>> These are trash register. Meaning the callee can put whatever
>> in them. The
>> caller must consider them trashed after the call.
>>
>> So no, it do NOT increase register pressure.
>
> 1. the register must be assigned a value - that has a cost
xor on Haswell has a reciprocal throughput of 0.25, meaning
execution of 4 instructions per cycle per core.
> 3. it prevents EDX from being used by the return value, when
> the return value is larger than a single register size
Store the error in TLS memory using a write-through (no load from
memory) instruction and use the carry-flag instead then (assuming
the return instruction does not clear carry). CLC has reciprocal
throughput of 0.25 too.
> 4. static functions may not need to follow the C ABI register
> convention, and can be so optimized
D calls D, no problem.
D calls C, no problem, C can't return D errors...
C calls D, a problem no matter what solution you pick.
More information about the Digitalmars-d
mailing list