|
@@ -13265,13 +13265,13 @@ the passes to handle arrays.
|
|
|
\subsection{Overload Resolution}
|
|
|
\label{sec:array-resolution}
|
|
|
|
|
|
-As noted above, with the addition of arrays, several operators have
|
|
|
-become \emph{overloaded}, that is, they can be applied to values of
|
|
|
-more than one type. In this case, the element access and \code{len}
|
|
|
+As noted previously, with the addition of arrays, several operators
|
|
|
+have become \emph{overloaded}; that is, they can be applied to values
|
|
|
+of more than one type. In this case, the element access and \code{len}
|
|
|
operators can be applied to both tuples and arrays. This kind of
|
|
|
overloading is quite common in programming languages, so many
|
|
|
-compilers perform \emph{overload resolution}\index{subject}{overload resolution}
|
|
|
-to handle it. The idea is to translate each overloaded
|
|
|
+compilers perform \emph{overload resolution}\index{subject}{overload
|
|
|
+ resolution} to handle it. The idea is to translate each overloaded
|
|
|
operator into different operators for the different types.
|
|
|
|
|
|
Implement a new pass named \code{resolve}.
|
|
@@ -13282,7 +13282,7 @@ and the writing of an array element to
|
|
|
\racket{\code{vectorof-set!}}\python{\code{array\_store}}
|
|
|
Translate calls to \racket{\code{vector-length}}\python{\code{len}}
|
|
|
into \racket{\code{vectorof-length}}\python{\code{array\_len}}.
|
|
|
-When these operators are applied to tuples, leave them as-is.
|
|
|
+When these operators are applied to tuples, leave them as is.
|
|
|
%
|
|
|
\python{The type checker for \LangArray{} adds a \code{has\_type}
|
|
|
field which can be inspected to determine whether the operator
|
|
@@ -13333,17 +13333,17 @@ equal to zero and less than the array's length.
|
|
|
This pass should translate array creation into lower-level
|
|
|
operations. In particular, the new AST node \ALLOCARRAY{\Exp}{\Type}
|
|
|
is analogous to the \code{Allocate} AST node for tuples. The $\Type$
|
|
|
-argument must be \ARRAYTY{T} where $T$ is the element type for the
|
|
|
+argument must be \ARRAYTY{T}, where $T$ is the element type for the
|
|
|
array. The \code{AllocateArray} AST node allocates an array of the
|
|
|
-length specified by the $\Exp$ (of type \INTTY), but does not initialize the elements of
|
|
|
-the array. Generate code in this pass to initialize the elements
|
|
|
-analogous to the case for tuples.
|
|
|
+length specified by the $\Exp$ (of type \INTTY), but does not
|
|
|
+initialize the elements of the array. Generate code in this pass to
|
|
|
+initialize the elements analogous to the case for tuples.
|
|
|
|
|
|
\subsection{Remove Complex Operands}
|
|
|
|
|
|
Add cases in the \code{rco\_atom} and \code{rco\_exp} for
|
|
|
\code{AllocateArray}. In particular, an \code{AllocateArray} node is
|
|
|
-complex and its subexpression must be atomic.
|
|
|
+complex, and its subexpression must be atomic.
|
|
|
|
|
|
\subsection{Explicate Control}
|
|
|
|
|
@@ -13353,8 +13353,8 @@ Add cases for \code{AllocateArray} to \code{explicate\_tail} and
|
|
|
\subsection{Select Instructions}
|
|
|
|
|
|
Generate instructions for \code{AllocateArray} similar to those for
|
|
|
-\code{Allocate} in section~\ref{sec:select-instructions-gc} except
|
|
|
-that the tag at the front of the array should instead use the
|
|
|
+\code{Allocate} given in section~\ref{sec:select-instructions-gc}
|
|
|
+except that the tag at the front of the array should instead use the
|
|
|
representation discussed in section~\ref{sec:array-rep}.
|
|
|
|
|
|
Regarding \racket{\code{vectorof-length}}\python{\code{array\_len}},
|
|
@@ -13378,10 +13378,11 @@ runtime.
|
|
|
|
|
|
Implement a compiler for the \LangArray{} language by extending your
|
|
|
compiler for \LangLoop{}. Test your compiler on a half dozen new
|
|
|
-programs, including the one in figure~\ref{fig:inner_product} and also
|
|
|
-a program that multiplies two matrices. Note that although matrices
|
|
|
-are 2-dimensional arrays, they can be encoded into 1-dimensional
|
|
|
-arrays by laying out each row in the array, one after the next.
|
|
|
+programs, including the one shown in figure~\ref{fig:inner_product}
|
|
|
+and also a program that multiplies two matrices. Note that although
|
|
|
+matrices are two-dimensional arrays, they can be encoded into
|
|
|
+one-dimensional arrays by laying out each row in the array, one after
|
|
|
+the next.
|
|
|
|
|
|
\end{exercise}
|
|
|
|
|
@@ -13397,10 +13398,10 @@ allocated data is more likely to become garbage then data that has
|
|
|
survived one or more previous calls to \code{collect}. This insight
|
|
|
motivated the creation of \emph{generational garbage collectors}
|
|
|
\index{subject}{generational garbage collector} that
|
|
|
-1) segregates data according to its age into two or more generations,
|
|
|
-2) allocates less space for younger generations, so collecting them is
|
|
|
-faster, and more space for the older generations, and 3) performs
|
|
|
-collection on the younger generations more frequently then for older
|
|
|
+(1) segregate data according to its age into two or more generations;
|
|
|
+(2) allocate less space for younger generations, so collecting them is
|
|
|
+faster, and more space for the older generations; and (3) perform
|
|
|
+collection on the younger generations more frequently than on older
|
|
|
generations~\citep{Wilson:1992fk}.
|
|
|
|
|
|
For this challenge assignment, the goal is to adapt the copying
|