From 86012c7d5e05a156f2c4d247b127a402c45ab02f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Sat, 4 Aug 2018 13:33:00 +0200 Subject: [PATCH] Write more about C++ exn --- report/report.tex | 11 +++++++++++ shared/report.bib | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/report/report.tex b/report/report.tex index 6ad375c..644b87a 100644 --- a/report/report.tex +++ b/report/report.tex @@ -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 diff --git a/shared/report.bib b/shared/report.bib index ec00f11..020492a 100644 --- a/shared/report.bib +++ b/shared/report.bib @@ -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} +} +