浏览代码

Merge pull request #96 from Compiler-Construction-Uni-Freiburg/master

small fixes for chapter 6
Jeremy G. Siek 3 年之前
父节点
当前提交
fde6b53773
共有 1 个文件被更改,包括 15 次插入8 次删除
  1. 15 8
      book.tex

+ 15 - 8
book.tex

@@ -10693,7 +10693,7 @@ for the compilation of \LangLoop{}.
 In this chapter we study the implementation of
 In this chapter we study the implementation of
 tuples\racket{, called vectors in Racket}.
 tuples\racket{, called vectors in Racket}.
 %
 %
-This language feature is the first of ours to use the computer's
+This language feature is the first to use the computer's
 \emph{heap}\index{subject}{heap} because the lifetime of a tuple is
 \emph{heap}\index{subject}{heap} because the lifetime of a tuple is
 indefinite, that is, a tuple lives forever from the programmer's
 indefinite, that is, a tuple lives forever from the programmer's
 viewpoint. Of course, from an implementer's viewpoint, it is important
 viewpoint. Of course, from an implementer's viewpoint, it is important
@@ -10732,7 +10732,8 @@ Figure~\ref{fig:Lvec-concrete-syntax} defines the concrete syntax for
   tuple with the square bracket notation, i.e., \code{t[n]} returns
   tuple with the square bracket notation, i.e., \code{t[n]} returns
   the nth element of the tuple \code{t}, 3) the \code{is} comparison
   the nth element of the tuple \code{t}, 3) the \code{is} comparison
   operator, and 4) obtaining the number of elements (the length) of a
   operator, and 4) obtaining the number of elements (the length) of a
-  tuple.}
+  tuple. In this chapter, we restrict access indices to constant
+  integers.}
 %
 %
 The program below shows an example use of tuples. It creates a 3-tuple
 The program below shows an example use of tuples. It creates a 3-tuple
 \code{t} and a 1-tuple that is stored at index $2$ of the 3-tuple,
 \code{t} and a 1-tuple that is stored at index $2$ of the 3-tuple,
@@ -10779,13 +10780,13 @@ print( t[0] + t[2][0] if t[1] else 44 )
 \newcommand{\LtupGrammarPython}{
 \newcommand{\LtupGrammarPython}{
 \begin{array}{rcl}
 \begin{array}{rcl}
   \itm{cmp} &::= & \key{is} \\
   \itm{cmp} &::= & \key{is} \\
-  \Exp &::=& \Exp \key{,} \ldots \key{,} \Exp \MID \CGET{\Exp}{\Exp} \MID \CLEN{\Exp} 
+  \Exp &::=& \Exp \key{,} \ldots \key{,} \Exp \MID \CGET{\Exp}{\Int} \MID \CLEN{\Exp} 
 \end{array}
 \end{array}
 }
 }
 \newcommand{\LtupASTPython}{
 \newcommand{\LtupASTPython}{
 \begin{array}{lcl}
 \begin{array}{lcl}
 \itm{cmp} &::= & \code{Is()} \\
 \itm{cmp} &::= & \code{Is()} \\
-\Exp &::=& \TUPLE{\Exp^{+}} \MID \GET{\Exp}{\Exp} \\
+\Exp &::=& \TUPLE{\Exp^{+}} \MID \GET{\Exp}{\INT{\Int}} \\
      &\MID& \LEN{\Exp}
      &\MID& \LEN{\Exp}
 \end{array}
 \end{array}
 }
 }
@@ -11060,7 +11061,8 @@ Figure~\ref{fig:type-check-Lvec}, we use the
 start and end parentheses. \index{subject}{unquote-slicing}}
 start and end parentheses. \index{subject}{unquote-slicing}}
 %
 %
 \python{records the type of each tuple expression in a new field
 \python{records the type of each tuple expression in a new field
-  named \code{has\_type}.}
+  named \code{has\_type}. As the type checker has to compute the type
+  of each tuple access, the index must be a constant.}
 
 
 
 
 \begin{figure}[tp]
 \begin{figure}[tp]
@@ -11194,7 +11196,7 @@ way.
 
 
 So the goal of the garbage collector is twofold:
 So the goal of the garbage collector is twofold:
 \begin{enumerate}
 \begin{enumerate}
-\item preserve all tuple that are reachable from the root set via a
+\item preserve all tuples that are reachable from the root set via a
   path of pointers, that is, the \emph{live} tuples, and
   path of pointers, that is, the \emph{live} tuples, and
 \item reclaim the memory of everything else, that is, the
 \item reclaim the memory of everything else, that is, the
   \emph{garbage}.
   \emph{garbage}.
@@ -11459,7 +11461,7 @@ compiler passes. We introduce a new compiler pass named
 make minor changes in several more passes.  The following program will
 make minor changes in several more passes.  The following program will
 serve as our running example.  It creates two tuples, one nested
 serve as our running example.  It creates two tuples, one nested
 inside the other. Both tuples have length one. The program accesses
 inside the other. Both tuples have length one. The program accesses
-the element in the inner tuple tuple.
+the element in the inner tuple.
 % tests/vectors_test_17.rkt
 % tests/vectors_test_17.rkt
 {\if\edition\racketEd
 {\if\edition\racketEd
 \begin{lstlisting}
 \begin{lstlisting}
@@ -11536,7 +11538,7 @@ of the tuple:
 \VECTY{\racket{$\Type_1 \ldots \Type_n$}\python{$\Type_1, \ldots, \Type_n$}}
 \VECTY{\racket{$\Type_1 \ldots \Type_n$}\python{$\Type_1, \ldots, \Type_n$}}
 %
 %
 where $\Type_i$ is the type of the $i$th element in the tuple. The
 where $\Type_i$ is the type of the $i$th element in the tuple. The
-\CGLOBAL{\itm{name}} form reads the value of a global variable, such
+\CGLOBALVALUE{\itm{name}} form reads the value of a global variable, such
 as \code{free\_ptr}.
 as \code{free\_ptr}.
 %
 %
 \python{The \code{begin} form is an expression that executes a
 \python{The \code{begin} form is an expression that executes a
@@ -11945,6 +11947,11 @@ during compilation.}
 The type annotation in the \code{allocate} form is used to determine
 The type annotation in the \code{allocate} form is used to determine
 the pointer mask region of the tag.
 the pointer mask region of the tag.
 %
 %
+Do not worry about the addressing mode \verb!free_ptr(%rip)!. It
+essentially stands for the address \code{free\_ptr}, but uses a
+special instruction-pointer relative addressing mode of the x86-64
+processor. 
+%
 {\if\edition\racketEd
 {\if\edition\racketEd
 \begin{lstlisting}
 \begin{lstlisting}
    |$\itm{lhs}$| = (allocate |$\itm{len}$| (Vector |$\itm{type} \ldots$|));
    |$\itm{lhs}$| = (allocate |$\itm{len}$| (Vector |$\itm{type} \ldots$|));