Daniele Cono D'Elia edited case-study.tex  over 8 years ago

Commit id: c2ac50f5bfdb7530755629dc019ecb21f76f5402

deletions | additions      

       

When the IIR compiler processes an annotated \feval\ instruction, it stores in the metadata of the function version being compiled the current variable map (i.e., a map between IIR and IR objects), the {\tt llvm::BasicBlock*} created for the \feval\ and the {\tt llvm::Value*} object corresponding to the first argument for the \feval. The last two objects are used by the inserter component as source label and {\tt val} argument for inserting an open OSR point. The open-OSR stub will in turn invoke the callback optimizer component we are about to present.  \newcommand{\gbase}{$g$}  \newcommand{\gOpt}{$g_{opt}$}  \newcommand{\gIIR}{$f^{IIR}$}  \newcommand{\gIR}{}  \newcommand{\gOptIIR}{$g^{IIR}_{opt}$}  \newcommand{\gOptIR}{$g^{IR}_{opt}$}  \subsection{Generating Optimized Code}  The core of our optimization pipeline is the optimizer module that is responsible for generating optimized code for the current function $f$ using the run-time value of the first argument for \feval and contextual information passed from the open-OSR stub. As a first step, the optimizer inspects {\tt val} to resolve the target of the call - which we call $g$ $f$  - and check whether a previously compiled optimized function is available from the code cache. If not, a new function $f_{opt}$ \gOpt\  is generated by cloning the IIR representation $f^{IIR}$ \gIIR\  of $f$ \gbase\  into $f^{IIR}_{opt}$ \gOptIIR\  and replacing all the \feval\ calls in the same group of the instrumented one with direct calls to $g$. $f$.  As a next step, the optimizer asks the IIR compiler to analyze $f^{IIR}_{opt}$ \gOptIIR\  and generate optimized LLVM IR $f^{IR}_{opt}$, \gOptIR,  also making a copy of the variable map between IIR and IR objects when compiling the direct call corresponding to the \feval\ instruction that triggered the OSR. This map is essential for the construction of a state mapping between $f^{IR}$ to $f^{IR}_{opt}$, as it is compared against the corresponding map stored during the lowering of $f$ to determine for each value in $f^{IR}_{opt}$ live at the continuation block whether:  \begin{itemize}