Camil Demetrescu edited intro.tex  over 8 years ago

Commit id: 680f70dca51d9c95836eb4560c9416f27af0a923

deletions | additions      

       

Currently VM builders using MCJIT are required to have a deep knowledge of the internals of LLVM in order to mimic a transitioning mechanism. In particular, they can rely on two experimental intrinsics, {\em Stackmap} and {\em Patchpoint}, to inspect the details of the compiled code generated by the back-end and to patch it manually with a sequence of assembly instructions. In particular, a Stackmap records the location of live values at a particular instruction address and during the compilation it is emitted into the object code within a designated section; a Patchpoint instead allows to reserve space at an instruction address for run-time patching and can be used to implement an inline caching mechanism~\cite{webkit14}.%~\cite{deutsch1984inlinecaching, webkit14}.  %In a 2013 paper  Lameed and Hendren propose McOSR~\cite{lameed2013modular}, a technique for OSR that 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 in \mysection\ref{se:osr-llvm}, and due to some relevant design choices, it can only work works  with the legacy JIT that is no longer included in LLVM since release 3.6. \paragraph{Contributions.}  In this paper we investigate general-purpose, target-independent implementations of on-stack replacement. Specific goals of our approach include: 

%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, we believe that they could 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 runtime~\cite{chevalier2010mcvm} based on \osrkit\footnote{\osrkit\ is available at \url{https://github.com/dcdelia/tinyvm}.} \osrkit\  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 the OSR machinery injected by \osrkit\ has a small level of intrusiveness and the optimizations enabled by our approach yield significant speedups 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.