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

Commit id: d4bcd372c9a435cfb7369241fa867d34ef2efc9b

deletions | additions      

       

When the IIR compiler processes an annotated {\tt feval} instruction, it will store in the metadata of the function version being compiled a copy of its variable map (i.e., a map between IIR and IR objects), the current {\tt llvm::BasicBlock*} created for the call and the {\tt llvm::Value*} object corresponding to the first argument for the {\tt feval}. The last two objects are used by the helper component as source label and profiling value for inserting an open OSR point, with the copy of the variable map being passed (along with other information) as {\tt extra} field. The open-OSR stub will in turn invoke the callback optimizer component we are about to describe in the next subsection.  \subsection{Generating optimized code}  The core of the optimization pipeline is the callback optimizer component, that is responsible for generating optimized code for the current function $f$ using profiling (i.e., the object containing the first argument for \feval\) and contextual information passed from the open-OSR stub. As a first step, the optimizer will process the profiling object to resolve the target of the call - which we call $g$ - and check whether a previously compiled optimized function is available from the code cache. If not, a new function $f^{opt}$ $f_{opt}$  is generated by cloning the IIR representation $f_{IIR}$ $f^{IIR}$  of $f$ into $f^{opt}_{IIR}}$ $f^{IIR}_{opt}}$  and replacing all the \feval\ calls in the same group of the instrumented one with direct calls to $g$. As a next step, the optimizer asks the IIR compiler to analyze $f^{IIR}_{opt}$ and generate optimized LLVM IR $f^{IR}_{opt}$, also making a copy of the variable map when compiling the direct call corresponding to the \feval\ instruction that triggered the OSR transition. This variable map is essential for the construction of a state mapping between $f^{IR}$ to $f^{IR}_{opt}$, as it is compared against the variable map stored during the lowering of $f$ for the corresponding point to determine:  \begin{itemize}  \item [...]  \end{itemize}  As a next step, the optimizer asks the IIR compiler to generate the LLVM IR $f^{IR}_{opt}$ for $f^{IIR}_{opt}$, also saving a copy of the variable map when compiling the direct call corresponding to the \feval\ instruction that triggered the OSR transition. This variable map is compared against the variable map stored during the lowering of $f$ for the corresponding point, and a state mapping from $f^{IR}$ to $f^{IR}_{opt}$ is generated.