|
@@ -10146,30 +10146,30 @@ guaranteed that iteratively applying liveness analysis to all blocks
|
|
|
in the program will eventually produce the least fixed point solution.
|
|
|
|
|
|
Next let us consider dataflow analysis in general and discuss the
|
|
|
-generic work list algorithm (Figure~\ref{fig:generic-dataflow}).
|
|
|
+generic work list algorithm (Figure~\ref{fig:generic-dataflow}).
|
|
|
%
|
|
|
The algorithm has four parameters: the control-flow graph \code{G}, a
|
|
|
function \code{transfer} that applies the analysis to one block, the
|
|
|
\code{bottom} and \code{join} operator for the lattice of abstract
|
|
|
-states. The algorithm begins by creating the bottom mapping,
|
|
|
-represented by a hash table. It then pushes all of the nodes in the
|
|
|
-control-flow graph onto the work list (a queue). The algorithm repeats
|
|
|
-the \code{while} loop as long as there are items in the work list. In
|
|
|
-each iteration, a node is popped from the work list and processed. The
|
|
|
-\code{input} for the node is computed by taking the join of the
|
|
|
-abstract states of all the predecessor nodes. The \code{transfer}
|
|
|
-function is then applied to obtain the \code{output} abstract
|
|
|
-state. If the output differs from the previous state for this block,
|
|
|
-the mapping for this block is updated and its successor nodes are
|
|
|
-pushed onto the work list.
|
|
|
-
|
|
|
-Note that the \code{analyze\_dataflow} function is formulated as a
|
|
|
+states. The \code{analyze\_dataflow} function is formulated as a
|
|
|
\emph{forward} dataflow analysis, that is, the inputs to the transfer
|
|
|
function come from the predecessor nodes in the control-flow
|
|
|
graph. However, liveness analysis is a \emph{backward} dataflow
|
|
|
analysis, so in that case one must supply the \code{analyze\_dataflow}
|
|
|
function with the transpose of the control-flow graph.
|
|
|
|
|
|
+The algorithm begins by creating the bottom mapping, represented by a
|
|
|
+hash table. It then pushes all of the nodes in the control-flow graph
|
|
|
+onto the work list (a queue). The algorithm repeats the \code{while}
|
|
|
+loop as long as there are items in the work list. In each iteration, a
|
|
|
+node is popped from the work list and processed. The \code{input} for
|
|
|
+the node is computed by taking the join of the abstract states of all
|
|
|
+the predecessor nodes. The \code{transfer} function is then applied to
|
|
|
+obtain the \code{output} abstract state. If the output differs from
|
|
|
+the previous state for this block, the mapping for this block is
|
|
|
+updated and its successor nodes are pushed onto the work list.
|
|
|
+
|
|
|
+
|
|
|
\begin{figure}[tb]
|
|
|
{\if\edition\racketEd
|
|
|
\begin{lstlisting}
|
|
@@ -10511,7 +10511,6 @@ control-flow graphs of the later may contain cycles.
|
|
|
\fbox{
|
|
|
\begin{minipage}{0.96\textwidth}
|
|
|
\small
|
|
|
-{\if\edition\racketEd
|
|
|
\[
|
|
|
\begin{array}{l}
|
|
|
\gray{\CvarASTRacket} \\ \hline
|
|
@@ -10522,10 +10521,6 @@ control-flow graphs of the later may contain cycles.
|
|
|
\end{array}
|
|
|
\end{array}
|
|
|
\]
|
|
|
-\fi}
|
|
|
-{\if\edition\pythonEd
|
|
|
-UNDER CONSTRUCTION
|
|
|
-\fi}
|
|
|
\end{minipage}
|
|
|
}
|
|
|
\caption{The abstract syntax of \LangCLoop{}, extending \LangCIf{} (Figure~\ref{fig:c1-syntax}).}
|