3 \usepackage{../slides} |
3 \usepackage{../slides} |
4 \usepackage{../langs} |
4 \usepackage{../langs} |
5 \usepackage{../data} |
5 \usepackage{../data} |
6 \usepackage{../graphicss} |
6 \usepackage{../graphicss} |
7 \usepackage{../grammar} |
7 \usepackage{../grammar} |
8 \usepackage{soul} |
8 %\usepackage{soul} |
9 \usepackage{mathpartir} |
9 %\usepackage{mathpartir} |
10 \usetikzlibrary{shapes,arrows,shadows} |
10 \usetikzlibrary{shapes,arrows,shadows} |
|
11 |
|
12 \usepackage[most]{tcolorbox} |
|
13 |
|
14 \newtcbox{\hl}[1][]{% |
|
15 size=fbox, |
|
16 tcbox raise base, nobeforeafter, |
|
17 enhanced, colframe=gray, |
|
18 colback=gray!30, boxrule=1pt, |
|
19 fontupper=\ttfamily, |
|
20 #1} |
|
21 |
|
22 |
|
23 |
11 |
24 |
12 % beamer stuff |
25 % beamer stuff |
13 \renewcommand{\slidecaption}{CFL 09, King's College London} |
26 \renewcommand{\slidecaption}{CFL 09, King's College London} |
14 \newcommand{\bl}[1]{\textcolor{blue}{#1}} |
27 \newcommand{\bl}[1]{\textcolor{blue}{#1}} |
15 |
28 |
76 |
89 |
77 \end{frame} |
90 \end{frame} |
78 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
91 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
79 |
92 |
80 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
93 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
81 \begin{frame}[c, fragile] |
94 %\begin{frame}[c, fragile] |
82 \frametitle{Stack Estimation} |
95 %\frametitle{Stack Estimation} |
83 \small |
96 %\small |
84 \mbox{}\\[-15mm] |
97 %\mbox{}\\[-15mm]% |
85 |
98 % |
86 \bl{\begin{center} |
99 %\bl{\begin{center} |
87 \begin{tabular}{@{\hspace{-4mm}}l@{\hspace{2mm}}c@{\hspace{2mm}}l@{}} |
100 %\begin{tabular}{@{\hspace{-4mm}}l@{\hspace{2mm}}c@{\hspace{2mm}}l@{}} |
88 $\textit{estimate}(n)$ & $\dn$ & $1$\\ |
101 %$\textit{estimate}(n)$ & $\dn$ & $1$\\ |
89 $\textit{estimate}(x)$ & $\dn$ & $1$\\ |
102 %$\textit{estimate}(x)$ & $\dn$ & $1$\\ |
90 $\textit{estimate}(a_1\;aop\;a_2)$ & $\dn$ & |
103 %$\textit{estimate}(a_1\;aop\;a_2)$ & $\dn$ & |
91 $\textit{estimate}(a_1) + \textit{estimate}(a_2)$\\ |
104 %$\textit{estimate}(a_1) + \textit{estimate}(a_2)$\\ |
92 $\textit{estimate}(\pcode{if}\;b\;\pcode{then}\;e_1\;\pcode{else}\;e_2)$ & $\dn$ & |
105 %$\textit{estimate}(\pcode{if}\;b\;\pcode{then}\;e_1\;\pcode{else}\;e_2)$ & $\dn$ & |
93 $\textit{estimate}(b) +$\\ |
106 %$\textit{estimate}(b) +$\\ |
94 & & $\quad max(\textit{estimate}(e_1), \textit{estimate}(e_2))$\\ |
107 %& & $\quad max(\textit{estimate}(e_1), \textit{estimate}(e_2))$\\ |
95 $\textit{estimate}(\pcode{write}(e))$ & $\dn$ & |
108 %$\textit{estimate}(\pcode{write}(e))$ & $\dn$ & |
96 $\textit{estimate}(e) + 1$\\ |
109 %$\textit{estimate}(e) + 1$\\ |
97 $\textit{estimate}(e_1 ; e_2)$ & $\dn$ & |
110 %$\textit{estimate}(e_1 ; e_2)$ & $\dn$ & |
98 $max(\textit{estimate}(e_1), \textit{estimate}(e_2))$\\ |
111 %$max(\textit{estimate}(e_1), \textit{estimate}(e_2))$\\ |
99 $\textit{estimate}(f(e_1, ..., e_n))$ & $\dn$ & |
112 %$\textit{estimate}(f(e_1, ..., e_n))$ & $\dn$ & |
100 $\sum_{i = 1..n}\;estimate(e_i)$\medskip\\ |
113 %$\sum_{i = 1..n}\;estimate(e_i)$\medskip\\ |
101 $\textit{estimate}(a_1\;bop\;a_2)$ & $\dn$ & |
114 %$\textit{estimate}(a_1\;bop\;a_2)$ & $\dn$ & |
102 $\textit{estimate}(a_1) + \textit{estimate}(a_2)$\\ |
115 %$\textit{estimate}(a_1) + \textit{estimate}(a_2)$\\ |
103 \end{tabular} |
116 %\end{tabular} |
104 \end{center}} |
117 %\end{center}} |
105 |
118 |
106 \end{frame} |
119 %\end{frame} |
107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
120 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
121 |
|
122 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
123 |
|
124 |
|
125 \begin{frame}[c,fragile] |
|
126 \frametitle{\mbox{}\hspace{5cm}Factorial} |
|
127 |
|
128 \begin{textblock}{7}(0,1.6)\footnotesize |
|
129 \begin{minipage}{6cm} |
|
130 \begin{lstlisting}[language=JVMIS,basicstyle=\ttfamily, numbers=none] |
|
131 .method public static fact(I)I |
|
132 .limit locals 1 |
|
133 .limit stack 6 |
|
134 iload 0 |
|
135 ldc 0 |
|
136 if_icmpne If_else_0 |
|
137 ldc 1 |
|
138 goto If_end_1 |
|
139 If_else_0: |
|
140 iload 0 |
|
141 iload 0 |
|
142 ldc 1 |
|
143 isub |
|
144 invokestatic fact/fact/fact(I)I |
|
145 imul |
|
146 If_end_1: |
|
147 ireturn |
|
148 .end method |
|
149 \end{lstlisting} |
|
150 \end{minipage} |
|
151 \end{textblock} |
|
152 |
|
153 \begin{textblock}{7}(6,7) |
|
154 \begin{bubble}[7cm]\small |
|
155 \begin{lstlisting}[language=Lisp, |
|
156 basicstyle=\ttfamily, |
|
157 numbers=none, |
|
158 xleftmargin=1mm,linebackgroundcolor=\color{cream}] |
|
159 def fact(n) = |
|
160 if n == 0 then 1 |
|
161 else n * fact(n - 1) |
|
162 \end{lstlisting} |
|
163 \end{bubble} |
|
164 \end{textblock} |
|
165 |
|
166 \end{frame} |
|
167 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
108 |
168 |
109 |
169 |
110 |
170 |
111 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
171 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
112 |
172 |
146 basicstyle=\ttfamily, |
206 basicstyle=\ttfamily, |
147 numbers=none, |
207 numbers=none, |
148 xleftmargin=1mm,linebackgroundcolor=\color{cream}] |
208 xleftmargin=1mm,linebackgroundcolor=\color{cream}] |
149 def facT(n, acc) = |
209 def facT(n, acc) = |
150 if n == 0 then acc |
210 if n == 0 then acc |
151 else facT(n - 1, n * acc); |
211 else facT(n - 1, n * acc) |
152 \end{lstlisting} |
212 \end{lstlisting} |
153 \end{bubble} |
213 \end{bubble} |
154 \end{textblock} |
214 \end{textblock} |
155 |
215 |
156 \end{frame} |
216 \end{frame} |
157 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
217 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
158 |
218 |
159 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
219 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
160 \begin{frame}[fragile] |
220 \begin{frame}[fragile] |
161 |
221 |
162 \begin{textblock}{7}(1,-0.2)\footnotesize |
222 \begin{textblock}{7}(1,-0.38)\footnotesize |
163 \begin{minipage}{6cm} |
223 \begin{minipage}{6cm} |
164 \begin{lstlisting}[language=JVMIS,basicstyle=\ttfamily, numbers=none, escapeinside={(*@}{@*)}] |
224 \begin{lstlisting}[language=JVMIS,basicstyle=\ttfamily, numbers=none, escapeinside={(*@}{@*)}] |
165 .method public static facT(II)I |
225 .method public static facT(II)I |
166 .limit locals 2 |
226 .limit locals 2 |
167 .limit stack 6 |
227 .limit stack 6 |
259 \end{lstlisting} |
319 \end{lstlisting} |
260 \end{textblock} |
320 \end{textblock} |
261 |
321 |
262 \end{frame} |
322 \end{frame} |
263 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
323 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
324 |
|
325 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
326 \begin{frame}[c] |
|
327 \frametitle{???} |
|
328 |
|
329 \small |
|
330 \begin{tabular}{cc} |
|
331 \includegraphics[scale=0.2]{basic-code.jpg} & |
|
332 \includegraphics[scale=0.2]{machine-code.jpg} |
|
333 \end{tabular} |
|
334 |
|
335 |
|
336 \end{frame} |
|
337 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
338 |
|
339 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
340 \begin{frame}[t] |
|
341 \frametitle{Opcodes} |
|
342 |
|
343 \small |
|
344 \begin{tabular}{cc} |
|
345 \includegraphics[scale=0.3]{machine-code-large.png} |
|
346 \end{tabular} |
|
347 |
|
348 |
|
349 \end{frame} |
|
350 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
351 |
|
352 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
353 \begin{frame}<1-2>[t] |
|
354 |
|
355 \end{frame} |
|
356 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
357 |
264 |
358 |
265 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
359 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
266 \begin{frame}[c,fragile] |
360 \begin{frame}[c,fragile] |
267 \frametitle{Peephole Optimisations} |
361 \frametitle{Peephole Optimisations} |
268 |
362 |