% vim: spell spelllang=en

\documentclass[11pt,xcolor={usenames,dvipsnames}]{beamer}
\usetheme{Warsaw}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{my_listings}
\usepackage{math}
\usepackage{tikz}
\setbeamertemplate{navigation symbols}{}

\newcommand{\wrt}{\textit{wrt.}}

\newcommand*\oldmacro{}%
\let\oldmacro\insertshorttitle%
\renewcommand*\insertshorttitle{%
   \oldmacro\hfill%
   \insertframenumber\,/\,\inserttotalframenumber}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\author{Théophile \textsc{Bastian}}
\title[Tracing Compilation by Abstract Interpretation]
    {Tracing Compilation by Abstract Interpretation \\
    {\small{}S. Dissegna, F. Logozzo, F. Ranzato}}
\date{March 7, 2018}

\begin{document}

\begin{frame}
    \addtocounter{framenumber}{-1}
	\titlepage{}

    Slides: \url{https://tiny.tobast.fr/m2-absint-slides} \\
    Article: \url{https://tiny.tobast.fr/m2-absint-article}
\end{frame}

\begin{frame}
    \addtocounter{framenumber}{-1}
    \tableofcontents
\end{frame}

\section{Just-In-Time compilation}

\begin{frame}{Just-In-Time (JIT) compilation}
    \begin{itemize}
        \item Dynamic languages: \alert{hard to compile} (rely on runtime)
        \item Yet \alert{ubiquitous}: javascript, python, \ldots
        \item Idea: compile \alert{at runtime} the \alert{most used} program
            parts
        \item Used in browsers (JS), PyPy (Python), most JVMs (Java), \ldots
    \end{itemize}

    \vspace{1em}

    \begin{center}
        \begin{tikzpicture}[xscale=0.6, fill=GreenYellow]
            \fill (-8, 0) rectangle (-4, 2)
                node[pos=.5] {Source code};
            \fill (-2, 0) rectangle (2, 2)
                node[pos=.5] {Byte code};
            \fill (4, 0) rectangle (8, 2)
                node[pos=.5, align=center] {Byte/machine\\code};

            \draw[->, line width=2] (-4,1) -- (-2,1);
            \draw[->, line width=2] (2,1) -- (4,1);
            \node [rotate=60, anchor=west] at (-3.75, 1.1) {Bytecode compiler};
            \node [rotate=60, anchor=west] at (2.25, 1.1) {JIT compiler};

            \draw[RubineRed, line width=1] (0, 2) -- (0, 4);
            \draw[RubineRed, line width=1, dotted] (0, 0) -- (0, 2);
            \draw[RubineRed, line width=1] (0, -0.2) -- (0, 0);

            \node [rotate=90, anchor=south, RubineRed] at (-0.1, 3) {Offline};
            \node [rotate=-90, anchor=south, RubineRed] at (0.1, 3) {Runtime};
        \end{tikzpicture}
    \end{center}
\end{frame}

\begin{frame}{How is it done?}
    \begin{itemize}
        \item (In most cases) strong \alert{interaction} interpreter
            $\leftrightarrow$ JIT compiler
            \vspace{1em}
        \item \textit{Article claim}: mostly done using \alert{hot paths}
            within loops (in a single function); most speedup is \alert{type
            specialization}.
            \begin{itemize}
                \item Hot path: path \alert{used $\geq N$ times} at runtime in
                    a \alert{given} (abstract) \alert{store state}
            \end{itemize}
            \pause{}
        \item \alert{Wrong}. But, heh, we'll deal with it nevertheless. \\
            {\small (Inlining, translation to machine code, global
            optimizations, lock elimination, non-volatile-write
            elimination/propagation, \ldots)}
    \end{itemize}
\end{frame}

\section{Study setup}

\begin{frame}{Study objectives}
\end{frame}

\begin{frame}{Studied language}
\end{frame}

\section{Abstract interpretation}

\begin{frame}{AbsInt hot path extraction}
\end{frame}

\begin{frame}{Value type specialization}
\end{frame}

\section{Correctness proof}

\begin{frame}{Correctness proof sketch}
\end{frame}

\section*{Conclusion}

\begin{frame}{Conclusion}
    \begin{columns}[c]
        \column{.8 \textwidth}
        \begin{exampleblock}{Pros}
            \begin{itemize}
                \item Opens the way for AbsInt formalism in JIT
                \item Provides an (implemented?) framework for JIT study
            \end{itemize}
        \end{exampleblock}

        \begin{alertblock}{Cons}
            \begin{itemize}
                \item Overly restrictive in JIT features, pretends otherwise
                \item Unusably small toy language
                \item Absurdly hard to read toy language
                \item Proof \wrt{} some $\alpha$ which is not
                    \textit{that much} realistic
            \end{itemize}
        \end{alertblock}

        \column{.2 \textwidth}
        \begin{figure}
            \centering
            \hspace*{-1em}
            \includegraphics[width=1.4\textwidth]{img/absint.jpg}
        \end{figure}
    \end{columns}
\end{frame}

\end{document}
