Camil Demetrescu edited intro.tex  over 8 years ago

Commit id: ca4530415256106ef0c576cb84b5a363ac637c5c

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 a novel, investigate general-purpose,  target-independent framework for implementations of  on-stack replacement.While the ideas have been prototyped in LLVM, they may be applied to other toolchains.  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 We implemented the proposed approach in a prototype library for LLVM  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. 

%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.  \noindent While the general ideas we propose have been prototyped in LLVM, they may be applied to other toolchains as well.  To investigate the potential of our approach, we show how to optimize the {\tt feval} construct\ - a major source of inefficiency in MATLAB execution engines~\cite{lameed2013feval, radpour2013refactoring}. We present an extension of the MATLAB McVM~\cite{chevalier2010mcvm} runtime to enable aggressive specialization mechanisms for {\tt feval} that were not supported by extant techniques\cite{lameed2013feval}. An experimental evaluation of our technique reveals that OSR machinery injected by \osrkit\ has a small level of intrusiveness and the optimizations enabled by our approach yield significant speeedups in practical scenarios. %we extended McVM~\cite{chevalier2010mcvm}, 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.