| 1 | \chapter{Introduction}
|
|---|
| 2 |
|
|---|
| 3 | % Talk about Cforall and exceptions generally.
|
|---|
| 4 | This thesis goes over the design and implementation of the exception handling
|
|---|
| 5 | mechanism (EHM) of
|
|---|
| 6 | \CFA (pernounced sea-for-all and may be written Cforall or CFA).
|
|---|
| 7 | Exception handling provides dynamic inter-function control flow.
|
|---|
| 8 | There are two forms of exception handling covered in this thesis:
|
|---|
| 9 | termination, which acts as a multi-level return,
|
|---|
| 10 | and resumption, which is a dynamic function call.
|
|---|
| 11 | This seperation is uncommon because termination exception handling is so
|
|---|
| 12 | much more common that it is often assumed.
|
|---|
| 13 |
|
|---|
| 14 | Termination exception handling allows control to return to any previous
|
|---|
| 15 | function on the stack directly, skipping any functions between it and the
|
|---|
| 16 | current function.
|
|---|
| 17 | \begin{center}
|
|---|
| 18 | \input{callreturn}
|
|---|
| 19 | \end{center}
|
|---|
| 20 |
|
|---|
| 21 | Resumption exception handling calls a function, but asks the functions on the
|
|---|
| 22 | stack what function that is.
|
|---|
| 23 | \todo{Add a diagram showing control flow for resumption.}
|
|---|
| 24 |
|
|---|
| 25 | Although a powerful feature, exception handling tends to be complex to set up
|
|---|
| 26 | and expensive to use
|
|---|
| 27 | so they are often limited to unusual or ``exceptional" cases.
|
|---|
| 28 | The classic example of this is error handling, exceptions can be used to
|
|---|
| 29 | remove error handling logic from the main execution path and while paying
|
|---|
| 30 | most of the cost only when the error actually occurs.
|
|---|
| 31 |
|
|---|
| 32 | % Overview of exceptions in Cforall.
|
|---|
| 33 | This work describes the design and implementation of the \CFA EHM.
|
|---|
| 34 | The \CFA EHM implements all of the common exception features (or an
|
|---|
| 35 | equivalent) found in most other EHMs and adds some features of its own.
|
|---|
| 36 | The design of all the features had to be adapted to \CFA's feature set as
|
|---|
| 37 | some of the underlying tools used to implement and express exception handling
|
|---|
| 38 | in other languages are absent in \CFA.
|
|---|
| 39 | Still the resulting syntax resembles that of other languages:
|
|---|
| 40 | \begin{cfa}
|
|---|
| 41 | try {
|
|---|
| 42 | ...
|
|---|
| 43 | T * object = malloc(request_size);
|
|---|
| 44 | if (!object) {
|
|---|
| 45 | throw OutOfMemory{fixed_allocation, request_size};
|
|---|
| 46 | }
|
|---|
| 47 | ...
|
|---|
| 48 | } catch (OutOfMemory * error) {
|
|---|
| 49 | ...
|
|---|
| 50 | }
|
|---|
| 51 | \end{cfa}
|
|---|
| 52 |
|
|---|
| 53 | % A note that yes, that was a very fast overview.
|
|---|
| 54 | All the design and implementation of all of \CFA's EHM's features are
|
|---|
| 55 | described in detail throughout this thesis, whether they are a common feature
|
|---|
| 56 | or one unique to \CFA.
|
|---|
| 57 |
|
|---|
| 58 | % The current state of the project and what it contributes.
|
|---|
| 59 | All of these features have been added to the \CFA implemenation, along with
|
|---|
| 60 | a suite of test cases as part of this project.
|
|---|
| 61 | The implementation techniques are generally applicable in other programming
|
|---|
| 62 | languages and much of the design is as well.
|
|---|
| 63 | Some parts of the EHM use other features unique to \CFA and these would be
|
|---|
| 64 | harder to replicate in other programming languages.
|
|---|
| 65 |
|
|---|
| 66 | % Talk about other programming languages.
|
|---|
| 67 | Some existing programming languages that include EHMs/exception handling
|
|---|
| 68 | include C++, Java and Python. All three examples focus on termination
|
|---|
| 69 | exceptions which unwind the stack as part of the
|
|---|
| 70 | Exceptions also can replace return codes and return unions.
|
|---|
| 71 | In functional languages will also sometimes fold exceptions into monads.
|
|---|
| 72 |
|
|---|
| 73 | The contributions of this work are:
|
|---|
| 74 | \begin{enumerate}
|
|---|
| 75 | \item Designing \CFA's exception handling mechanism, adapting designs from
|
|---|
| 76 | other programming languages and the creation of new features.
|
|---|
| 77 | \item Implementing stack unwinding and the EHM in \CFA, including updating
|
|---|
| 78 | the compiler and the run-time environment.
|
|---|
| 79 | \item Designed and implemented a prototype virtual system.
|
|---|
| 80 | % I think the virtual system and per-call site default handlers are the only
|
|---|
| 81 | % "new" features, everything else is a matter of implementation.
|
|---|
| 82 | \end{enumerate}
|
|---|
| 83 |
|
|---|
| 84 | \todo{I can't figure out a good lead-in to the overview.}
|
|---|
| 85 | Covering the existing \CFA features in \autoref{c:existing}.
|
|---|
| 86 | Then the new features are introduce in \autoref{c:features}, explaining their
|
|---|
| 87 | usage and design.
|
|---|
| 88 | That is followed by the implementation of those features in
|
|---|
| 89 | \autoref{c:implement}.
|
|---|
| 90 | % Future Work \autoref{c:future}
|
|---|