[LLVMdev] Redefining function
Dr.Graef at t-online.de
Sat Jan 30 15:38:43 PST 2010
Conrado Miranda wrote:
> To implement something that is common in Lisp. Suppose I have a program
> that is running and can't be stopped or the cost being stoped is
> prohibitive. If I find a better way to run an algorithm, I'd like to
> update the running program non-stopping.
The way I do this in Pure is to always call global functions in an
indirect fashion, using an internal global variable which holds the
current function pointer. When a function definition gets updated, the
Pure interpreter just jits the new function, changes the global variable
accordingly, and frees the old code.
Compared to Duncan's suggestion, this has the advantage that you only
have to recompile the function which was changed. AFAICT, if you use
replaceAllUsesWith, then the changes ripple through so that you might
end up re-jiting most of your program.
Dr. Albert Gr"af
Dept. of Music-Informatics, University of Mainz, Germany
Email: Dr.Graef at t-online.de, ag at muwiinfa.geschichte.uni-mainz.de
More information about the llvm-dev