author | Christian Urban <christian.urban@kcl.ac.uk> |
Mon, 30 Aug 2021 14:38:24 +0100 | |
changeset 827 | 67c8a6e6a305 |
parent 812 | 2f9a0dcf61ae |
child 852 | 8706b846a3e0 |
permissions | -rw-r--r-- |
686 | 1 |
% !TEX program = xelatex |
744 | 2 |
\documentclass[dvipsnames,14pt,t,xelatex,aspectratio=169,xcolor={table}]{beamer} |
302
0fa7b4221745
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
3 |
\usepackage{../slides} |
215
828303e8e4af
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
188
diff
changeset
|
4 |
\usepackage{../langs} |
828303e8e4af
updated slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
188
diff
changeset
|
5 |
\usepackage{../data} |
608 | 6 |
\usepackage{../graphics} |
7 |
\usepackage{../grammar} |
|
188
12ef150273ce
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
187
diff
changeset
|
8 |
|
63 | 9 |
% beamer stuff |
451 | 10 |
\renewcommand{\slidecaption}{CFL 07, King's College London} |
63 | 11 |
\newcommand{\bl}[1]{\textcolor{blue}{#1}} |
12 |
||
13 |
\begin{document} |
|
14 |
||
15 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
302
0fa7b4221745
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
16 |
\begin{frame}[t] |
63 | 17 |
\frametitle{% |
18 |
\begin{tabular}{@ {}c@ {}} |
|
19 |
\\[-3mm] |
|
451 | 20 |
\LARGE Compilers and \\[-2mm] |
744 | 21 |
\LARGE Formal Languages\\[3mm] |
63 | 22 |
\end{tabular}} |
23 |
||
24 |
\normalsize |
|
25 |
\begin{center} |
|
26 |
\begin{tabular}{ll} |
|
686 | 27 |
Email: & christian.urban at kcl.ac.uk\\ |
744 | 28 |
%Office Hours: & Thursdays 12 -- 14\\ |
29 |
%Location: & N7.07 (North Wing, Bush House)\\ |
|
686 | 30 |
Slides \& Progs: & KEATS (also homework is there)\\ |
63 | 31 |
\end{tabular} |
32 |
\end{center} |
|
33 |
||
744 | 34 |
\begin{center} |
35 |
\begin{tikzpicture} |
|
36 |
\node[drop shadow,fill=white,inner sep=0pt] |
|
37 |
{\footnotesize\rowcolors{1}{capri!10}{white} |
|
38 |
\begin{tabular}{|p{4.8cm}|p{4.8cm}|}\hline |
|
39 |
1 Introduction, Languages & 6 While-Language \\ |
|
40 |
2 Regular Expressions, Derivatives & \cellcolor{blue!50} 7 Compilation, JVM \\ |
|
41 |
3 Automata, Regular Languages & 8 Compiling Functional Languages \\ |
|
42 |
4 Lexing, Tokenising & 9 Optimisations \\ |
|
43 |
5 Grammars, Parsing & 10 LLVM \\ \hline |
|
44 |
\end{tabular}% |
|
45 |
}; |
|
46 |
\end{tikzpicture} |
|
47 |
\end{center} |
|
48 |
||
302
0fa7b4221745
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
49 |
\end{frame} |
0fa7b4221745
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
215
diff
changeset
|
50 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
63 | 51 |
|
608 | 52 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
807 | 53 |
\begin{frame}[t] |
608 | 54 |
\frametitle{Bird's Eye View} |
807 | 55 |
\mbox{}\\[-16mm]\mbox{} |
387
8aa406adfde0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
374
diff
changeset
|
56 |
|
608 | 57 |
\begin{center} |
807 | 58 |
\begin{tikzpicture}[scale=1, |
59 |
node/.style={ |
|
60 |
rectangle,rounded corners=3mm, |
|
61 |
very thick,draw=black!50, |
|
62 |
minimum height=18mm, minimum width=20mm, |
|
63 |
top color=white,bottom color=black!20,drop shadow}] |
|
64 |
\node (0) at (-2.3,0) {}; |
|
65 |
||
66 |
\node (A) at (0,0) [node] {}; |
|
67 |
\node [below right] at (A.north west) {lexer}; |
|
68 |
||
69 |
\node (B) at (3,0) [node] {}; |
|
70 |
\node [below right=1mm] at (B.north west) |
|
71 |
{\mbox{}\hspace{-1mm}parser}; |
|
608 | 72 |
|
807 | 73 |
\node (C) at (6,0) [node] {}; |
74 |
\node [below right] at (C.north west) |
|
75 |
{\mbox{}\hspace{-1mm}code gen}; |
|
76 |
||
77 |
\node (1) at (8.4,0) {}; |
|
78 |
||
79 |
\draw [->,line width=4mm] (0) -- (A); |
|
80 |
\draw [->,line width=4mm] (A) -- (B); |
|
81 |
\draw [->,line width=4mm] (B) -- (C); |
|
82 |
\draw [->,line width=4mm] (C) -- (1); |
|
83 |
\end{tikzpicture} |
|
808 | 84 |
\end{center}\pause |
85 |
||
86 |
\begin{center} |
|
87 |
\begin{tikzpicture}[scale=1,font=\bf, |
|
88 |
node/.style={ |
|
89 |
rectangle,rounded corners=3mm, |
|
90 |
ultra thick,draw=black!50,minimum height=18mm, |
|
91 |
minimum width=20mm, |
|
92 |
top color=white,bottom color=black!20}] |
|
93 |
||
94 |
\node (0) at (-3,0) {}; |
|
95 |
\node (A) at (0,0) [node,text width=1.6cm,text centered] {\small{}our compiler}; |
|
96 |
\node (B) at (3.5,0) [node,text width=1.6cm,text centered] {\small{}Jasmin / Krakatau}; |
|
97 |
\node (C) at (7.5,0) [node] {JVM}; |
|
98 |
||
99 |
\draw [->,line width=2.5mm] (0) -- node [above,pos=0.35] {*.while} (A); |
|
100 |
\draw [->,line width=2.5mm] (A) -- node [above,pos=0.35] {*.j} (B); |
|
101 |
\draw [->,line width=2.5mm] (B) -- node [above,pos=0.35] {*.class} (C); |
|
102 |
\end{tikzpicture} |
|
807 | 103 |
\end{center} |
608 | 104 |
\end{frame} |
63 | 105 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
686 | 106 |
|
808 | 107 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
108 |
\begin{frame}[c] |
|
109 |
\frametitle{Test Program} |
|
110 |
||
111 |
\mbox{}\\[-18mm]\mbox{} |
|
112 |
||
113 |
{\lstset{language=While}\fontsize{10}{12}\selectfont |
|
114 |
\texttt{\lstinputlisting{../progs/while-tests/loops.while}}} |
|
115 |
||
116 |
\end{frame} |
|
117 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
686 | 118 |
|
119 |
||
120 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
121 |
\begin{frame}[c] |
|
608 | 122 |
\begin{textblock}{10}(0.5,0.5) |
123 |
\LARGE |
|
124 |
\fontspec{Hoefler Text Black} |
|
125 |
\textcolor{ProcessBlue}{JVM\\ Code} |
|
126 |
\\[12mm] |
|
127 |
||
128 |
\normalsize |
|
129 |
Jasmin\\ |
|
130 |
Krakatau\\ |
|
131 |
ASM lib |
|
132 |
\end{textblock} |
|
133 |
||
387
8aa406adfde0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
374
diff
changeset
|
134 |
|
608 | 135 |
\fontsize{8}{10}\selectfont |
136 |
%\footnotesize |
|
807 | 137 |
\mbox{}\\[-13mm]\mbox{} |
608 | 138 |
|
139 |
\begin{columns} |
|
140 |
\begin{column}{2cm} |
|
141 |
\lstinputlisting[numbers=none]{../progs/appHa.j} |
|
142 |
\end{column} |
|
143 |
||
144 |
\begin{column}{2cm} |
|
145 |
\lstinputlisting[numbers=none]{../progs/appHb.j} |
|
146 |
\end{column} |
|
147 |
||
148 |
\end{columns} |
|
63 | 149 |
|
608 | 150 |
\end{frame} |
151 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
152 |
||
153 |
||
808 | 154 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
155 |
% \begin{frame}[t] |
|
608 | 156 |
|
808 | 157 |
% \begin{center} |
158 |
% \bl{\begin{tabular}{@{}lcl@{}} |
|
159 |
% \\[-12mm] |
|
160 |
% \meta{Stmt} & $::=$ & $\texttt{skip}$\\ |
|
161 |
% & $|$ & \textit{Id}\;\texttt{:=}\;\meta{AExp}\\ |
|
162 |
% & $|$ & \texttt{if}\; \meta{BExp} \;\texttt{then}\; \meta{Block} \;\texttt{else}\; \meta{Block}\\ |
|
163 |
% & $|$ & \texttt{while}\; \meta{BExp} \;\texttt{do}\; \meta{Block}\\ |
|
164 |
% & $|$ & \texttt{read}\;\textit{Id}\\ |
|
165 |
% & $|$ & \texttt{write}\;\textit{Id}\\ |
|
166 |
% & $|$ & \texttt{write}\;\textit{String}\medskip\\ |
|
167 |
% \meta{Stmts} & $::=$ & \meta{Stmt} \;\texttt{;}\; \meta{Stmts}\\ |
|
168 |
% & $|$ & \meta{Stmt}\medskip\\ |
|
169 |
% \meta{Block} & $::=$ & \texttt{\{}\,\meta{Stmts}\,\texttt{\}}\\ |
|
170 |
% & $|$ & \meta{Stmt}\medskip\\ |
|
171 |
% \meta{AExp} & $::=$ & \ldots\\ |
|
172 |
% \meta{BExp} & $::=$ & \ldots\\ |
|
173 |
% \end{tabular}} |
|
174 |
% \end{center} |
|
175 |
% \end{frame} |
|
176 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
184
2e9134d25a2b
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
177 |
|
608 | 178 |
|
808 | 179 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
180 |
% \begin{frame}[c] |
|
181 |
% \frametitle{\begin{tabular}{c}Fibonacci Numbers\end{tabular}} |
|
387
8aa406adfde0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
374
diff
changeset
|
182 |
|
808 | 183 |
% \mbox{}\\[-18mm]\mbox{} |
184 |
% ?? |
|
185 |
% %{\lstset{language=While}\fontsize{10}{12}\selectfont |
|
186 |
% %\texttt{\lstinputlisting{../progs/fib.while}}} |
|
387
8aa406adfde0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
374
diff
changeset
|
187 |
|
808 | 188 |
% \end{frame} |
189 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
387
8aa406adfde0
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
374
diff
changeset
|
190 |
|
808 | 191 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
192 |
% \begin{frame}[c] |
|
193 |
% \frametitle{Interpreter} |
|
188
12ef150273ce
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
187
diff
changeset
|
194 |
|
808 | 195 |
% \begin{center} |
196 |
% \bl{\begin{tabular}{@{}lcl@{}} |
|
197 |
% $\text{eval}(n, E)$ & $\dn$ & $n$\\ |
|
198 |
% $\text{eval}(x, E)$ & $\dn$ & $E(x)$ \;\;\;\textcolor{black}{lookup \bl{$x$} in \bl{$E$}}\\ |
|
199 |
% $\text{eval}(a_1 + a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) + \text{eval}(a_2, E)$\\ |
|
200 |
% $\text{eval}(a_1 - a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) - \text{eval}(a_2, E)$\\ |
|
201 |
% $\text{eval}(a_1 * a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) * \text{eval}(a_2, E)$\bigskip\\ |
|
202 |
% $\text{eval}(a_1 = a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) = \text{eval}(a_2, E)$\\ |
|
203 |
% $\text{eval}(a_1\,!\!= a_2, E)$ & $\dn$ & $\neg(\text{eval}(a_1, E) = \text{eval}(a_2, E))$\\ |
|
204 |
% $\text{eval}(a_1 < a_2, E)$ & $\dn$ & $\text{eval}(a_1, E) < \text{eval}(a_2, E)$\ |
|
205 |
% \end{tabular}} |
|
206 |
% \end{center} |
|
63 | 207 |
|
808 | 208 |
% \end{frame} |
209 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
608 | 210 |
|
808 | 211 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
212 |
% \begin{frame}[c] |
|
213 |
% \frametitle{Interpreter (2)} |
|
63 | 214 |
|
808 | 215 |
% \begin{center} |
216 |
% \bl{\begin{tabular}{@{}lcl@{}} |
|
217 |
% $\text{eval}(\text{skip}, E)$ & $\dn$ & $E$\\ |
|
218 |
% $\text{eval}(x:=a, E)$ & $\dn$ & \bl{$E(x \mapsto \text{eval}(a, E))$}\\ |
|
219 |
% \multicolumn{3}{@{}l@{}}{$\text{eval}(\text{if}\;b\;\text{then}\;cs_1\;\text{else}\;cs_2 , E) \dn$}\\ |
|
220 |
% \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{if}\;\text{eval}(b,E)\;\text{then}\; |
|
221 |
% \text{eval}(cs_1,E)$}\\ |
|
222 |
% \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\phantom{\text{if}\;\text{eval}(b,E)\;}\text{else}\;\text{eval}(cs_2,E)$}\\ |
|
223 |
% \multicolumn{3}{@{}l@{}}{$\text{eval}(\text{while}\;b\;\text{do}\;cs, E) \dn$}\\ |
|
224 |
% \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{if}\;\text{eval}(b,E)$}\\ |
|
225 |
% \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{then}\; |
|
226 |
% \text{eval}(\text{while}\;b\;\text{do}\;cs, \text{eval}(cs,E))$}\\ |
|
227 |
% \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{else}\; E$}\\ |
|
228 |
% $\text{eval}(\text{write}\; x, E)$ & $\dn$ & $\{\;\text{println}(E(x))\; ;\;E\;\}$\\ |
|
229 |
% \end{tabular}} |
|
230 |
% \end{center} |
|
63 | 231 |
|
808 | 232 |
% \end{frame} |
233 |
% %%%%%%%%%%%%%%% |
|
234 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
188
12ef150273ce
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
187
diff
changeset
|
235 |
|
808 | 236 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
237 |
% \begin{frame}[c] |
|
238 |
% \frametitle{Test Program} |
|
188
12ef150273ce
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
187
diff
changeset
|
239 |
|
808 | 240 |
% \mbox{}\\[-18mm]\mbox{} |
188
12ef150273ce
added
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
187
diff
changeset
|
241 |
|
808 | 242 |
% {\lstset{language=While}\fontsize{10}{12}\selectfont |
243 |
% \texttt{\lstinputlisting{../progs/while-tests/loops.while}}} |
|
63 | 244 |
|
808 | 245 |
% \end{frame} |
246 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
63 | 247 |
|
808 | 248 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
249 |
% \begin{frame}[c] |
|
250 |
% \fontsize{7}{9}\selectfont |
|
608 | 251 |
|
252 |
||
808 | 253 |
% \begin{columns} |
254 |
% \begin{column}{7cm} |
|
255 |
% \lstinputlisting[numbers=none]{../progs/appHa.j} |
|
256 |
% \end{column} |
|
608 | 257 |
|
808 | 258 |
% \begin{column}{7cm} |
259 |
% \lstinputlisting[numbers=none]{../progs/appHb.j} |
|
260 |
% \end{column} |
|
261 |
% \end{columns} |
|
608 | 262 |
|
808 | 263 |
% \end{frame} |
264 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
608 | 265 |
|
686 | 266 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
267 |
%\begin{frame}[t] |
|
268 |
%\frametitle{Interpreted Code} |
|
269 |
% |
|
270 |
%\begin{center} |
|
271 |
%\begin{tikzpicture} |
|
272 |
%\begin{axis}[axis x line=bottom, axis y line=left, xlabel=n, ylabel=secs, legend style=small] |
|
273 |
%\addplot+[smooth] file {interpreted.data}; |
|
274 |
%\end{axis} |
|
275 |
%\end{tikzpicture} |
|
276 |
%\end{center} |
|
277 |
% |
|
278 |
%\end{frame} |
|
279 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
280 |
% |
|
281 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
282 |
%\begin{frame}[c] |
|
283 |
%\frametitle{Java Virtual Machine} |
|
284 |
% |
|
285 |
%\begin{itemize} |
|
286 |
%\item introduced in 1995 |
|
287 |
%\item is a stack-based VM (like Postscript, CLR of .Net) |
|
288 |
%\item contains a JIT compiler |
|
289 |
%\item many languages take advantage of JVM's infrastructure (JRE) |
|
290 |
%\item is garbage collected $\Rightarrow$ no buffer overflows |
|
291 |
%\item some languages compiled to the JVM: Scala, Clojure\ldots |
|
292 |
%\end{itemize} |
|
293 |
% |
|
294 |
%\end{frame} |
|
608 | 295 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
296 |
||
297 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
298 |
\begin{frame}[t,fragile] |
|
299 |
\frametitle{Compiling AExps} |
|
300 |
||
686 | 301 |
For example \textbf{\bl{1 + ((2 * 3) + (4 - 3))}}:\medskip |
608 | 302 |
|
303 |
\begin{columns}[T] |
|
304 |
\begin{column}{.3\textwidth} |
|
305 |
\begin{center} |
|
306 |
\bl{\begin{tikzpicture} |
|
307 |
\tikzset{level distance=12mm,sibling distance=4mm} |
|
308 |
\tikzset{edge from parent/.style={draw,very thick}} |
|
309 |
\Tree [.$+$ [.$1$ ] [.$+$ [.$*$ $2$ $3$ ] [.$-$ $4$ $3$ ]]] |
|
310 |
\end{tikzpicture}} |
|
311 |
\end{center} |
|
312 |
\end{column} |
|
313 |
\begin{column}{.3\textwidth} |
|
314 |
\begin{lstlisting}[language=JVMIS,numbers=none] |
|
315 |
ldc 1 |
|
316 |
ldc 2 |
|
317 |
ldc 3 |
|
318 |
imul |
|
319 |
ldc 4 |
|
320 |
ldc 3 |
|
321 |
isub |
|
322 |
iadd |
|
323 |
iadd |
|
324 |
\end{lstlisting} |
|
325 |
\end{column} |
|
326 |
\end{columns}\bigskip |
|
327 |
||
328 |
\small |
|
329 |
Traverse tree in post-order \bl{$\Rightarrow$} code for |
|
330 |
stack-machine |
|
331 |
||
332 |
\end{frame} |
|
333 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
334 |
||
335 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
336 |
\begin{frame}[t,fragile] |
|
337 |
\frametitle{Compiling AExps} |
|
338 |
||
686 | 339 |
\liningnums{\textbf{\Large\bl{(1 + 2) + 3}}} |
608 | 340 |
|
341 |
\begin{lstlisting}[language=JVMIS,numbers=none,xleftmargin=6cm] |
|
342 |
ldc 1 |
|
343 |
ldc 2 |
|
344 |
iadd |
|
345 |
ldc 3 |
|
346 |
iadd |
|
347 |
\end{lstlisting} |
|
348 |
||
349 |
||
350 |
\end{frame} |
|
351 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
352 |
||
353 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
354 |
\begin{frame}[t,fragile] |
|
355 |
\frametitle{Compiling AExps} |
|
356 |
||
357 |
\liningnums{\textbf{\Large\bl{1 + (2 + 3)}}} |
|
358 |
||
359 |
\begin{lstlisting}[language=JVMIS,numbers=none,xleftmargin=6cm] |
|
360 |
ldc 1 |
|
361 |
ldc 2 |
|
362 |
ldc 3 |
|
363 |
iadd |
|
364 |
iadd |
|
365 |
\end{lstlisting} |
|
366 |
\bigskip\pause |
|
367 |
\vfill |
|
368 |
||
369 |
\textcolor{codepurple}{\textbf{\texttt{dadd}}}, |
|
370 |
\textcolor{codepurple}{\textbf{\texttt{fadd}}}, |
|
371 |
\textcolor{codepurple}{\textbf{\texttt{ladd}}}, \ldots |
|
372 |
||
373 |
\end{frame} |
|
374 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
375 |
||
376 |
||
377 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
378 |
\begin{frame}[t] |
|
379 |
\frametitle{Compiling AExps} |
|
380 |
||
381 |
\begin{center} |
|
382 |
\bl{\begin{tabular}{@{}lcl@{}} |
|
383 |
$\text{compile}(n)$ & $\dn$ & $\text{ldc}\;n$\\ |
|
384 |
$\text{compile}(a_1 + a_2)$ & $\dn$\\ |
|
385 |
\multicolumn{3}{l}{$\qquad\text{compile}(a_1) \;@\;\text{compile}(a_2)\;@\; \text{iadd}$}\smallskip\\ |
|
386 |
$\text{compile}(a_1 - a_2)$ & $\dn$\\ |
|
387 |
\multicolumn{3}{l}{$\qquad\text{compile}(a_1) \;@\; \text{compile}(a_2)\;@\; \text{isub}$}\smallskip\\ |
|
388 |
$\text{compile}(a_1 * a_2)$ & $\dn$\\ |
|
389 |
\multicolumn{3}{l}{$\qquad\text{compile}(a_1) \;@\; \text{compile}(a_2)\;@\; \text{imul}$}\smallskip\\ |
|
390 |
\end{tabular}} |
|
391 |
\end{center} |
|
392 |
||
393 |
\end{frame} |
|
394 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
395 |
||
396 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
397 |
\begin{frame}[t,fragile] |
|
398 |
\frametitle{\begin{tabular}{c}Compiling AExps\end{tabular}} |
|
399 |
||
400 |
\liningnums{\textbf{\Large\bl{1 $+$ 2 $*$ 3 $+$ (4 $-$ 3)}}} |
|
401 |
||
402 |
\begin{lstlisting}[language=JVMIS,numbers=none,xleftmargin=6cm] |
|
403 |
ldc 1 |
|
404 |
ldc 2 |
|
405 |
ldc 3 |
|
406 |
imul |
|
407 |
ldc 4 |
|
408 |
ldc 3 |
|
409 |
isub |
|
410 |
iadd |
|
411 |
iadd |
|
412 |
\end{lstlisting} |
|
413 |
||
414 |
\end{frame} |
|
415 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
416 |
||
417 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
418 |
\begin{frame}[c] |
|
419 |
\frametitle{Variables} |
|
420 |
\liningnums{\textbf{\Large\bl{x $:=$ 5 $+$ y $*$ 2}}}\bigskip\pause |
|
421 |
||
422 |
\begin{itemize} |
|
423 |
\item lookup: \bl{$\textcolor{codepurple}{\textbf{\texttt{iload}}}\; index$} |
|
424 |
\item store: \bl{$\textcolor{codepurple}{\textbf{\texttt{istore}}}\; index$} |
|
425 |
\end{itemize}\bigskip\pause |
|
426 |
||
427 |
while compilating we have to maintain a map between our identifiers and the |
|
428 |
Java bytecode indices |
|
429 |
||
430 |
\begin{center} |
|
431 |
\bl{$\text{compile}(a, E)$} |
|
432 |
\end{center} |
|
433 |
||
434 |
\end{frame} |
|
435 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
436 |
||
437 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
438 |
\begin{frame}[t] |
|
439 |
\frametitle{Compiling AExps} |
|
440 |
||
441 |
\begin{center} |
|
442 |
\bl{\begin{tabular}{@{}lcl@{}} |
|
443 |
$\text{compile}(n, E)$ & $\dn$ & $\text{ldc}\;n$\\ |
|
444 |
$\text{compile}(a_1 + a_2, E)$ & $\dn$\\ |
|
445 |
\multicolumn{3}{l}{$\qquad\text{compile}(a_1, E) \;@\;\text{compile}(a_2, E)\;@\; \text{iadd}$}\smallskip\\ |
|
446 |
$\text{compile}(a_1 - a_2, E)$ & $\dn$\\ |
|
447 |
\multicolumn{3}{l}{$\qquad\text{compile}(a_1, E) \;@\; \text{compile}(a_2, E)\;@\; \text{isub}$}\smallskip\\ |
|
448 |
$\text{compile}(a_1 * a_2, E)$ & $\dn$\\ |
|
449 |
\multicolumn{3}{l}{$\qquad\text{compile}(a_1, E) \;@\; \text{compile}(a_2, E)\;@\; \text{imul}$}\bigskip\\ |
|
450 |
$\text{compile}(x, E)$ & $\dn$ & $\text{iload}\;E(x)$\\ |
|
451 |
\end{tabular}} |
|
452 |
\end{center} |
|
453 |
||
454 |
\end{frame} |
|
455 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
456 |
||
457 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
458 |
\begin{frame}[c, fragile] |
|
459 |
\frametitle{Mathematical Functions} |
|
460 |
||
461 |
Compilation of some mathematical functions: |
|
462 |
||
463 |
\begin{center} |
|
464 |
\begin{tabular}{lcl} |
|
465 |
\texttt{Aop("+", a1, a2)} & $\Rightarrow$ & \texttt{...iadd}\\ |
|
466 |
\texttt{Aop("-", a1, a2)} & $\Rightarrow$ & \texttt{...isub}\\ |
|
467 |
\texttt{Aop("*", a1, a2)} & $\Rightarrow$ & \texttt{...imul}\\ |
|
468 |
\texttt{Aop("/", a1, a2)} & $\Rightarrow$ & \texttt{...idiv}\\ |
|
469 |
\texttt{Aop("\%", a1, a2)} & $\Rightarrow$ & \texttt{...irem}\\ |
|
470 |
\end{tabular} |
|
471 |
\end{center} |
|
472 |
||
473 |
\end{frame} |
|
474 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
475 |
||
476 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
477 |
\begin{frame}[c] |
|
478 |
\frametitle{Compiling Statements} |
|
479 |
||
480 |
We return a list of instructions and an environment for the |
|
481 |
variables |
|
482 |
||
483 |
\begin{center} |
|
484 |
\bl{\begin{tabular}{@{}l@{\hspace{1mm}}c@{\hspace{1mm}}l@{}} |
|
485 |
$\text{compile}(\text{skip}, E)$ & $\dn$ & $(\textit{Nil}, E)$\bigskip\\ |
|
486 |
$\text{compile}(x := a, E)$ & $\dn$\\ |
|
487 |
\multicolumn{3}{l}{$(\text{compile}(a, E) \;@\;\text{istore}\;index, E(x\mapsto index))$}\\ |
|
488 |
\end{tabular}} |
|
489 |
\end{center}\medskip |
|
490 |
||
491 |
where \bl{$index$} is \bl{$E(x)$} if it is already defined, |
|
492 |
or if it is not, then the largest index not yet seen |
|
493 |
||
494 |
\end{frame} |
|
495 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
496 |
||
497 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
498 |
\begin{frame}[c,fragile] |
|
499 |
\frametitle{Compiling Assignments} |
|
500 |
||
501 |
\liningnums{\textbf{\Large\bl{x $:=$ x $+$ 1}}} |
|
502 |
||
503 |
\begin{lstlisting}[language=JVMIS,numbers=none,xleftmargin=6cm] |
|
504 |
iload /*@\bl{$n_x$}@*/ |
|
505 |
ldc 1 |
|
506 |
iadd |
|
507 |
istore /*@\bl{$n_x$}@*/ |
|
508 |
\end{lstlisting}\medskip |
|
509 |
||
510 |
where \bl{$n_x$} is the index corresponding to the variable~\bl{$x$} |
|
511 |
||
512 |
\end{frame} |
|
513 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
514 |
||
515 |
||
516 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
517 |
\begin{frame}[t] |
|
518 |
\frametitle{Compiling Ifs} |
|
519 |
||
520 |
{\Large\bl{$\text{if}\;b\;\text{then}\;cs_1\;\text{else}\;cs_2$}}\bigskip\bigskip |
|
521 |
||
522 |
\onslide<2->{Case }\only<2>{{\bf True}:}\only<3>{{\bf False}:} |
|
523 |
||
524 |
\begin{center} |
|
525 |
\begin{tikzpicture}[node distance=2mm and 4mm, |
|
526 |
block/.style={rectangle, minimum size=1cm, draw=black, line width=1mm}, |
|
527 |
point/.style={rectangle, inner sep=0mm, minimum size=0mm, fill=red}, |
|
528 |
skip loop/.style={red, line width=1mm, to path={-- ++(0,-10mm) -| (\tikztotarget)}}] |
|
529 |
\node (A1) [point] {}; |
|
530 |
\node (b) [block, right=of A1] {code of \bl{$b$}}; |
|
531 |
\node (A2) [point, right=of b] {}; |
|
532 |
\node (cs1) [block, right=of A2] {code of \bl{$cs_1$}}; |
|
533 |
\node (A3) [point, right=of cs1] {}; |
|
534 |
\node (cs2) [block, right=of A3] {code of \bl{$cs_2$}}; |
|
535 |
\node (A4) [point, right=of cs2] {}; |
|
536 |
||
537 |
\only<2>{ |
|
538 |
\draw (A1) edge [->, red, line width=1mm] (b); |
|
539 |
\draw (b) edge [->, red, line width=1mm] (cs1); |
|
540 |
\draw (cs1) edge [->, red, line width=1mm] (A3); |
|
541 |
\draw (A3) edge [->,skip loop] (A4); |
|
542 |
\node [below=of cs2] {\raisebox{-5mm}{\small{}jump}};} |
|
543 |
\only<3>{ |
|
544 |
\draw (A1) edge [->, red, line width=1mm] (b); |
|
545 |
\draw (b) edge [->, red, line width=1mm] (A2); |
|
546 |
\draw (A2) edge [skip loop] (A3); |
|
547 |
\draw (A3) edge [->, red, line width=1mm] (cs2); |
|
548 |
\draw (cs2) edge [->,red, line width=1mm] (A4); |
|
549 |
\node [below=of cs1] {\raisebox{-5mm}{\small{}conditional jump}};} |
|
550 |
\end{tikzpicture} |
|
551 |
\end{center} |
|
552 |
||
553 |
\end{frame} |
|
554 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
555 |
||
556 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
557 |
\begin{frame}[t,fragile] |
|
558 |
\frametitle{Conditional Jumps} |
|
559 |
||
560 |
\begin{minipage}{1.1\textwidth} |
|
561 |
\begin{itemize} |
|
562 |
\item \textcolor{codepurple}{\textbf{\texttt{if\_icmpeq}}} \bl{$label$} |
|
563 |
if two ints are equal, then jump\medskip |
|
564 |
\item \textcolor{codepurple}{\textbf{\texttt{if\_icmpne}}} \bl{$label$} |
|
565 |
if two ints aren't equal, then jump\medskip |
|
566 |
\item \textcolor{codepurple}{\textbf{\texttt{if\_icmpge}}} \bl{$label$} |
|
567 |
if one int is greater or equal then another, then jump |
|
568 |
\item[]\ldots |
|
569 |
\end{itemize} |
|
570 |
\end{minipage}\pause |
|
571 |
||
572 |
\begin{lstlisting}[language=JVMIS,numbers=none,xleftmargin=2cm] |
|
573 |
/*@\bl{$L_1$:}@*/ |
|
574 |
if_icmpeq /*@\bl{$L_2$}@*/ |
|
575 |
iload 1 |
|
576 |
ldc 1 |
|
577 |
iadd |
|
578 |
if_icmpeq /*@\bl{$L_1$}@*/ |
|
579 |
/*@\bl{$L_2$:}@*/ |
|
580 |
\end{lstlisting} |
|
581 |
||
582 |
||
583 |
\begin{textblock}{3.5}(11,12) |
|
584 |
\only<3>{labels must be unique} |
|
585 |
\end{textblock} |
|
586 |
\end{frame} |
|
587 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
588 |
||
589 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
590 |
\begin{frame}[c,fragile] |
|
591 |
\frametitle{Compiling Ifs} |
|
592 |
||
593 |
For example |
|
594 |
||
595 |
\begin{lstlisting}[mathescape,numbers=none,language=While] |
|
810 | 596 |
if 1 == 1 then x := 2 else y := 3 |
608 | 597 |
\end{lstlisting} |
598 |
||
599 |
||
600 |
\begin{center} |
|
601 |
\begin{lstlisting}[mathescape,language=JVMIS,numbers=none] |
|
602 |
ldc 1 |
|
603 |
ldc 1 |
|
604 |
if_icmpne L_ifelse $\quad\tikz[remember picture] \node (C) {\mbox{}};$ |
|
605 |
ldc 2 |
|
606 |
istore 0 |
|
607 |
goto L_ifend $\quad\tikz[remember picture] \node (A) {\mbox{}};$ |
|
608 |
L_ifelse: $\quad\tikz[remember picture] \node[] (D) {\mbox{}};$ |
|
609 |
ldc 3 |
|
610 |
istore 1 |
|
611 |
L_ifend: $\quad\tikz[remember picture] \node[] (B) {\mbox{}};$ |
|
612 |
\end{lstlisting} |
|
613 |
\end{center} |
|
614 |
||
615 |
\begin{tikzpicture}[remember picture,overlay] |
|
616 |
\draw[->,very thick] (A) edge [->,to path={-- ++(10mm,0mm) |
|
617 |
-- ++(0mm,-17.3mm) |- (\tikztotarget)},line width=1mm] (B.east); |
|
618 |
\draw[->,very thick] (C) edge [->,to path={-- ++(10mm,0mm) |
|
619 |
-- ++(0mm,-17.3mm) |- (\tikztotarget)},line width=1mm] (D.east); |
|
620 |
\end{tikzpicture} |
|
621 |
||
622 |
\end{frame} |
|
623 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
624 |
||
625 |
||
626 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
627 |
\begin{frame}[t] |
|
628 |
\frametitle{Compiling BExps} |
|
629 |
||
810 | 630 |
{\Large\bl{$a_1 == a_2$}} |
608 | 631 |
|
632 |
\begin{center} |
|
633 |
\bl{\begin{tabular}{lcl} |
|
810 | 634 |
$\text{compile}(a_1 == a_2, E, lab)$ & $\dn$\\ |
608 | 635 |
\multicolumn{3}{l}{$\quad\text{compile}(a_1, E) \;@\;\text{compile}(a_2, E)\;@\; \text{if\_icmpne}\;lab$} |
636 |
\end{tabular}} |
|
637 |
\end{center} |
|
638 |
||
639 |
\end{frame} |
|
640 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
641 |
||
642 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
643 |
\begin{frame}[c, fragile] |
|
644 |
\frametitle{Boolean Expressions} |
|
645 |
||
646 |
Compilation of boolean expressions: |
|
647 |
||
648 |
\begin{center} |
|
649 |
\begin{tikzpicture}[node distance=2mm and 4mm, |
|
650 |
block/.style={rectangle, minimum size=1cm, draw=black, line width=1mm}, |
|
651 |
point/.style={rectangle, inner sep=0mm, minimum size=0mm, fill=red}, |
|
652 |
skip loop/.style={red, line width=1mm, to path={-- ++(0,-10mm) -| (\tikztotarget)}}] |
|
653 |
\node (A1) [point] {}; |
|
654 |
\node (b) [block, right=of A1] {code of \bl{$b$}}; |
|
655 |
\node (A2) [point, right=of b] {}; |
|
656 |
\node (cs1) [block, right=of A2] {code of \bl{$cs_1$}}; |
|
657 |
\node (A3) [point, right=of cs1] {}; |
|
658 |
\node (cs2) [block, right=of A3] {code of \bl{$cs_2$}}; |
|
659 |
\node (A4) [point, right=of cs2] {}; |
|
660 |
||
661 |
\only<1>{ |
|
662 |
\draw (A1) edge [->, red, line width=1mm] (b); |
|
663 |
\draw (b) edge [->, red, line width=1mm] (A2); |
|
664 |
\draw (A2) edge [skip loop] (A3); |
|
665 |
\draw (A3) edge [->, red, line width=1mm] (cs2); |
|
666 |
\draw (cs2) edge [->,red, line width=1mm] (A4); |
|
667 |
\node [below=of cs1] {\raisebox{-5mm}{\small{}conditional jump}};} |
|
668 |
\end{tikzpicture} |
|
669 |
\end{center} |
|
670 |
||
671 |
\begin{center} |
|
672 |
\begin{tabular}{lcl} |
|
673 |
\texttt{Bop("==", a1, a2)} & $\Rightarrow$ & \texttt{...if\_icmpne...}\\ |
|
674 |
\texttt{Bop("!=", a1, a2)} & $\Rightarrow$ & \texttt{...if\_icmpeq...}\\ |
|
675 |
\texttt{Bop("<", a1, a2)} & $\Rightarrow$ & \texttt{...if\_icmpge...}\\ |
|
676 |
\texttt{Bop("<=", a1, a2)} & $\Rightarrow$ & \texttt{...if\_icmpgt...}\\ |
|
677 |
\end{tabular} |
|
678 |
\end{center} |
|
679 |
||
680 |
\end{frame} |
|
681 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
682 |
||
683 |
||
684 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
685 |
\begin{frame}[t] |
|
686 |
\frametitle{Compiling Ifs} |
|
687 |
||
688 |
{\Large\bl{if $b$ then $cs_1$ else $cs_2$}} |
|
689 |
||
690 |
\begin{center} |
|
691 |
\bl{\begin{tabular}{lcl} |
|
692 |
$\text{compile}(\text{if}\;b\;\text{then}\; cs_1\;\text{else}\; cs_2, E)$ & $\dn$\\ |
|
693 |
\multicolumn{3}{l}{$\quad l_{ifelse}\;$ \textcolor{black}{(fresh label)}}\\ |
|
694 |
\multicolumn{3}{l}{$\quad l_{ifend}\;$ \textcolor{black}{(fresh label)}}\\ |
|
695 |
\multicolumn{3}{l}{$\quad (is_1, E') = \text{compile}(cs_1, E)$}\\ |
|
696 |
\multicolumn{3}{l}{$\quad (is_2, E'') = \text{compile}(cs_2, E')$}\\ |
|
697 |
\multicolumn{3}{l}{$\quad(\text{compile}(b, E, l_{ifelse})$}\\ |
|
698 |
\multicolumn{3}{l}{$\quad\phantom{(}@\;is_1$}\\ |
|
699 |
\multicolumn{3}{l}{$\quad\phantom{(}@\; \text{goto}\;l_{ifend}$}\\ |
|
700 |
\multicolumn{3}{l}{$\quad\phantom{(}@\;l_{ifelse}:$}\\ |
|
701 |
\multicolumn{3}{l}{$\quad\phantom{(}@\;is_2$}\\ |
|
702 |
\multicolumn{3}{l}{$\quad\phantom{(}@\;l_{ifend}:, E'')$}\\ |
|
703 |
\end{tabular}} |
|
704 |
\end{center} |
|
705 |
||
706 |
\end{frame} |
|
707 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
708 |
||
709 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
710 |
\begin{frame}[t] |
|
711 |
\frametitle{Compiling Whiles} |
|
712 |
||
713 |
{\Large\bl{$\text{while}\;b\;\text{do}\;cs$}}\bigskip\bigskip |
|
714 |
||
715 |
\onslide<2->{Case }\only<2>{{\bf True}:}\only<3>{{\bf False}:} |
|
716 |
||
717 |
\begin{center} |
|
718 |
\begin{tikzpicture}[node distance=2mm and 4mm, |
|
719 |
block/.style={rectangle, minimum size=1cm, draw=black, line width=1mm}, |
|
720 |
point/.style={rectangle, inner sep=0mm, minimum size=0mm, fill=red}, |
|
721 |
skip loop/.style={red, line width=1mm, to path={-- ++(0,-10mm) -| (\tikztotarget)}}] |
|
722 |
\node (A0) [point, left=of A1] {}; |
|
723 |
\node (A1) [point] {}; |
|
724 |
\node (b) [block, right=of A1] {code of \bl{$b$}}; |
|
725 |
\node (A2) [point, right=of b] {}; |
|
726 |
\node (cs1) [block, right=of A2] {code of \bl{$cs$}}; |
|
727 |
\node (A3) [point, right=of cs1] {}; |
|
728 |
\node (A4) [point, right=of A3] {}; |
|
729 |
||
730 |
\only<2>{ |
|
731 |
\draw (A0) edge [->, red, line width=1mm] (b); |
|
732 |
\draw (b) edge [->, red, line width=1mm] (cs1); |
|
733 |
\draw (cs1) edge [->, red, line width=1mm] (A3); |
|
734 |
\draw (A3) edge [->,skip loop] (A1);} |
|
735 |
\only<3>{ |
|
736 |
\draw (A0) edge [->, red, line width=1mm] (b); |
|
737 |
\draw (b) edge [->, red, line width=1mm] (A2); |
|
738 |
\draw (A2) edge [skip loop] (A3); |
|
739 |
\draw (A3) edge [->, red, line width=1mm] (A4);} |
|
740 |
\end{tikzpicture} |
|
741 |
\end{center} |
|
742 |
||
743 |
\end{frame} |
|
744 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
745 |
||
746 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
747 |
\begin{frame}[t] |
|
748 |
\frametitle{Compiling Whiles} |
|
749 |
||
750 |
{\Large\bl{while $b$ do $cs$}} |
|
751 |
||
752 |
\begin{center} |
|
753 |
\bl{\begin{tabular}{lcl} |
|
754 |
$\text{compile}(\text{while}\; b\; \text{do} \;cs, E)$ & $\dn$\\ |
|
755 |
\multicolumn{3}{l}{$\quad l_{wbegin}\;$ \textcolor{black}{(fresh label)}}\\ |
|
756 |
\multicolumn{3}{l}{$\quad l_{wend}\;$ \textcolor{black}{(fresh label)}}\\ |
|
757 |
\multicolumn{3}{l}{$\quad (is, E') = \text{compile}(cs_1, E)$}\\ |
|
758 |
\multicolumn{3}{l}{$\quad(l_{wbegin}:$}\\ |
|
759 |
\multicolumn{3}{l}{$\quad\phantom{(}@\;\text{compile}(b, E, l_{wend})$}\\ |
|
760 |
\multicolumn{3}{l}{$\quad\phantom{(}@\;is$}\\ |
|
761 |
\multicolumn{3}{l}{$\quad\phantom{(}@\; \text{goto}\;l_{wbegin}$}\\ |
|
762 |
\multicolumn{3}{l}{$\quad\phantom{(}@\;l_{wend}:, E')$}\\ |
|
763 |
\end{tabular}} |
|
764 |
\end{center} |
|
765 |
||
766 |
\end{frame} |
|
767 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
768 |
||
769 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
770 |
\begin{frame}[c,fragile] |
|
771 |
\frametitle{Compiling Whiles} |
|
772 |
||
773 |
For example |
|
774 |
||
775 |
\begin{lstlisting}[mathescape,numbers=none,language=While] |
|
776 |
while x <= 10 do x := x + 1 |
|
777 |
\end{lstlisting} |
|
778 |
||
779 |
||
780 |
\begin{center} |
|
781 |
\begin{lstlisting}[mathescape,language=JVMIS,numbers=none] |
|
782 |
L_wbegin: $\quad\tikz[remember picture] \node[] (LB) {\mbox{}};$ |
|
783 |
iload 0 |
|
784 |
ldc 10 |
|
785 |
if_icmpgt L_wend $\quad\tikz[remember picture] \node (LC) {\mbox{}};$ |
|
786 |
iload 0 |
|
787 |
ldc 1 |
|
788 |
iadd |
|
789 |
istore 0 |
|
790 |
goto L_wbegin $\quad\tikz[remember picture] \node (LA) {\mbox{}};$ |
|
791 |
L_wend: $\quad\tikz[remember picture] \node[] (LD) {\mbox{}};$ |
|
792 |
\end{lstlisting} |
|
793 |
\end{center} |
|
794 |
||
795 |
\begin{tikzpicture}[remember picture,overlay] |
|
796 |
\draw[->,very thick] (LA) edge [->,to path={-- ++(12mm,0mm) |
|
797 |
-- ++(0mm,17.3mm) |- (\tikztotarget)},line width=1mm] (LB.east); |
|
798 |
\draw[->,very thick] (LC) edge [->,to path={-- ++(12mm,0mm) |
|
799 |
-- ++(0mm,-17.3mm) |- (\tikztotarget)},line width=1mm] (LD.east); |
|
800 |
\end{tikzpicture} |
|
801 |
||
802 |
\end{frame} |
|
803 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
804 |
||
805 |
||
806 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
807 |
\begin{frame}[c,fragile] |
|
808 |
\frametitle{Compiling Writes} |
|
809 |
||
810 |
\small |
|
811 |
\begin{lstlisting}[language=JVMIS,mathescape, |
|
812 |
numbers=none,xleftmargin=-6mm] |
|
813 |
.method public static write(I)V |
|
814 |
.limit locals 1 |
|
815 |
.limit stack 2 |
|
811 | 816 |
getstatic java/lang/System/out Ljava/io/PrintStream; |
608 | 817 |
iload 0 |
818 |
invokevirtual java/io/PrintStream/println(I)V |
|
819 |
return |
|
820 |
.end method |
|
821 |
||
822 |
||
823 |
||
824 |
iload $E(x)$ |
|
825 |
invokestatic XXX/XXX/write(I)V |
|
826 |
\end{lstlisting} |
|
827 |
||
828 |
\end{frame} |
|
829 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
830 |
||
831 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
832 |
\begin{frame}[c,fragile] |
|
833 |
\frametitle{Compiling Main} |
|
834 |
||
835 |
\footnotesize |
|
836 |
\begin{lstlisting}[language=JVMIS,mathescape, |
|
837 |
numbers=none,xleftmargin=-6mm] |
|
838 |
.class public XXX.XXX |
|
839 |
.super java/lang/Object |
|
840 |
||
811 | 841 |
... |
608 | 842 |
|
843 |
.method public static main([Ljava/lang/String;)V |
|
844 |
.limit locals 200 |
|
845 |
.limit stack 200 |
|
846 |
||
847 |
$\textit{\ldots{}here comes the compiled code\ldots}$ |
|
848 |
||
849 |
return |
|
850 |
.end method |
|
851 |
\end{lstlisting} |
|
852 |
||
811 | 853 |
%.method public <init>()V |
854 |
% aload_0 |
|
855 |
% invokenonvirtual java/lang/Object/<init>()V |
|
856 |
% return |
|
857 |
%.end method |
|
858 |
||
859 |
||
608 | 860 |
\end{frame} |
861 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
862 |
||
863 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
864 |
\begin{frame}[c] |
|
686 | 865 |
\frametitle{Next Compiler Phases} |
608 | 866 |
|
867 |
\begin{itemize} |
|
868 |
\item assembly $\Rightarrow$ byte code (class file) |
|
869 |
\item labels $\Rightarrow$ absolute or relative jumps\bigskip\bigskip |
|
870 |
\item \texttt{javap} is a disassembler for class files |
|
686 | 871 |
\item jasmin and krakatau are assemblers for jvm code |
369
43c0ed473720
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
302
diff
changeset
|
872 |
\end{itemize} |
43c0ed473720
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
302
diff
changeset
|
873 |
|
686 | 874 |
\end{frame} |
608 | 875 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
876 |
||
877 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
878 |
\begin{frame}[t] |
|
686 | 879 |
\frametitle{Recall: Interpreted Code} |
880 |
||
881 |
\begin{center} |
|
882 |
\begin{tikzpicture} |
|
883 |
\begin{axis}[axis x line=bottom, axis y line=left, xlabel=n, ylabel=secs, legend style=small] |
|
884 |
\addplot+[smooth] file {interpreted.data}; |
|
885 |
\end{axis} |
|
886 |
\end{tikzpicture} |
|
887 |
\end{center} |
|
888 |
||
889 |
Loop program |
|
890 |
\end{frame} |
|
891 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
892 |
||
893 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
894 |
\begin{frame}[t] |
|
895 |
\frametitle{Compiled Code} |
|
608 | 896 |
|
897 |
\begin{center} |
|
898 |
\begin{tikzpicture} |
|
899 |
\begin{axis}[axis x line=bottom, axis y line=left, xlabel=n, ylabel=secs, legend style=small] |
|
900 |
\addplot+[smooth] file {compiled.data}; |
|
901 |
\end{axis} |
|
902 |
\end{tikzpicture} |
|
903 |
\end{center} |
|
904 |
||
686 | 905 |
\end{frame} |
608 | 906 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
907 |
||
908 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
909 |
\begin{frame}[t] |
|
686 | 910 |
\frametitle{Compiler vs.~Interpreter} |
608 | 911 |
|
912 |
\begin{center} |
|
913 |
\begin{tikzpicture} |
|
914 |
\begin{axis}[axis x line=bottom, axis y line=left, ylabel=secs, |
|
915 |
xlabel=n, |
|
916 |
enlargelimits=0.05, |
|
917 |
ybar interval=0.7, legend style=small] |
|
918 |
\addplot file {interpreted2.data}; |
|
919 |
\addplot file {compiled2.data}; |
|
920 |
%\legend{interpreted, compiled} |
|
921 |
\end{axis} |
|
922 |
\end{tikzpicture} |
|
923 |
\end{center} |
|
924 |
||
686 | 925 |
\end{frame} |
608 | 926 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
927 |
||
928 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
686 | 929 |
\begin{frame}[c] |
930 |
\frametitle{A ``Compiler'' for BF*** to C} |
|
931 |
||
932 |
\begin{center} |
|
933 |
\begin{tabular}{lcl} |
|
934 |
\bl{\texttt{>}} & $\Rightarrow$ & \texttt{ptr++}\\ |
|
935 |
\bl{\texttt{<}} & $\Rightarrow$ & \texttt{ptr--}\\ |
|
936 |
\bl{\texttt{+}} & $\Rightarrow$ & \texttt{(*ptr)++}\\ |
|
937 |
\bl{\texttt{-}} & $\Rightarrow$ & \texttt{(*ptr)--}\\ |
|
938 |
\bl{\texttt{.}} & $\Rightarrow$ & \texttt{putchar(*ptr)}\\ |
|
939 |
\bl{\texttt{,}} & $\Rightarrow$ & \texttt{*ptr = getchar()}\\ |
|
940 |
\bl{\texttt{[}} & $\Rightarrow$ & \texttt{while(*ptr)\{}\\ |
|
941 |
\bl{\texttt{]}} & $\Rightarrow$ & \texttt{\}}\medskip\\ |
|
942 |
& $\Rightarrow$ & ignore everything else\\ |
|
943 |
\end{tabular} |
|
944 |
\end{center}\bigskip |
|
945 |
||
946 |
\texttt{char field[30000]\\ char *ptr = \&field[15000]} |
|
947 |
||
948 |
\end{frame} |
|
949 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
950 |
||
951 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
952 |
\begin{frame}[c,fragile] |
|
953 |
\frametitle{BF***} |
|
954 |
||
955 |
we need some big array, say \texttt{arr} and 7 (8) instructions:\medskip |
|
956 |
||
957 |
\begin{itemize} |
|
958 |
\item \texttt{>} move \texttt{ptr++} |
|
959 |
\item \texttt{<} move \texttt{ptr-{}-} |
|
960 |
\item \texttt{+} add \texttt{arr[ptr]++} |
|
961 |
\item \texttt{-} subtract \texttt{arr[ptr]-{}-} |
|
962 |
\item \texttt{.} print out \texttt{arr[ptr]} as ASCII |
|
963 |
\item \texttt{[} if \texttt{arr[ptr] == 0} jump just after the corresponding \texttt{]}; otherwise \texttt{ptr++} |
|
964 |
\item \texttt{]} if \texttt{arr[ptr] != 0} jump just after the corresponding \texttt{[}; otherwise \texttt{ptr++} |
|
965 |
||
966 |
\end{itemize} |
|
967 |
||
968 |
\end{frame} |
|
969 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
970 |
||
971 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
972 |
\begin{frame}[c,fragile] |
|
973 |
\frametitle{Arrays in While} |
|
974 |
||
975 |
\begin{itemize} |
|
976 |
\item \texttt{new arr[15000]}\medskip |
|
977 |
\item \texttt{x := 3 + arr[3 + y]}\medskip |
|
978 |
\item \texttt{arr[42 * n] := ...} |
|
979 |
\end{itemize} |
|
980 |
||
981 |
\end{frame} |
|
982 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
983 |
||
984 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
985 |
\begin{frame}[c,fragile] |
|
986 |
\frametitle{New Arrays} |
|
987 |
||
988 |
\begin{lstlisting}[mathescape,numbers=none,language=While] |
|
989 |
new arr[number] |
|
990 |
\end{lstlisting}\bigskip\bigskip |
|
991 |
||
992 |
\begin{lstlisting}[mathescape,numbers=none,language=JVMIS] |
|
993 |
ldc number |
|
994 |
newarray int |
|
995 |
astore loc_var |
|
996 |
\end{lstlisting} |
|
997 |
||
998 |
||
999 |
\end{frame} |
|
1000 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1001 |
||
1002 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1003 |
\begin{frame}[c,fragile] |
|
1004 |
\frametitle{Array Update} |
|
1005 |
||
1006 |
\begin{lstlisting}[mathescape,numbers=none,language=While] |
|
1007 |
arr[...] := |
|
1008 |
\end{lstlisting}\bigskip\bigskip |
|
1009 |
||
1010 |
\begin{lstlisting}[mathescape,numbers=none,language=JVMIS] |
|
1011 |
aload loc_var |
|
1012 |
index_aexp |
|
1013 |
value_aexp |
|
1014 |
iastore |
|
1015 |
\end{lstlisting} |
|
1016 |
||
1017 |
||
1018 |
\end{frame} |
|
1019 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1020 |
||
1021 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1022 |
\begin{frame}[c,fragile] |
|
1023 |
\frametitle{Array Lookup in AExp} |
|
1024 |
||
1025 |
\begin{lstlisting}[mathescape,numbers=none,language=While] |
|
1026 |
...arr[...]... |
|
1027 |
\end{lstlisting}\bigskip\bigskip |
|
1028 |
||
1029 |
\begin{lstlisting}[mathescape,numbers=none,language=JVMIS] |
|
1030 |
aload loc_var |
|
1031 |
index_aexp |
|
1032 |
iaload |
|
1033 |
\end{lstlisting} |
|
1034 |
||
1035 |
||
1036 |
\end{frame} |
|
1037 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1038 |
||
1039 |
||
1040 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
608 | 1041 |
\mode<presentation>{ |
1042 |
\begin{frame}[c] |
|
1043 |
\frametitle{Backend} |
|
1044 |
||
1045 |
\begin{center} |
|
1046 |
\begin{tikzpicture} |
|
1047 |
\node (rexp) {\bl{\bf Lexer}}; |
|
1048 |
\node (nfa) [right=of rexp] {\bl{\bf Parser}}; |
|
1049 |
\node (dfa) [right=of nfa] {\bl{\begin{tabular}{c}\bf Optimizations\end{tabular}}}; |
|
1050 |
\path[->, red, line width=2mm] (rexp) edge node [above=4mm, black] {\begin{tabular}{c@{\hspace{9mm}}}token\\[-1mm] |
|
1051 |
sequence\end{tabular}} (nfa); |
|
1052 |
\node (final) [below=of dfa] {\bl{\begin{tabular}{c}\bf Machine Code/\\\bf Byte Code\end{tabular}}}; |
|
1053 |
\path[->, red, line width=2mm] (nfa) edge node [above=4mm, black] {\begin{tabular}{c}parse\\[-1mm] tree |
|
1054 |
\end{tabular}}(dfa); |
|
1055 |
\path[->, red, line width=2mm] (dfa) edge (final); |
|
1056 |
\end{tikzpicture}\\ |
|
1057 |
\end{center} |
|
1058 |
||
1059 |
\end{frame}} |
|
369
43c0ed473720
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
302
diff
changeset
|
1060 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
43c0ed473720
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
302
diff
changeset
|
1061 |
|
608 | 1062 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
1063 |
\mode<presentation>{ |
|
1064 |
\begin{frame}[t] |
|
1065 |
\frametitle{\begin{tabular}{c}What is Next\end{tabular}} |
|
1066 |
||
1067 |
\begin{itemize} |
|
1068 |
\item register spilling |
|
1069 |
\item dead code removal |
|
1070 |
\item loop optimisations |
|
1071 |
\item instruction selection |
|
1072 |
\item type checking |
|
1073 |
\item concurrency |
|
1074 |
\item fuzzy testing |
|
1075 |
\item verification\bigskip\\ |
|
1076 |
||
1077 |
\item GCC, LLVM, tracing JITs |
|
1078 |
\end{itemize} |
|
1079 |
||
1080 |
\end{frame}} |
|
1081 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
1082 |
||
184
2e9134d25a2b
added slides
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
173
diff
changeset
|
1083 |
|
812 | 1084 |
|
1085 |
\begin{frame}<1-10> |
|
1086 |
\end{frame} |
|
1087 |
||
63 | 1088 |
\end{document} |
1089 |
||
1090 |
%%% Local Variables: |
|
1091 |
%%% mode: latex |
|
1092 |
%%% TeX-master: t |
|
1093 |
%%% End: |
|
1094 |