Is it time for D 3.0?

NaN divide at by.zero
Fri Mar 27 22:26:11 UTC 2020


On Friday, 27 March 2020 at 20:16:19 UTC, H. S. Teoh wrote:
> On Fri, Mar 27, 2020 at 03:08:51PM -0400, Steven Schveighoffer
>
>
> Honestly, I think cheap Exceptions could be done transparently 
> of user code, for the most part.  Instead of using libunwind or 
> equivalent, for example, just change the ABI to propagate an 
> out-of-band error indicator that, say in a register or 
> something that gets checked by the caller and branches to the 
> function's exit block if set.

Why not just pass the address of the error handler into the 
callee? So instead of

foo()
if (R12) goto i_see_dead_people;

void foo()
{
     if (zombies) { R12 = err; return; }
}

you do...

R12 = &i_see_dead_people
foo();

void foo()
{
     if (zombies) { return to R12; }
}

On x86 at least you could just poke the alternate return address 
into the stack and do RET as you would for normal return. So in 
the non-error path it's a single LEA instruction, vs a compare 
and conditional branch if using an extra return value.


More information about the Digitalmars-d mailing list