Camil Demetrescu  over 8 years ago

Commit id: 9618713d6b4e4bfbf5da50a28c6dd36ef8018893

deletions | additions      

       

% !TEX root = article.tex  On-Stack Replacement (OSR) is a technique for dynamically transferring diverting  execution between different versions of a function at run time. %suspending the execution of a function and continuing with a different version of the code.   OSR is often typically  used in virtual machines to interrupt a long-running function and recompile it at a higher optimization level, or to replace it with a different one when a speculative assumption made during its compilation no longer holds. In this paper we present a framework for OSR that introduces novel ideas and combines features of extant techniques that no previous solution provided simultaneously. New features include OSR with compensation code to adjust the program state during a transition and the ability to fire an OSR from arbitrary locations in the code. Our approach is platform-independent as the OSR machinery is entirely encoded at a compiler's intermediate representation level. 

%and it allows a function version reached via OSR to fire an OSR itself, either to a more optimized version or to a less optimized one from which it was derived.  We implement and evaluate our technique in the LLVM compiler infrastructure, which is nowadays being increasingly used gaining popularity  as Just-In-Time (JIT) compiler in virtual machines for dynamic languages such as Javascript, MATLAB, Python, and Ruby. We As a case study of our approach, we show how to improve the state of the art in the optimization of the \feval\ instruction, a performance-critical construct of the MATLAB language.  %We  also present a case study on the integration of our technique in the McVM virtual machine for MATLAB, showing significant speedups from the run-time optimization of a typical construct of the language.