249 \multicolumn{3}{@{}l@{}}{$\text{eval}(\text{while}\;b\;\text{do}\;cs, E) \dn$}\\ |
269 \multicolumn{3}{@{}l@{}}{$\text{eval}(\text{while}\;b\;\text{do}\;cs, E) \dn$}\\ |
250 \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{if}\;\text{eval}(b,E)$}\\ |
270 \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{if}\;\text{eval}(b,E)$}\\ |
251 \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{then}\; |
271 \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{then}\; |
252 \text{eval}(\text{while}\;b\;\text{do}\;cs, \text{eval}(cs,E))$}\\ |
272 \text{eval}(\text{while}\;b\;\text{do}\;cs, \text{eval}(cs,E))$}\\ |
253 \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{else}\; E$}\\ |
273 \multicolumn{3}{@{}l@{}}{\hspace{2cm}$\text{else}\; E$}\\ |
254 $\text{eval}(\text{print}\; x, E)$ & $\dn$ & $\{\;\text{println}(E(x))\; ;\;E\;\}$\\ |
274 $\text{eval}(\text{write}\; x, E)$ & $\dn$ & $\{\;\text{println}(E(x))\; ;\;E\;\}$\\ |
255 \end{tabular}} |
275 \end{tabular}} |
256 \end{center} |
276 \end{center} |
257 |
277 |
258 \end{frame}} |
278 \end{frame}} |
259 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
279 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
294 |
314 |
295 \begin{itemize} |
315 \begin{itemize} |
296 \item introduced in 1995 |
316 \item introduced in 1995 |
297 \item is a stack-based VM (like Postscript, CLR of .Net) |
317 \item is a stack-based VM (like Postscript, CLR of .Net) |
298 \item contains a JIT compiler |
318 \item contains a JIT compiler |
299 \item many languages take advantage of the infrastructure (JRE) |
319 \item many languages take advantage of JVM's infrastructure (JRE) |
300 \item languages compiled to the JVM: Scala, Clojure\ldots |
320 \item languages compiled to the JVM: Scala, Clojure\ldots |
301 \item garbage collected |
321 \item is garbage collected $\Rightarrow$ no buffer overflows |
302 \end{itemize} |
322 \end{itemize} |
303 |
323 |
304 \end{frame}} |
324 \end{frame}} |
305 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
325 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
306 |
326 |
419 \item lookup: \bl{$\text{iload}\; number$} |
439 \item lookup: \bl{$\text{iload}\; number$} |
420 \item store: \bl{$\text{istore}\; number$} |
440 \item store: \bl{$\text{istore}\; number$} |
421 \end{itemize}\bigskip\pause |
441 \end{itemize}\bigskip\pause |
422 |
442 |
423 during compilation we have to maintain a map between our identifiers and the |
443 during compilation we have to maintain a map between our identifiers and the |
424 java bytecode numbers |
444 Java bytecode numbers |
425 |
445 |
426 \begin{center} |
446 \begin{center} |
427 \bl{$\text{compile}(a, E)$} |
447 \bl{$\text{compile}(a, E)$} |
428 \end{center} |
448 \end{center} |
429 |
449 |
590 \frametitle{\begin{tabular}{c}Compiling Ifs\end{tabular}} |
610 \frametitle{\begin{tabular}{c}Compiling Ifs\end{tabular}} |
591 |
611 |
592 {\Large\bl{if $b$ then $cs_1$ else $cs_2$}} |
612 {\Large\bl{if $b$ then $cs_1$ else $cs_2$}} |
593 |
613 |
594 \begin{center} |
614 \begin{center} |
595 \bl{\begin{tabular}{l} |
615 \bl{\begin{tabular}{lcl} |
596 iload $n_x$\\ |
616 $\text{compile}(\text{if}\;b\;\text{then}\; cs_1\;\text{else}\; cs_2, E)$ & $\dn$\\ |
597 ldc 1\\ |
617 \multicolumn{3}{l}{$\quad l_{ifelse}\;$ \textcolor{black}{(fresh label)}}\\ |
598 iadd\\ |
618 \multicolumn{3}{l}{$\quad l_{ifend}\;$ \textcolor{black}{(fresh label)}}\\ |
599 istore $n_x$\\ |
619 \multicolumn{3}{l}{$\quad (is_1, E') = \text{compile}(cs_1, E)$}\\ |
|
620 \multicolumn{3}{l}{$\quad (is_2, E'') = \text{compile}(cs_2, E')$}\\ |
|
621 \multicolumn{3}{l}{$\quad(\text{compile}(b, E, l_{ifelse})$}\\ |
|
622 \multicolumn{3}{l}{$\quad\phantom{(}@\;is_1$}\\ |
|
623 \multicolumn{3}{l}{$\quad\phantom{(}@\; \text{goto}\;l_{ifend}$}\\ |
|
624 \multicolumn{3}{l}{$\quad\phantom{(}@\;l_{ifelse}:$}\\ |
|
625 \multicolumn{3}{l}{$\quad\phantom{(}@\;is_2$}\\ |
|
626 \multicolumn{3}{l}{$\quad\phantom{(}@\;l_{ifend}:, E'')$}\\ |
600 \end{tabular}} |
627 \end{tabular}} |
601 \end{center} |
628 \end{center} |
602 |
629 |
603 \end{frame}} |
630 \end{frame}} |
604 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
631 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
648 \frametitle{\begin{tabular}{c}Compiling Whiles\end{tabular}} |
675 \frametitle{\begin{tabular}{c}Compiling Whiles\end{tabular}} |
649 |
676 |
650 {\Large\bl{while $b$ do $cs$}} |
677 {\Large\bl{while $b$ do $cs$}} |
651 |
678 |
652 \begin{center} |
679 \begin{center} |
653 \bl{\begin{tabular}{l} |
680 \bl{\begin{tabular}{lcl} |
654 iload $n_x$\\ |
681 $\text{compile}(\text{while}\; b\; \text{do} \;cs, E)$ & $\dn$\\ |
655 ldc 1\\ |
682 \multicolumn{3}{l}{$\quad l_{wbegin}\;$ \textcolor{black}{(fresh label)}}\\ |
656 iadd\\ |
683 \multicolumn{3}{l}{$\quad l_{wend}\;$ \textcolor{black}{(fresh label)}}\\ |
657 istore $n_x$\\ |
684 \multicolumn{3}{l}{$\quad (is, E') = \text{compile}(cs_1, E)$}\\ |
|
685 \multicolumn{3}{l}{$\quad(l_{wbegin}:$}\\ |
|
686 \multicolumn{3}{l}{$\quad\phantom{(}@\;\text{compile}(b, E, l_{wend})$}\\ |
|
687 \multicolumn{3}{l}{$\quad\phantom{(}@\;is$}\\ |
|
688 \multicolumn{3}{l}{$\quad\phantom{(}@\; \text{goto}\;l_{wbegin}$}\\ |
|
689 \multicolumn{3}{l}{$\quad\phantom{(}@\;l_{wend}:, E'')$}\\ |
658 \end{tabular}} |
690 \end{tabular}} |
659 \end{center} |
691 \end{center} |
660 |
692 |
661 \end{frame}} |
693 \end{frame}} |
662 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
694 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
667 \frametitle{\begin{tabular}{c}Compiling Writes\end{tabular}} |
699 \frametitle{\begin{tabular}{c}Compiling Writes\end{tabular}} |
668 |
700 |
669 {\Large\bl{write $x$}} |
701 {\Large\bl{write $x$}} |
670 |
702 |
671 \begin{center} |
703 \begin{center} |
672 \bl{\begin{tabular}{l} |
704 \small\bl{\begin{tabular}{l} |
673 iload $n_x$\\ |
705 .method public static write(I)V\\ |
674 ldc 1\\ |
706 \;\; .limit locals 5 \\ |
675 iadd\\ |
707 \;\; .limit stack 5 \\ |
676 istore $n_x$\\ |
708 \;\; iload 0 \\ |
|
709 \;\; getstatic java/lang/System/out Ljava/io/PrintStream;\\ |
|
710 \;\; swap \\ |
|
711 \;\; invokevirtual java/io/PrintStream/println(I)V \\ |
|
712 \;\; return \\ |
|
713 .end method\bigskip\bigskip\\ |
|
714 % |
|
715 \normalsize |
|
716 iload $E(x)$\\ |
|
717 invokestatic write(I)V\\ |
677 \end{tabular}} |
718 \end{tabular}} |
678 \end{center} |
719 \end{center} |
679 |
720 |
680 \end{frame}} |
721 \end{frame}} |
681 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
722 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
723 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
724 \mode<presentation>{ |
|
725 \begin{frame}[c] |
|
726 \frametitle{\begin{tabular}{c}Next Compiler Phases\end{tabular}} |
|
727 |
|
728 \begin{itemize} |
|
729 \item assembly $\Rightarrow$ native code |
|
730 \item labels $\Rightarrow$ absolute or relative addresses |
|
731 |
|
732 \end{itemize} |
|
733 |
|
734 \end{frame}} |
|
735 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
736 |
|
737 |
682 |
738 |
683 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
739 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
684 \mode<presentation>{ |
740 \mode<presentation>{ |
685 \begin{frame}[t] |
741 \begin{frame}[t] |
686 \frametitle{\begin{tabular}{c}Compiled vs.~Interpreted Code\end{tabular}} |
742 \frametitle{\begin{tabular}{c}Compiled vs.~Interpreted Code\end{tabular}} |
687 |
743 |
688 \begin{center} |
744 \begin{center} |
689 \begin{tikzpicture} |
745 \begin{tikzpicture} |
690 \begin{loglogaxis}[axis x line=bottom, axis y line=left, xlabel=n, ylabel=secs] |
746 \begin{loglogaxis}[axis x line=bottom, axis y line=left, xlabel=n, ylabel=secs, legend style=small] |
691 \addplot+[smooth] file {interpreted.data}; |
747 \addplot+[smooth] file {interpreted.data}; |
692 \addplot+[smooth] file {compiled.data}; |
748 \addplot+[smooth] file {compiled.data}; |
693 \end{loglogaxis} |
749 \end{loglogaxis} |
694 \end{tikzpicture} |
750 \end{tikzpicture} |
695 \end{center} |
751 \end{center} |
696 |
752 |
697 \end{frame}} |
753 \end{frame}} |
698 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
754 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
699 |
755 |
700 |
756 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
701 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
757 \mode<presentation>{ |
702 \mode<presentation>{ |
758 \begin{frame}[t] |
703 \begin{frame}[t] |
759 \frametitle{\begin{tabular}{c}Compiled vs.~Interpreted Code\end{tabular}} |
704 \frametitle{\begin{tabular}{c}Compiled Code\end{tabular}} |
|
705 |
760 |
706 \begin{center} |
761 \begin{center} |
707 \begin{tikzpicture} |
762 \begin{tikzpicture} |
708 \begin{axis}[axis x line=bottom, axis y line=left, xlabel=n, ylabel=secs] |
763 \begin{axis}[ylabel=secs, |
709 \addplot+[smooth] file {compiled.data}; |
764 xlabel=n, |
|
765 enlargelimits=0.05, |
|
766 ybar interval=0.7, legend style=small] |
|
767 \addplot file {interpreted2.data}; |
|
768 \addplot file {compiled2.data}; |
|
769 %\legend{interpreted, compiled} |
710 \end{axis} |
770 \end{axis} |
711 \end{tikzpicture} |
771 \end{tikzpicture} |
712 \end{center} |
772 \end{center} |
713 |
773 |
714 \end{frame}} |
774 \end{frame}} |
715 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
775 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
776 |
|
777 |
|
778 |
|
779 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
|
780 \mode<presentation>{ |
|
781 \begin{frame}[t] |
|
782 \frametitle{\begin{tabular}{c}What Next\end{tabular}} |
|
783 |
|
784 \begin{itemize} |
|
785 \item register spilling |
|
786 \item dead code removal |
|
787 \item loop optimisations |
|
788 \item instruction selection |
|
789 \item type checking |
|
790 \item concurrency |
|
791 \item fuzzy testing |
|
792 \item verification\bigskip\\ |
|
793 |
|
794 \item GCC, LLVM, tracing JITs |
|
795 \end{itemize} |
|
796 |
|
797 \end{frame}} |
|
798 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
716 |
799 |
717 |
800 |
718 \end{document} |
801 \end{document} |
719 |
802 |
720 %%% Local Variables: |
803 %%% Local Variables: |