Camil Demetrescu edited approach.tex  over 8 years ago

Commit id: f14098b8ffbf794e0d8b8027cfee836c477d02fb

deletions | additions      

       

\end{figure}  \fi  \section{Approach}  \label{se:approach} \section{Overview}  \label{se:overview}  The key to platform independence in our work is to encode the entire OSR machinery at an abstract code level, without resorting to machine-level code manipulation. Before %Before  describing how this is achieved in LLVM, we provide an overview of our approach. \subsection{Overview}  \label{ss:overview} %\subsection{Overview}  %\label{ss:overview}  Consider the generic OSR scenario shown in \ifauthorea{Figure~}{}\ref{fi:osr-dynamics}. A base function \fbase\ is executed and it can either terminate normally (dashed lines), or an OSR event may transfer control to a variant \fvariant. The decision of whether an OSR should be fired at a given point \osrpoint\ of \fbase\ is based on an {\em OSR condition}. A typical example is a guard testing whether \fbase\ has become unsafe and execution needs to fall back to a safe version \fvariant. This scenario includes deoptimization of functions generated with aggressive speculative optimizations. Another example is a profile counter reaching a certain hotness threshold, which indicates that \fbase\ is taking longer than expected and is worth optimizing. This is a frequent scenario in JIT-based virtual machines. 

The open OSR scenario is similar, with one main difference (see \ifauthorea{Figure~}{}\ref{fi:overview-osr-open}): instead of calling \fosrto\ directly, \fosrfrom\ calls a stub function \fstub, which first creates \fosrto\ and then calls it. Function \fosrto\ is generated by a function {\tt gen} that takes the base function \fbase\ and the OSR point \osrpoint\ as input. The reason for having a stub in the open OSR scenario, rather than directly instrumenting \fbase\ with the code generation machinery, is to minimize the extra code injected into \fbase. Indeed, instrumentation may interfere with optimizations, e.g., by increasing register pressure and altering code layout and instruction cache behavior.  \subsection{Discussion}  \label{ss:discussion} %\subsection{Discussion}  %\label{ss:discussion}  \paragraph{Discussion}  Instrumenting functions for OSR at a higher level of representation than machine code yields several benefits:   \begin{enumerate}  \item {\em Platform independence}: the OSR instrumentation code is lowered to native code by the compiler backend, which handles the details of the target ABI;