[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Exceptions and local state
> Date: Fri, 13 Mar 1998 15:21:46 -0600
> From: "Mark K. Gardner" <mkgardne@rtsl3.cs.uiuc.edu>
> [...]
> As I see it, the smallest change which will allow exceptions which can
> access local state is to allow nested procedure assignments. However,
> if we are going to make a change, we might as well also add the
> syntactic sugar. It would cost little in terms of compiler effort and
> size. Its runtime cost would be zero unless it were actually used.
Your assumption is that the local state is easily accessible. This
might be the case for simple single pass compilers, but it doesn't
hold for compilers based on GSA (or SSA) form. Just inspecting the
activation record of a procedure is not sufficient.
In the best case a local variable is never written into the activation
record, but rather lives in registers over its whole lifetime. That
is, the variable will never be part of the procedure's local state as
stored on the activation stack.
Some values may never be created explicitly. That is, they never
exist in memory _or_ in a register. Example: When iterating over an
array with a FOR loop the iteration variable can often be converted in
a pointer traversing the array elements. The iteration variable can
then be optimized away.
Even if you have the local state of a procedure at the place of an
exception it is possible that this state doesn't correspond to the
sequence of instructions in the source program. Typically OOC's
backend overlaps and reorders instructions. This means that the
generated code produces a sequence of states that differs from the
states created by the assignments of the source code. The first and
the last state will be identical for both source and target code (or
the compiler is buggy), but there doesn't need to be a one-to-one
mapping of the states in between.
In short: The local state of a procedure during execution differs
vastly from the local state suggested by the source program. It is
very expensive to map towards the "source" state, and there might be
situations where such a mapping is altogether impossible.
-- mva