|
@@ -8679,6 +8679,35 @@ your previously created test programs.
|
|
|
|
|
|
\clearpage
|
|
|
|
|
|
+
|
|
|
+\section{Expose Allocation}
|
|
|
+\label{sec:expose-allocation-r5}
|
|
|
+
|
|
|
+Compile the $\CLOSURE{\itm{arity}}{\LP\Exp\ldots\RP}$ form into code
|
|
|
+that allocates and initializes a vector, similar to the translation of
|
|
|
+the \code{vector} operator in Section~\ref{sec:expose-allocation}.
|
|
|
+The only difference is replacing the use of
|
|
|
+\ALLOC{\itm{len}}{\itm{type}} with
|
|
|
+\ALLOCCLOS{\itm{len}}{\itm{type}}{\itm{arity}}.
|
|
|
+
|
|
|
+
|
|
|
+\section{Select Instructions}
|
|
|
+\label{sec:select-instructions-R5}
|
|
|
+
|
|
|
+Compile the \ALLOCCLOS{\itm{len}}{\itm{type}}{\itm{arity}} form
|
|
|
+similar to the \ALLOC{\itm{len}}{\itm{type}} form
|
|
|
+(Section~\ref{sec:select-instructions-gc}). The only difference is
|
|
|
+that you should place the \itm{arity} in the tag that is stored at
|
|
|
+position $0$ of the vector. Recall that in
|
|
|
+Section~\ref{sec:select-instructions-gc} we used the first $56$ bits
|
|
|
+of the 64-bit tag, but that the rest were unused. So the arity goes
|
|
|
+into the tag in bit positions $57$ through $63$.
|
|
|
+
|
|
|
+Compile the \code{procedure-arity} operator into a sequence of
|
|
|
+instructions that access the tag from position $0$ of the vector and
|
|
|
+shift it by $57$ bits to the right.
|
|
|
+
|
|
|
+
|
|
|
\section{Challenge: Optimize Closures}
|
|
|
\label{sec:optimize-closures}
|
|
|
|