dcdelia  over 8 years ago

Commit id: dafe775430c8b4eacdbef68c9a82fe7ad645e36d

deletions | additions      

       

\newcommand{\fIR}{$f^{IR}$}  \newcommand{\fOptIIR}{$f^{IIR}_{opt}$}  \newcommand{\fOptIR}{$f^{IR}_{opt}$}  \newcommand{\gTarget}{$g$}  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%  \paragraph{Optimizer.}  The optimizer is called as {\tt gen} function in the open OSR stub (see \myfigure\ref{fi:overview-osr-open}) created by the OSR inserter. It receives the IR version \fIR\ of function $f$, \fbase,  the basic block of \fIR\ where the OSR was fired, and the native code address of the \feval\ target function $g$. \gTarget.  As a first step, the optimizer looks up the IR code of $g$ \gTarget\  by its address and checks whether a previously compiled version of \fBase\ specialized with $g$ \gTarget\  was previously cached. %The core of our optimization pipeline is the optimizer module, which is responsible for generating optimized code for the running function \fBase\ using contextual information passed by an open-OSR stub. As a first step, the optimizer inspects {\tt val} to resolve the target $g$ of the \feval\ and checks whether a previously compiled version of \fBase\ optimized for $f$ is available from the cache.  \ifdefined \fullver  If not, a new function \fOptIIR\ is generated by cloning the IIR representation \fIIR\ of \fBase\ and by replacing all the \feval\ calls in the same group of the instrumented one with direct calls to $f$. \gTarget.  \else  If not, a new function \fOptIIR\ is generated by cloning the IIR representation \fIIR\ of \fBase\ and by replacing all \feval\ calls to $g$ \gTarget\  in \fOptIIR\ with direct calls. \fi  As a next step, the optimizer asks the IIR compiler to process \fOptIIR\ and generate optimized LLVM IR \fOptIR, also storing the variable map between IIR and IR objects when compiling the direct call corresponding to the \feval\ instruction that triggered the OSR.  \ifdefined \fullver  As a next step, the optimizer asks the IIR compiler to process \fOptIIR\ and generate optimized LLVM IR \fOptIR, also storing the variable map between IIR and IR objects when compiling the direct call corresponding to the \feval\ instruction that triggered the OSR.  \else  As a next step, the optimizer asks the IIR compiler to lower \fOptIIR\ to \fOptIR. During the process, the compiler stores the variable map between IIR and IR objects at the direct call replacing the \feval\ instruction that triggered the OSR.  \fi  This map is essential for the next step, which is constructing a state mapping between \fIR\ to \fOptIR, as it is compared against the corresponding map stored during the lowering of \fBase\ to determine whether for each value in \fOptIR\ live at the continuation block:  \begin{itemize} \begin{itemize}[noitemsep, partopsep=0.5ex, topsep=0.5ex]  \item an {\tt llvm::Value*} from \fIR\ passed as argument at the OSR point can be used directly  \item or, compensation code is required to reconstruct its value before jumping to the block.  \end{itemize}