Camil Demetrescu edited approach.tex  over 8 years ago

Commit id: b2c4d7b39d11bb9a51af21d22e183d70b13f3597

deletions | additions      

       

\subsection{Overview}  \label{ss:overview}  Consider the generic OSR scenario shown in 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 \textsf{L} 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 \textsf{f} \fbase\  is taking longer than expected and is worth optimizing. This is a frequent scenario in JIT-based virtual machines. Classical OSR implementations adjust the stack so that execution can continue in \fvariant\ with the current frame \mynote{add citations}. This requires manipulating the program at machine code level and is highly ABI- and compiler-dependent. A simpler approach, which we follow in this article, consists of creating a new frame every time an OSR is fired, essentially regarding an OSR transition as a function call \mynote{cite WebKit and McVM}.   Our implementation targets two general scenarios: 1) {\bf resolved OSR}: \fvariant\ is known before executing \fbase, as in the deoptimization example discussed above; 2) {\bf open OSR}: \fvariant\ is generated when the OSR is fired, supporting deferred compilation strategies. In both cases, for an OSR to be fired at a certain point \textsf{L}, the base function needs to be \fbase\ is  instrumented before its execution with code that checks to incorporate  the OSR condition. machinery.  We denote with \fosrfrom\ the call such  OSR-instrumented version \fosrfrom. Instrumentation consists of adding a check  of \fbase. the OSR condition.  If the condition is satisfied, \fosrfrom\ yields to \fvariant\ fires the OSR  via a regular function call.In the first scenario, shown in Figure~\ref{fi:overview-osr-final}, the OSR invokes an instrumented version of \fvariant, which we call \fosrto. This is possible since \fvariant\ is known when \fbase\ is instrumented.  In the resolved OSR scenario, shown in Figure~\ref{fi:overview-osr-final}, the OSR invokes an instrumented version of \fvariant\ called \fosrto, passing to it {\em all variables that are live at the OSR point}. Notice that, differently from \fvariant, \fosrto\ takes as input the live variables of \fbase\ at \textsf{L}.  %and returns the same value when it has terminated. The assumption is that the called function produces the same side-effects and return values that one would obtain by \textsf{f} if no OSR were performed.  %\ref{fi:overview-osr-final}