Even Wiik Thomassen avatar Even Wiik Thomassen committed 2b63b47

Some more listings improvements.

Comments (0)

Files changed (5)

 * Do some work on reusing a subset of Haskell Prelude
 
 * Finish external Core chapter
-* Finish JIT chapter
 * Finish PyHaskell chapter
 
 * Create more benchmarks, testing different features and parts
 3. RPython - Done
 4. External Core - 50% done
 5. PyHaskell - 80% done
-6. JIT - 50% done
+6. JIT - Done
 7. Low level - 40% done
 8. Benchmarks - 10% done
 9. Discussion - Not started
 % Source code example for promotion
 \begin{listing}[htbp]
     \pycode{promotion}
-    \mycpt{Promotion example, RPython code}%
-        {--- \citet[p.~4]{bolz11}}{promote-code}
+    \mycpt{Promotion example: RPython code}%
+        {--- \citet[p.~4]{bolz11}}{lst:promote-code}
 \end{listing}
 
 % Trace, unoptimized, promotion
         return($v_2$)
     \end{lstlisting}
     \vspace{-10pt}
-    \mycpt{Promotion example, unoptimized trace}%
-        {--- \citet[p.~4]{bolz11}}{promote-unop}
+    \mycpt{Promotion example: unoptimized trace}%
+        {--- \citet[p.~4]{bolz11}}{lst:promote-unop}
 \end{listing}
 
 % Trace, optimized, promotion
         return($v_2$)
     \end{lstlisting}
     \vspace{-10pt}
-    \mycpt{Promotion example, optimized trace}%
-        {--- \citet[p.~4]{bolz11}}{promote-op}
+    \mycpt{Promotion example: optimized trace}%
+        {--- \citet[p.~4]{bolz11}}{lst:promote-op}
 \end{listing}
 
 
 % Source code example of elidable
 \begin{listing}[htbp]
     \pycode{elidable}
-    \mycpt{Elidable example, RPython code}%
-        {--- \citet[p.~4]{bolz11}}{elidable-code}
+    \mycpt{Elidable example: RPython code}%
+        {--- \citet[p.~4]{bolz11}}{lst:elidable-code}
 \end{listing}
 
 % Trace, unoptimized, elidable
         $a_1$.y = $v_3$
     \end{lstlisting}
     \vspace{-10pt}
-    \mycpt{Elidable example, unoptimized trace}%
-        {--- \citet[p.~4]{bolz11}}{elidable-unop}
+    \mycpt{Elidable example: unoptimized trace}%
+        {--- \citet[p.~4]{bolz11}}{lst:elidable-unop}
 \end{listing}
 
 % Trace, optimized, elidable
         $a_1$.y = $v_2$
     \end{lstlisting}
     \vspace{-10pt}
-    \mycpt{Elidable example, optimized trace}%
-        {--- \citet[p.~5]{bolz11}}{elidable-op}
+    \mycpt{Elidable example: optimized trace}%
+        {--- \citet[p.~5]{bolz11}}{lst:elidable-op}
 \end{listing}
 
 
 
 \begin{listing}[htbp]
     \pycode{immutable}
-    \mycpt{RPython hint example: \immfields}{}{immfields}
+    \mycpt{RPython hint example: \immfields}{}{lst:immfields}
 \end{listing}
 
 
 \begin{listing}[htbp]
     \pycode{jitdriver}
     \mycpt{PyHaskell haskell.py module excerpt showing RPython hints}%
-        {\cite{pyhaskell}}{jitdriver}
+        {\cite{pyhaskell}}{lst:jitdriver}
 \end{listing}
 
 \mylst{jitdriver} is an excerpt from PyHaskell's \textit{haskell}-module, which
 \begin{listing}[htbp]
     \pycode{unroll}
     \mycpt{PyHaskell module.py and haskell.py excerpts showing hints}%
-        {\cite{pyhaskell}}{unroll}
+        {\cite{pyhaskell}}{lst:unroll}
 \end{listing}
 
 PyHaskell treat only recursive functions as a possible trace heads, where as
 
 \begin{listing}[htbp]
     \pycode{numeric}
-    \vspace{-10pt}
-    \mycpt{PyHaskell numeric addition before \hint{elidable get\_var}}%
-        {}{num-elidable}
+    \mycpt{PyHaskell numeric addition before \hint{elidable} get\_var}%
+        {}{lst:num-elidable}
 \end{listing}
 
 \begin{listing}[htbp]
     \pycode{getvar}
-    \vspace{-10pt}
     \mycpt{Trace-elidable function for looking up in qvars dictionary}%
-        {}{get-var}
+        {}{lst:get-var}
 \end{listing}
 
 \mylst{addition-ex1} is the part of the addition trace that perform the
 operations in the \gls{jit} trace from 115 to 99, and reduced the number of
 guards from 21 to 15.
 
-\mytracelog[35]{45}{addition-no-elidable}{addition-ex1}{%
-    Addition benchmark: Trace excerpt --- before elidable}
-\mytracelog[35]{36}{addition-elidable}{addition-ex2}{%
-    Addition benchmark: Trace excerpt --- after elidable}
+\begin{listing}[htbp]
+    \tracelog{35}{45}{addition-no-elidable}
+    \mycpt{Addition benchmark: trace excerpt, before elidable}%
+        {}{lst:addition-ex1}
+\end{listing}
+
+\begin{listing}[htbp]
+    \tracelog{35}{36}{addition-elidable}
+    \mycpt{Addition benchmark: trace excerpt, after elidable}%
+        {}{lst:addition-ex2}
+\end{listing}
 
 \subsection{Benchmarks}
 \label{sec:todotodo}
 \begin{figure}[tbp]
 	\center
 	\includegraphics[scale=0.75]{./img/pipeline}
-	\caption[Haskell-Python pipeline]{%
-        Haskell-Python pipeline by \citet{skrede}\label{fig:pipeline}}
+	\mycpt{Haskell-Python pipeline by}{\citet{skrede}}{fig:pipeline}
 \end{figure}
 The \gls{ghc} frontend handle parsing and type-checking of Haskell source
 code before it desugar Haskell into the Core intermediate representation.
 \mytodo{actually implement IO (), and return it, then explain what I did and show an example}
 
 \begin{listing}[htbp]
-\begin{lstlisting}[basicstyle=\footnotesize, numberstyle=\tiny\color{gray}, numbers=right]
-%module main:Main
-  main:Main.main :: (ghc-prim:GHC.Types.IO
-                     ghc-prim:GHC.Tuple.()) =
-    base:System.IO.putStrLn
-    (ghc-prim:GHC.CString.unpackCString#
-     ("Hey"::ghc-prim:GHC.Prim.Addr#));
-  main::Main.main :: (ghc-prim:GHC.Types.IO
-                       ghc-prim:GHC.Tuple.()) =
-    base:GHC.TopHandler.runMainIO @ ghc-prim:GHC.Tuple.()
-    main:Main.main;
-\end{lstlisting}
-\caption{putStrLn example, GHC external Core output\label{lst:putStrLn-extcore}}
+    \begin{lstlisting}[style=hcr]
+        %module main:Main
+          main:Main.main :: (ghc-prim:GHC.Types.IO
+                             ghc-prim:GHC.Tuple.()) =
+            base:System.IO.putStrLn
+            (ghc-prim:GHC.CString.unpackCString#
+             ("Hey"::ghc-prim:GHC.Prim.Addr#));
+          main::Main.main :: (ghc-prim:GHC.Types.IO
+                               ghc-prim:GHC.Tuple.()) =
+            base:GHC.TopHandler.runMainIO @ ghc-prim:GHC.Tuple.()
+            main:Main.main;
+    \end{lstlisting}
+    \mycpt{putStrLn example: GHC external Core output}%
+        {}{lst:putStrLn-extcore}
 \end{listing}
 
 \begin{listing}[htbp]
-\begin{lstlisting}[basicstyle=\footnotesize, numberstyle=\tiny\color{gray}, numbers=right]
-runMainIO putStrLn unpackCString# Hey  => 
-putStrLn unpackCString# Hey  => 
-unpackCString# Hey  => 
-(Constr : H, (Constr : e, (Constr : y, (Constr []))))  => 
-putStrLn (Constr : H, (Constr : e, (Constr : y, (Constr []))))  => 
-Hey
-(Constr : H, (Constr : e, (Constr : y, (Constr []))))  => 
-runMainIO (Constr : H, (Constr : e, (Constr : y, (Constr []))))  => 
-\end{lstlisting}
-\caption{putStrLn example, PyHaskell evaluation log\label{lst:putStrLn-evallog}}
+    \begin{lstlisting}[style=pyhaskell]
+        runMainIO putStrLn unpackCString# Hey  => 
+        putStrLn unpackCString# Hey  => 
+        unpackCString# Hey  => 
+        (Constr : H, (Constr : e, (Constr : y, (Constr []))))  => 
+        putStrLn (Constr : H, (Constr : e, (Constr : y, (Constr []))))  => 
+        Hey
+        (Constr : H, (Constr : e, (Constr : y, (Constr []))))  => 
+        runMainIO (Constr : H, (Constr : e, (Constr : y, (Constr []))))  => 
+    \end{lstlisting}
+    \mycpt{putStrLn example: PyHaskell evaluation log}{}{lst:putStrLn-evallog}
 \end{listing}
 
 \subsection{Show}
 
 % Listings options
 %------------------
-\lstdefinestyle{pypymath}{%
+\lstdefinestyle{pypymath}{% PyPy trace with mathmode
     language=python,
-    numbersep=2pt,
-    numbers=right,
-    numberstyle=\tiny,
+    numbersep=2pt, numbers=right, numberstyle=\tiny\color{gray},
     basicstyle=\footnotesize,
     mathescape=true,
-    frame=lines,
-    framerule=0.2pt,
-    emph={guard, promote},
-    emphstyle=\color{blue},
+    frame=lines, framerule=0.2pt,
+    emph={guard, promote}, emphstyle=\color{blue},
+    gobble=8,
+}
+
+\lstdefinestyle{hcr}{% Haskell external Core output
+    language=haskell,
+    numbersep=2pt, numbers=right, numberstyle=\tiny\color{gray},
+    basicstyle=\footnotesize,
+    frame=lines, framerule=0.2pt,
+    gobble=8,
+}
+
+\lstdefinestyle{hcj}{% Core2js output, JSCore
+    numbersep=2pt, numbers=right, numberstyle=\tiny\color{gray},
+    basicstyle=\footnotesize,
+    frame=lines, framerule=0.2pt,
+    gobble=8,
+}
+
+\lstdefinestyle{pyhaskell}{% PyHaskell main loop output
+    numbersep=2pt, numbers=right, numberstyle=\tiny\color{gray},
+    basicstyle=\footnotesize,
+    frame=lines, framerule=0.2pt,
     gobble=8,
 }
 
 
 % Command for RPython JIT trace log minted listing
 %--------------------------------------------------
-\newcommand{\tracelog}[3][1]{%
+\newcommand{\tracelog}[3]{%
 	\inputminted[firstline=#1,lastline=#2,numbersep=2pt,numbers=left,
                  fontsize=\scriptsize,frame=lines]{pypylog}{./logs/#3.pypylog}
 	\vspace{-10pt}}
+
 \newcommand{\mytracelog}[5][1]{%
 \begin{listing}[tbp]
-    \tracelog[#1]{#2}{#3}
+    \tracelog{#1}{#2}{#3}
 	\caption{#5\label{lst:#4}}
 \end{listing}}
 
 % Caption command that hides cite from lists
 %--------------------------------------------
-\newcommand{\mycpt}[3]{\caption[#1]{#1~#2\label{lst:#3}}}
+\newcommand{\mycpt}[3]{\caption[#1]{#1~#2\label{#3}}}
 
 % System F commands
 %-------------------
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.