Write more about C++ exn

This commit is contained in:
Théophile Bastian 2018-08-04 13:33:00 +02:00
parent ec17205086
commit 86012c7d5e
2 changed files with 29 additions and 0 deletions

View file

@ -177,6 +177,17 @@ necessary to be able to unwind frames, one by one, until a suitable
\lstc{catch} block is found. The C++ language, for one, includes a
stack-unwinding library similar to \prog{libunwind} in its runtime.
Technically, exception handling could be implemented without any stack
unwinding, by using \lstc{setjmp}/\lstc{longjmp} mechanics~\cite{niditoexn}.
However, this is not possible in C++ (and some other languages), because the
stack needs to be properly unwound in order to trigger the destructors of
stack-allocated objects. Furthermore, this is often undesirable: \lstc{setjmp}
has a quite big overhead, which is introduced whenever a \lstc{try} block is
encountered. Instead, it is often preferred to have strictly no overhead when
no exception happens, at the cost of a greater overhead when an exception is
actually fired (after all, they are supposed to be \emph{exceptional}). For
more details on C++ exception handling, see~\cite{dinechin2000exn}.
In both of these two previous cases, performance \emph{can} be a problem. In
the latter, a slow unwinding directly impacts the overall program performance,
particularly if a lot of exceptions are thrown and caught far away in their

View file

@ -32,3 +32,21 @@
year={2011}
}
@article{dinechin2000exn,
title={C++ exception handling},
author={De Dinechin, Christophe},
journal={IEEE Concurrency},
volume={8},
number={4},
pages={72--79},
year={2000},
publisher={IEEE}
}
@online{niditoexn,
title={Exceptions in C with Longjmp and Setjmp},
author={Nidito, Francesco},
url={https://www.di.unipi.it/~nids/docs/longjump_try_trow_catch.html},
urldate={2018-08-04}
}