dcdelia  over 8 years ago

Commit id: 87b293aeb597c5e63bedeef83a866233ff52f1b9

deletions | additions      

       

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  \subsection{Description}  The main component of the artifact is an interactive VM called \tinyvm\ built on top of the LLVM MCJIT runtime environment and the \osrkit\ library. The VM provides an interactive environment for IR manipulation, JIT-compilation, and execution of functions either generated at run-time or loaded from disk: for instance, it allows the user to insert OSR points in loaded functions, run optimization passes on them, display their CFGs, and repeatedly invoke a function for a specified amount of times. \tinyvm\ supports dynamic library loading and linking, and includes a helper component for MCJIT that simplifies tasks such as handling multiple IR modules, symbol resolution in presence of multiple versions of a function, and trackingnative code and other  machine-level generated objects such as Stackmaps. code and data objects.  \tinyvm\ is located in {\small\tt /home/osrkit/Desktop/tinyvm/} and runs a case-insensitite command-line interpreter:  \begin{small} 

\end{verbatim}  \end{small}  \noindent Use ``help'' {\tt HELP}  to print basic documentation on how to use the shell. Usage scenarios are discussed in \ref{ss:art-eval-res}. \subsubsection{Check-list (artifact meta information)}         

\subsubsection{Session 1: OSR instrumentation in \osrkit}  \tinyvm\ implements a code generator for open OSR points that can dynamically inline a method whose address function calls to targets that  cannot be determined when the calling function is compiled. statically determined.  In the example from \myfigure\ref{fi:isord-example}, a comparator function {\tt c} is passed as argument to function {\tt isord}, which checks whether an array {\tt v} of numbers  is ordered according to the criterion encoded in {\tt c}. To interactively reproduce the experiment presented in \mysection\ref{se:osr-llvm}, we provide under the folder {\small\tt tinyvm/isord} a C driver module  {\small\tt inline.c} with an LLVM IR counterpart {\small\tt inline.ll} (generated with {\small\tt clang -S -emit-llvm -O1 inline.c}). \vspace{0.2em}  We can load the IR module in \tinyvm\ and show the code generated for method {\tt isord} with:  \begin{small}  \begin{verbatim} 

\end{verbatim}  \end{small}  \noindent A $\phi$-node {\tt \%i.01} is used to represent the index of theC  {\tt for} loop, loop from the C code,  and is set to {\tt \%10} when reached from the loop header (basic block {\tt \%2}) {\em after} a loop iteration. In fact, as a result of {\small \tt -O1} optimizations, with when  {\tt n>1} execution jumps from the function entrypoint {\tt \%0} directly into the loop body, initializing the $\phi$-node with {\tt 1}. Comparator {\tt c} is invoked with a tail call, storing its return value into virtual register {\tt \%8}. OSR points can be inserted with the {\tt INSERT\_OSR} command, which allows several combinations of features (see {\tt HELP} for details). an exhaustive list).  In this session we will modify {\tt isord} so that when the loop body is entered for the first time, an OSR is promptly aggressively  fired: \begin{small}  \begin{verbatim} 

\end{verbatim}  \end{small}  \noindent \tinyvm\ will {\tt UPDATE} the function in the following way: an {\tt ALWAYS}-true OSR condition is verified checked  before executing instruction {\tt \%4}, firing \%4} to fire  an {\tt OPEN} OSR transition to the {\tt DYN\_INLINE} code generator that generator, which  will inline any indirect function call to the function pointer {\tt \%c}. We choose {\tt \%4} as location for the OSR as it is the first non-$\phi$ instruction in the loop body, and body;  we also  hint the LLVM back-end through IR  profiling metadata thatthe OSR  firing an OSR  is {\tt 100}\%-likely. The IR will now look like: 

\end{verbatim}  \end{small}  \noindent\osrkit\ has split the {\tt \%.lr.ph}basic  block at for  the OSR point, condition,  also adding an {\tt OSR\_fire} block to transfer the execution state to {\tt isord\_stub} and eventually return the {\tt OSRRet} value. We can now let {\tt isord} run on a an array  dynamically initialized array through from  the {\tt driver} method, which takes as argument the array length to use. The method will also  populate it  with elements ordered for the comparator in use (see {\small\tt inline.c}). For instance, we will can  ask {\tt driver} to set up an array of $100000$ elements and run {\tt isord} on it: \begin{small}  \begin{verbatim}