--- a/slides/slides09.tex Tue Nov 28 11:45:48 2023 +0000
+++ b/slides/slides09.tex Sat Dec 02 21:37:04 2023 +0000
@@ -5,10 +5,23 @@
\usepackage{../data}
\usepackage{../graphicss}
\usepackage{../grammar}
-\usepackage{soul}
-\usepackage{mathpartir}
+%\usepackage{soul}
+%\usepackage{mathpartir}
\usetikzlibrary{shapes,arrows,shadows}
+\usepackage[most]{tcolorbox}
+
+\newtcbox{\hl}[1][]{%
+ size=fbox,
+ tcbox raise base, nobeforeafter,
+ enhanced, colframe=gray,
+ colback=gray!30, boxrule=1pt,
+ fontupper=\ttfamily,
+ #1}
+
+
+
+
% beamer stuff
\renewcommand{\slidecaption}{CFL 09, King's College London}
\newcommand{\bl}[1]{\textcolor{blue}{#1}}
@@ -78,33 +91,80 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\begin{frame}[c, fragile]
-\frametitle{Stack Estimation}
-\small
-\mbox{}\\[-15mm]
+%\begin{frame}[c, fragile]
+%\frametitle{Stack Estimation}
+%\small
+%\mbox{}\\[-15mm]%
+%
+%\bl{\begin{center}
+%\begin{tabular}{@{\hspace{-4mm}}l@{\hspace{2mm}}c@{\hspace{2mm}}l@{}}
+%$\textit{estimate}(n)$ & $\dn$ & $1$\\
+%$\textit{estimate}(x)$ & $\dn$ & $1$\\
+%$\textit{estimate}(a_1\;aop\;a_2)$ & $\dn$ &
+%$\textit{estimate}(a_1) + \textit{estimate}(a_2)$\\
+%$\textit{estimate}(\pcode{if}\;b\;\pcode{then}\;e_1\;\pcode{else}\;e_2)$ & $\dn$ &
+%$\textit{estimate}(b) +$\\
+%& & $\quad max(\textit{estimate}(e_1), \textit{estimate}(e_2))$\\
+%$\textit{estimate}(\pcode{write}(e))$ & $\dn$ &
+%$\textit{estimate}(e) + 1$\\
+%$\textit{estimate}(e_1 ; e_2)$ & $\dn$ &
+%$max(\textit{estimate}(e_1), \textit{estimate}(e_2))$\\
+%$\textit{estimate}(f(e_1, ..., e_n))$ & $\dn$ &
+%$\sum_{i = 1..n}\;estimate(e_i)$\medskip\\
+%$\textit{estimate}(a_1\;bop\;a_2)$ & $\dn$ &
+%$\textit{estimate}(a_1) + \textit{estimate}(a_2)$\\
+%\end{tabular}
+%\end{center}}
+
+%\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+\begin{frame}[c,fragile]
+\frametitle{\mbox{}\hspace{5cm}Factorial}
-\bl{\begin{center}
-\begin{tabular}{@{\hspace{-4mm}}l@{\hspace{2mm}}c@{\hspace{2mm}}l@{}}
-$\textit{estimate}(n)$ & $\dn$ & $1$\\
-$\textit{estimate}(x)$ & $\dn$ & $1$\\
-$\textit{estimate}(a_1\;aop\;a_2)$ & $\dn$ &
-$\textit{estimate}(a_1) + \textit{estimate}(a_2)$\\
-$\textit{estimate}(\pcode{if}\;b\;\pcode{then}\;e_1\;\pcode{else}\;e_2)$ & $\dn$ &
-$\textit{estimate}(b) +$\\
-& & $\quad max(\textit{estimate}(e_1), \textit{estimate}(e_2))$\\
-$\textit{estimate}(\pcode{write}(e))$ & $\dn$ &
-$\textit{estimate}(e) + 1$\\
-$\textit{estimate}(e_1 ; e_2)$ & $\dn$ &
-$max(\textit{estimate}(e_1), \textit{estimate}(e_2))$\\
-$\textit{estimate}(f(e_1, ..., e_n))$ & $\dn$ &
-$\sum_{i = 1..n}\;estimate(e_i)$\medskip\\
-$\textit{estimate}(a_1\;bop\;a_2)$ & $\dn$ &
-$\textit{estimate}(a_1) + \textit{estimate}(a_2)$\\
-\end{tabular}
-\end{center}}
+\begin{textblock}{7}(0,1.6)\footnotesize
+\begin{minipage}{6cm}
+\begin{lstlisting}[language=JVMIS,basicstyle=\ttfamily, numbers=none]
+.method public static fact(I)I
+.limit locals 1
+.limit stack 6
+ iload 0
+ ldc 0
+ if_icmpne If_else_0
+ ldc 1
+ goto If_end_1
+If_else_0:
+ iload 0
+ iload 0
+ ldc 1
+ isub
+ invokestatic fact/fact/fact(I)I
+ imul
+If_end_1:
+ ireturn
+.end method
+\end{lstlisting}
+\end{minipage}
+\end{textblock}
+
+\begin{textblock}{7}(6,7)
+\begin{bubble}[7cm]\small
+\begin{lstlisting}[language=Lisp,
+ basicstyle=\ttfamily,
+ numbers=none,
+ xleftmargin=1mm,linebackgroundcolor=\color{cream}]
+def fact(n) =
+ if n == 0 then 1
+ else n * fact(n - 1)
+\end{lstlisting}
+\end{bubble}
+\end{textblock}
\end{frame}
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -148,7 +208,7 @@
xleftmargin=1mm,linebackgroundcolor=\color{cream}]
def facT(n, acc) =
if n == 0 then acc
- else facT(n - 1, n * acc);
+ else facT(n - 1, n * acc)
\end{lstlisting}
\end{bubble}
\end{textblock}
@@ -159,7 +219,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
-\begin{textblock}{7}(1,-0.2)\footnotesize
+\begin{textblock}{7}(1,-0.38)\footnotesize
\begin{minipage}{6cm}
\begin{lstlisting}[language=JVMIS,basicstyle=\ttfamily, numbers=none, escapeinside={(*@}{@*)}]
.method public static facT(II)I
@@ -263,6 +323,40 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[c]
+\frametitle{???}
+
+\small
+\begin{tabular}{cc}
+ \includegraphics[scale=0.2]{basic-code.jpg} &
+ \includegraphics[scale=0.2]{machine-code.jpg}
+\end{tabular}
+
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}[t]
+\frametitle{Opcodes}
+
+\small
+\begin{tabular}{cc}
+ \includegraphics[scale=0.3]{machine-code-large.png}
+\end{tabular}
+
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\begin{frame}<1-2>[t]
+
+\end{frame}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[c,fragile]
\frametitle{Peephole Optimisations}