|
@@ -6,10 +6,9 @@
|
|
|
%% * adding letrec to the language
|
|
|
%% (Thought: in the book and regular course, replace top-level defines
|
|
|
%% with letrec.)
|
|
|
-%% * alternative back ends (ARM, LLVM)
|
|
|
+%% * alternative back ends (ARM!, LLVM)
|
|
|
%% * alternative calling convention (a la Dybvig)
|
|
|
%% * lazy evaluation
|
|
|
-%% * gradual typing
|
|
|
%% * continuations (frames in heap a la SML or segmented stack a la Dybvig)
|
|
|
%% * exceptions
|
|
|
%% * self hosting
|
|
@@ -19,17 +18,15 @@
|
|
|
%% * macros (too difficult?)
|
|
|
%% * alternative garbage collector
|
|
|
%% * alternative register allocator
|
|
|
-%% * parametric polymorphism
|
|
|
-%% * type classes (too difficulty?)
|
|
|
-%% * loops (too easy? combine with something else?)
|
|
|
+%% * type classes
|
|
|
%% * loop optimization (fusion, etc.)
|
|
|
%% * deforestation
|
|
|
-%% * records and subtyping
|
|
|
+%% * records with subtyping
|
|
|
%% * object-oriented features
|
|
|
%% - objects, object types, and structural subtyping (e.g. Abadi & Cardelli)
|
|
|
%% - class-based objects and nominal subtyping (e.g. Featherweight Java)
|
|
|
%% * multi-threading, fork join, futures, implicit parallelism
|
|
|
-%% * dataflow analysis, type analysis and specialization
|
|
|
+%% * type analysis and specialization
|
|
|
|
|
|
|
|
|
\documentclass[11pt]{book}
|
|
@@ -225,8 +222,8 @@ the students learned a lot and got excited about compilers.
|
|
|
|
|
|
I returned to Indiana University in 2013. In my absence the compiler
|
|
|
course had switched from the front-to-back organization to a
|
|
|
-back-to-front organization~\cite{Dybvig:2010aa}. Seeing how well the
|
|
|
-incremental approach worked at Colorado, I started porting and
|
|
|
+back-to-front~\cite{Dybvig:2010aa}. While that organization also works
|
|
|
+well, I prefer the incremental approach and started porting and
|
|
|
adapting the structure of the Colorado course back into the land of
|
|
|
Scheme. In the meantime Indiana University had moved on from Scheme to
|
|
|
Racket~\citep{plt-tr}, so the course is now about compiling a subset
|
|
@@ -2618,21 +2615,20 @@ The next exercise builds on Exercise~\ref{ex:pe-R1}.
|
|
|
Improve on the partial evaluator by replacing the \code{pe-neg} and
|
|
|
\code{pe-add} auxiliary functions with functions that know more about
|
|
|
arithmetic. For example, your partial evaluator should translate
|
|
|
-\begin{lstlisting}
|
|
|
-(+ 1 (+ (read) 1))
|
|
|
-\end{lstlisting}
|
|
|
-into
|
|
|
-\begin{lstlisting}
|
|
|
-(+ 2 (read))
|
|
|
-\end{lstlisting}
|
|
|
+\[
|
|
|
+\code{(+ 1 (+ (read) 1))} \qquad \text{into} \qquad
|
|
|
+\code{(+ 2 (read))}
|
|
|
+\]
|
|
|
To accomplish this, the \code{pe-exp} function should produce output
|
|
|
in the form of the $\itm{residual}$ non-terminal of the following
|
|
|
grammar.
|
|
|
\[
|
|
|
\begin{array}{lcl}
|
|
|
-\itm{inert} &::=& \Var \mid (\key{read}) \mid (\key{-} \;(\key{read}))
|
|
|
- \mid (\key{+} \; \itm{inert} \; \itm{inert})\\
|
|
|
-\itm{residual} &::=& \Int \mid (\key{+}\; \Int\; \itm{inert}) \mid \itm{inert}
|
|
|
+\itm{inert} &::=& \Var \mid \LP\key{read}\RP \mid \LP\key{-} \;\Var\RP
|
|
|
+ \mid \LP\key{-} \;\LP\key{read}\RP\RP
|
|
|
+ \mid \LP\key{+} \; \itm{inert} \; \itm{inert}\RP\\
|
|
|
+ &\mid& \LP\key{let}~\LP\LS\Var~\itm{inert}\RS\RP~ \itm{inert} \RP \\
|
|
|
+\itm{residual} &::=& \Int \mid \LP\key{+}\; \Int\; \itm{inert}\RP \mid \itm{inert}
|
|
|
\end{array}
|
|
|
\]
|
|
|
The \code{pe-add} and \code{pe-neg} functions may therefore assume
|
|
@@ -11016,7 +11012,6 @@ The \code{analyze-dataflow} function has four parameters.
|
|
|
Figure~\ref{fig:R8-passes} provides an overview of all the passes needed
|
|
|
for the compilation of $R_8$.
|
|
|
|
|
|
-
|
|
|
% TODO: challenge assignment
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
@@ -12176,6 +12171,9 @@ recommend the reader to the online gradual typing bibliography:
|
|
|
\url{http://samth.github.io/gradual-typing-bib/}
|
|
|
\end{center}
|
|
|
|
|
|
+% TODO: challenge problem:
|
|
|
+% type analysis and type specialization?
|
|
|
+% coercions?
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
\chapter{Parametric Polymorphism}
|
|
@@ -12801,13 +12799,7 @@ annotations and the body.
|
|
|
Figure~\ref{fig:R10-passes} provides an overview of all the passes needed
|
|
|
for the compilation of $R_{10}$.
|
|
|
|
|
|
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
-%% \chapter{High-level Optimization}
|
|
|
-%% \label{ch:high-level-optimization}
|
|
|
-
|
|
|
-%% This chapter will present a procedure inlining pass based on the
|
|
|
-%% algorithm of \citet{Waddell:1997fk}.
|
|
|
-
|
|
|
+% TODO: challenge problem: specialization of instantiations
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
\chapter{Appendix}
|