Browse Source

slight improvement

Jeremy Siek 4 năm trước cách đây
mục cha
commit
bc1c7271cc
1 tập tin đã thay đổi với 25 bổ sung24 xóa
  1. 25 24
      book.tex

+ 25 - 24
book.tex

@@ -5135,7 +5135,7 @@ conclusion:
 \node (x86-2-1) at (3,-6)  {\large $\text{x86}^{*}_1$};
 \node (x86-2-2) at (6,-6)  {\large $\text{x86}^{*}_1$};
 
-\path[->,bend left=15] (R2) edge [above] node {\ttfamily\footnotesize\color{red} typecheck} (R2-2);
+\path[->,bend left=15] (R2) edge [above] node {\ttfamily\footnotesize\color{red} type-check} (R2-2);
 \path[->,bend left=15] (R2-2) edge [above] node {\ttfamily\footnotesize\color{red} shrink} (R2-3);
 \path[->,bend left=15] (R2-3) edge [above] node {\ttfamily\footnotesize uniquify} (R2-4);
 \path[->,bend left=15] (R2-4) edge [right] node {\ttfamily\footnotesize remove-complex.} (R2-5);
@@ -5563,13 +5563,13 @@ the \code{void?} predicate that returns \code{\#t} when applied to
 \label{fig:interp-R3}
 \end{figure}
 
-Figure~\ref{fig:typecheck-R3} shows the type checker for $R_3$, which
+Figure~\ref{fig:type-check-R3} shows the type checker for $R_3$, which
 deserves some explanation. As we see in Section~\ref{sec:GC}, we
 need to know which variables contain pointers into the heap, that is,
 which variables contain vectors. Also, when allocating a vector, we
 need to know which elements of the vector are pointers. We can obtain
 this information during type checking. The type checker in
-Figure~\ref{fig:typecheck-R3} not only computes the type of an
+Figure~\ref{fig:type-check-R3} not only computes the type of an
 expression, it also wraps every sub-expression $e$ with the form
 $(\key{HasType}~e~T)$, where $T$ is $e$'s type.
 Subsequently, in the \code{uncover-locals} pass
@@ -5578,7 +5578,7 @@ propagated to all variables (including the temporaries generated by
 \code{remove-complex-opera*}).
 
 To create the s-expression for the \code{Vector} type in
-Figure~\ref{fig:typecheck-R3}, we use the
+Figure~\ref{fig:type-check-R3}, we use the
 \href{https://docs.racket-lang.org/reference/quasiquote.html}{unquote-splicing
   operator} \code{,@} to insert the list \code{t*} without its usual
 start and end parentheses.  \index{unquote-slicing}
@@ -5620,7 +5620,7 @@ start and end parentheses.  \index{unquote-slicing}
       )))
 \end{lstlisting}
 \caption{Type checker for the $R_3$ language.}
-\label{fig:typecheck-R3}
+\label{fig:type-check-R3}
 \end{figure}
 
 
@@ -6256,22 +6256,23 @@ $\itm{arg}'$) at the same time!
 
 We compile the \code{allocate} form to operations on the
 \code{free\_ptr}, as shown below. The address in the \code{free\_ptr}
-is the next free address in the FromSpace, so we move it into the
-\itm{lhs} and then move it forward by enough space for the tuple being
-allocated, which is $8(\itm{len}+1)$ bytes because each element is 8
-bytes (64 bits) and we use 8 bytes for the tag. Last but not least, we
-initialize the \itm{tag}. Refer to Figure~\ref{fig:tuple-rep} to see
-how the tag is organized. We recommend using the Racket operations
+is the next free address in the FromSpace, so we copy it into
+\code{r11} and then move it forward by enough space for the tuple
+being allocated, which is $8(\itm{len}+1)$ bytes because each element
+is 8 bytes (64 bits) and we use 8 bytes for the tag.  We then
+initialize the \itm{tag} and finally copy the address in \code{r11} to
+the left-hand-side. Refer to Figure~\ref{fig:tuple-rep} to see how the
+tag is organized. We recommend using the Racket operations
 \code{bitwise-ior} and \code{arithmetic-shift} to compute the tag
 during compilation.  The type annotation in the \code{vector} form is
 used to determine the pointer mask region of the tag.
 \begin{lstlisting}
    |$\itm{lhs}$| = (allocate |$\itm{len}$| (Vector |$\itm{type} \ldots$|));
    |$\Longrightarrow$|
-   movq free_ptr(%rip), |$\itm{lhs}'$|
+   movq free_ptr(%rip), %r11
    addq |$8(\itm{len}+1)$|, free_ptr(%rip)
-   movq |$\itm{lhs}'$|, %r11
    movq $|$\itm{tag}$|, 0(%r11)
+   movq %r11, |$\itm{lhs}'$|
 \end{lstlisting}
 
 The \code{collect} form is compiled to a call to the \code{collect}
@@ -6578,7 +6579,7 @@ conclusion:
 \node (x86-2-1) at (3,-6)  {\large $\text{x86}^{*}_2$};
 \node (x86-2-2) at (6,-6)  {\large $\text{x86}^{*}_2$};
 
-\path[->,bend left=15] (R3) edge [above] node {\ttfamily\footnotesize\color{red} typecheck} (R3-2);
+\path[->,bend left=15] (R3) edge [above] node {\ttfamily\footnotesize\color{red} type-check} (R3-2);
 \path[->,bend left=15] (R3-2) edge [above] node {\ttfamily\footnotesize shrink} (R3-3);
 \path[->,bend left=15] (R3-3) edge [above] node {\ttfamily\footnotesize uniquify} (R3-4);
 \path[->,bend left=15] (R3-4) edge [right] node {\ttfamily\footnotesize\color{red} expose-alloc.} (R3-5);
@@ -7754,7 +7755,7 @@ of your previously created test programs.
 \node (x86-2-2) at (6,-6)  {\large $\text{x86}^{*}_3$};
 
 \path[->,bend left=15] (R4) edge [above] node
-     {\ttfamily\footnotesize\color{red} typecheck} (R4-2);
+     {\ttfamily\footnotesize\color{red} type-check} (R4-2);
 \path[->,bend left=15] (R4-2) edge [above] node
      {\ttfamily\footnotesize uniquify} (R4-3);
 \path[->,bend left=15] (R4-3) edge [right] node
@@ -8134,7 +8135,7 @@ values.
 \label{sec:type-check-r5}
 \index{type checking}
 
-Figure~\ref{fig:typecheck-R5} shows how to type check the new
+Figure~\ref{fig:type-check-R5} shows how to type check the new
 \key{lambda} form. The body of the \key{lambda} is checked in an
 environment that includes the current environment (because it is
 lexically scoped) and also includes the \key{lambda}'s parameters.  We
@@ -8142,7 +8143,7 @@ require the body's type to match the declared return type.
 
 \begin{figure}[tbp]
 \begin{lstlisting}
-(define (typecheck-R5 env)
+(define (type-check-R5 env)
   (lambda (e)
     (match e
       [(Lambda (and bnd `([,xs : ,Ts] ...)) rT body)
@@ -8158,7 +8159,7 @@ require the body's type to match the declared return type.
       )))
 \end{lstlisting}
 \caption{Type checking the \key{lambda}'s in $R_5$.}
-\label{fig:typecheck-R5}
+\label{fig:type-check-R5}
 \end{figure}
 
 
@@ -8338,7 +8339,7 @@ $\Downarrow$
 \node (x86-2-2) at (6,-6)  {\large $\text{x86}^{*}_3$};
 
 \path[->,bend left=15] (R4) edge [above] node
-     {\ttfamily\footnotesize\color{red} typecheck} (R4-2);
+     {\ttfamily\footnotesize\color{red} type-check} (R4-2);
 \path[->,bend left=15] (R4-2) edge [above] node
      {\ttfamily\footnotesize uniquify} (R4-3);
 \path[->] (R4-3) edge [right] node
@@ -8641,16 +8642,16 @@ if the tag corresponds to the predicate, and return \key{\#t}
 otherwise.
 %
 Selections from the type checker for $R_6$ are shown in
-Figure~\ref{fig:typecheck-R6} and the interpreter for $R_6$ is in
+Figure~\ref{fig:type-check-R6} and the interpreter for $R_6$ is in
 Figure~\ref{fig:interp-R6}.
 
 \begin{figure}[btp]
 \begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
 (define (flat-ty? ty) ...)
 
-(define (typecheck-R6 env)
+(define (type-check-R6 env)
   (lambda (e)
-    (define recur (typecheck-R6 env))
+    (define recur (type-check-R6 env))
     (match e
        [`(inject ,e ,ty)
         (unless (flat-ty? ty)
@@ -8683,7 +8684,7 @@ Figure~\ref{fig:interp-R6}.
       )))
 \end{lstlisting}
 \caption{Type checker for parts of the $R_6$ language.}
-\label{fig:typecheck-R6}
+\label{fig:type-check-R6}
 \end{figure}
 
 % to do: add rules for vector-ref, etc. for Vectorof
@@ -9307,7 +9308,7 @@ registers.
 %%  LocalWords:  runtime Liveness liveness undirected Balakrishnan je
 %%  LocalWords:  Rosen DSATUR SDO Gebremedhin Omari morekeywords cnd
 %%  LocalWords:  fullflexible vertices Booleans Listof Pairof thn els
-%%  LocalWords:  boolean typecheck notq cmpq sete movzbq jmp al xorq
+%%  LocalWords:  boolean type-check notq cmpq sete movzbq jmp al xorq
 %%  LocalWords:  EFLAGS thns elss elselabel endlabel Tuples tuples os
 %%  LocalWords:  tuple args lexically leaq Polymorphism msg bool nums
 %%  LocalWords:  macosx unix Cormen vec callee xs maxStack numParams