In many exception handling systems, if the foo subroutine calls a bar, which in turn throws a moo, and moo throws an exception, the only way this exception can purely return to foo is if bar "has a code to handle the exception. Even if the โbarโ allows to exclude the distribution of the non-displayable, it, as a rule, must ensure that its local variables are correctly destroyed before the execution is allowed to leave the scope. To do this, you need to add additional code to "bar"; on most systems, part of this code must be executed even if no exception is thrown.
BTW, on some ARM processors, such as Cortex M3, or as Arm7, working in ARM mode, if the caller will also work in ARM mode, you can allow exceptions without any cost to the execution time. Returning the โnormalโ subroutine goes to LR + 4 (four bytes per normal return address) and has an exclusive output in LR (which would then be a 4-byte branch instruction). However, this behavior will be contrary to the usual practice in ARM, and such a design will not be well ported to the Cortex M0.
supercat May 18 '11 at 20:02 2011-05-18 20:02
source share