Browse Source

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

small fixes for chapter 6
Jeremy G. Siek 3 years ago
parent
commit
fde6b53773
1 changed files with 15 additions and 8 deletions
  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
 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
 indefinite, that is, a tuple lives forever from the programmer's
 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
   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
-  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
 \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}{
 \begin{array}{rcl}
   \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}
 }
 \newcommand{\LtupASTPython}{
 \begin{array}{lcl}
 \itm{cmp} &::= & \code{Is()} \\
-\Exp &::=& \TUPLE{\Exp^{+}} \MID \GET{\Exp}{\Exp} \\
+\Exp &::=& \TUPLE{\Exp^{+}} \MID \GET{\Exp}{\INT{\Int}} \\
      &\MID& \LEN{\Exp}
 \end{array}
 }
@@ -11060,7 +11061,8 @@ Figure~\ref{fig:type-check-Lvec}, we use the
 start and end parentheses. \index{subject}{unquote-slicing}}
 %
 \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]
@@ -11194,7 +11196,7 @@ way.
 
 So the goal of the garbage collector is twofold:
 \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
 \item reclaim the memory of everything else, that is, the
   \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
 serve as our running example.  It creates two tuples, one nested
 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
 {\if\edition\racketEd
 \begin{lstlisting}
@@ -11536,7 +11538,7 @@ of the tuple:
 \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
-\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}.
 %
 \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 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
 \begin{lstlisting}
    |$\itm{lhs}$| = (allocate |$\itm{len}$| (Vector |$\itm{type} \ldots$|));