Camil Demetrescu edited intro.tex  over 8 years ago

Commit id: 175f1f497c841bb3a836df5fc6bf4ef26362712f

deletions | additions      

       

In a 2013 paper Lameed and Hendren propose McOSR~\cite{lameed2013modular}, a technique for OSR that essentially stores the live values in a global buffer, recompiles the current function and then loads in it the saved state when the execution is resumed. Their approach shows a few limitations that we discuss later on in this paper, and because of some relevant design choices it can work only with the legacy JIT that has been dropped since LLVM's release 3.6.  \paragraph{Contributions.}  In this paper we present our a  novel, platform-independent target-independent  framework for LLVM to enable switching between different versions of a function at run-time. Specific goals of our approach include: \begin{itemize}  \item The ability for a function reached via OSR to fire an OSR itself: this would allow switching from a base function $f_0$ to an optimized function $f_1$, and later on to a further optimized version $f_2$, etc.  \item Supporting deoptimization, i.e., transitions from an optimized function to a less optimized function from which it was derived. 

\item Hiding from the front-end that generates the different optimized versions of a function all the implementation details of how on-the-fly transitions between them are handled at specific OSR points.  \end{itemize}  \noindent Design goals of our implementation include: We implemented the proposed approach in a prototype library for IR manipulation based on MCJIT called \osrkit, designed with the following goals:  \begin{itemize}  \item Encoding OSR transitions in terms of pure IR code only, avoiding manipulations at machine-code level.  \item Incurring a minimal level of intrusiveness in terms of both the instrumentation of the code generated by the front-end and the impact of OSR points on native code quality. 

%\item Providing support for the redirection of future invocations of a function to the latest compiled version without recompiling the callers or performing linking again.  \end{itemize}  \noindent Our %Our  implementation ships as a library for IR manipulation, and we present a preliminary experimental study of our technique in \tinyvm\, a proof-of-concept virtual machine for run-time IR manipulation and compilation based on MCJIT. We also present \noindent To show the potential of our approach, we extend the McVM~\cite{chevalier2010mcvm} virtual machine for MATLAB, showing how to enable aggressive specialization mechanism for the {\tt feval} construct\ - a source of bottlenecks in many MATLAB programs~\cite{lameed2013feval, radpour2013refactoring} - that could not have been implemented using extant OSR techniques.  %present  a case study on the integration of our technique in McVM~\cite{chevalier2010mcvm}: we show the potential of our approach by enabling an aggressive specialization mechanism for the {\tt feval} construct\ - a source of bottlenecks in many MATLAB programs~\cite{lameed2013feval, radpour2013refactoring} - that could not have been implemented using extant OSR techniques. \paragraph{Structure of the paper.}  The remainder of this paper is organized as follows. In \mysection\ref{se:overview} we present our OSR technique and in \mysection\ref{se:osr-llvm} we outline its implementation and Application Program Interface (API) in LLVM. \mysection\ref{se:case-study} illustrates a case study in McVM. In \mysection\ref{se:experiments}, we present our experimental study and discuss implications of inserting OSR points in a LLVM function, while \mysection\ref{se:related} addresses related work. \mysection\ref{se:conclusions} concludes the paper and presents some ideas for future research directions.