dcdelia Comparison with McOSR  over 8 years ago

Commit id: 3983bdb3bc46c0791cad99e9d3066027127f98ad

deletions | additions      

       

%Function* src, BasicBlock* src_bb, std::string* F1NewName, OSRLibrary::OSRCond &cond, int branchTakenProb  %The generated stub calls a function inliner that generates a version of {\tt isord} where the comparator's body, pointed to by live variable {\tt c_osr}, is inlined in the loop body. The optimized version {\tt isordto} is shown in \myfigure\ref{fig:isordascto}.  \paragraph{Comparison with McOSR.}  McOSR~\cite{lameed2013modular} is a library for inserting open OSR points in the legacy LLVM JIT. McOSR is similar to \osrkit\ as it encodes OSR entirely in LLVM IR. When an OSR is fired, live variables are stored into a pool of global variables allocated by the library. While we generate an \fosrto\ function to resume the execution, McOSR calls a user-defined method to transform \fbase\ into \fvariant\ and then calls \fbase\ with empty parameters. In fact, the new entrypoint of \fbase\ checks a global flag to discriminate if it is being invoked in an OSR transition or as a regular call: in the first case, the state is restored from the pool of global variables before jumping to the OSR landing pad. As the new entrypoint can disrupt LLVM optimizations and lead to poorer performance on subsequent invocations of \fbase, McOSR recompiles \fbase\ after an OSR. Lessons from the Jikes RVM~\cite{fink2003design} suggest that generating a continuation function \fosrto\ is likely to yield better performance. \osrkit\ addresses a few limitations of McOSR, including: 1) only one version of a function can be active in memory; 2) there is no provision for resolved OSR points or compensation code; 3) OSR points can be inserted at loop headers only; 4) MCJIT does not allow to modify a JIT-ted IR function, and is this incompatible with MCOSR's design.         

Speculative variables~\cite{susskraut2009speculation} are introduced when the slow variant needs to track state (e.g., information for out-of-bound checks) that is missing in the fast variant. Switching operations are performed by Prospect at user-specified checkpoints in the original code.  \fi  \paragraph{McOSR.} %\paragraph{McOSR.}  McOSR~\cite{lameed2013modular} is a library for the LLVM legacy JIT compiler to insert OSR points at loop headers. When an OSR transition is fired, the live state is saved into a set of global variables (one per live variable) and a helper method is invoked to modify the IR of the function using a code transformer provided by the front-end and a copy of the original code saved as control version. The library generates a new entrypoint for the function to check a global condition and discriminate whether the function is being invoked through an OSR transition or a regular call: in the first case, values for live variables are read from the associated global variables, and the execution jumps to the block to resume the execution at. \ifdefined %\ifdefined  \fullver The %The  SSAUpdater component of LLVM is then used to restore the SSA form after the update. \fi  When %\fi  %When  the helper method returns, the updated function is invoked and the OSR is thus performed in a new stack frame. When the updated function returns, a second helper method is called to recompile the updated function to remove the new entrypoint inserted for the OSR transition, as it can disrupt LLVM optimizations and lead to poorer performance on subsequent invocations of the function. \paragraph{Other Related Work.}  \ifdefined \fullver