Camil Demetrescu edited approach.tex  over 8 years ago

Commit id: f32cd5437a1eafc095324ae23bbd1765ec252aaf

deletions | additions      

       

Our implementation targets two general scenarios: 1) {\em resolved OSR}: \fvariant\ is known before executing \fbase\ as in the deoptimization example discussed above; 2) {\em open OSR}: \fvariant\ is generated when the OSR is fired, supporting deferred compilation strategies. In both cases, \fbase\ is instrumented before its execution to incorporate the OSR machinery. We call such OSR-instrumented version \fosrfrom.  In the resolved OSR scenario (see \ifauthorea{Figure~}{}\ref{fi:overview-osr-final}), instrumentation consists of adding a check of the OSR condition and, if it is satisfied, a tail call that fires the OSR. The called function is an instrumented version of \fvariant, which we call \fosrto. The assumption is that \fosrto\ produces the same side-effects and return value that one would obtain by \fbase\ if no OSR was performed. Differently from \fvariant, \fosrto\ takes as input all live variables of \fbase\ at \osrpoint, executes an optional compensation code to fix the computation state ({\tt comp\_code}), and then jumps to a point \textsf{L'} from which execution can continue. The OSR practice often makes the conservative assumption that execution can always continue with the very same program state as the base function. However, this assumption may reduce the number of points where sound OSR transitions can be fired. Supporting compensation code in our framework adds flexibility, allowing OSR transitions to happen at arbitrary places in the base function.  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}  Instrumenting functions for OSR at a higher level of representation than machine code yields several benefits:   \begin{enumerate}  \item {\em platform independence}: both the base/variant code and the OSR instrumentation code are lowered to native code by the compiler backend, which handles the details of the target ABI;   \item [...]  \end{enumerate}  \ifdefined\noauthorea  \begin{figure}[t]  \begin{center} 

\end{figure}  \fi  In the resolved OSR scenario (see \ifauthorea{Figure~}{}\ref{fi:overview-osr-final}), instrumentation consists of adding a check of the OSR condition and, if it is satisfied, a tail call that fires the OSR. The called function is an instrumented version of \fvariant, which we call \fosrto. The assumption is that \fosrto\ produces the same side-effects and return value that one would obtain by \fbase\ if no OSR was performed. Differently from \fvariant, \fosrto\ takes as input all live variables of \fbase\ at \osrpoint, executes an optional compensation code to fix the computation state ({\tt comp\_code}), and then jumps to a point \textsf{L'} from which execution can continue. The OSR practice often makes the conservative assumption that execution can always continue with the very same program state as the base function. However, this assumption may reduce the number of points where sound OSR transitions can be fired. Supporting compensation code in our framework adds flexibility, allowing OSR transitions to happen at arbitrary places in the base function.  \ifdefined\noauthorea  \begin{figure}[t] \begin{figure}[h!]  \begin{center}  \includegraphics[width=1.0\columnwidth]{figures/overview-osr-open/overview-osr-open.eps}  \caption{\protect\input{figures/overview-osr-open/caption}} 

\end{figure}  \fi  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}  Instrumenting functions for OSR at a higher level of representation than machine code yields several benefits:   \begin{enumerate}  \item {\em platform independence}: both the base/variant code and the OSR instrumentation code are lowered to native code by the compiler backend, which handles the details of the target ABI;   \item [...]  \end{enumerate}