Is it time for D 3.0?
H. S. Teoh
hsteoh at quickfur.ath.cx
Fri Mar 27 22:47:36 UTC 2020
On Fri, Mar 27, 2020 at 10:26:11PM +0000, NaN via Digitalmars-d wrote:
> On Friday, 27 March 2020 at 20:16:19 UTC, H. S. Teoh wrote:
[...]
> > 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.
That would work too, I guess.
The point is, these are all implementation details that can be
implemented in a way that's transparent to user code. It doesn't have
to be libunwind with its associated overhead that Walter did not like.
T
--
"Maybe" is a strange word. When mom or dad says it it means "yes", but when my big brothers say it it means "no"! -- PJ jr.
More information about the Digitalmars-d
mailing list