[LLVMdev] On-Stack Replacement & Code Patching

Nyx mcheva at cs.mcgill.ca
Wed Mar 10 12:11:53 PST 2010


I am interested in writing a JIT that makes use of on-stack replacement. This
essentially means that the JIT must be able to compile new versions of
already compiled functions (eg: more optimized versions) and ensure that the
code for the new functions is executed. I was wondering if LLVM offers any
support for this.

Suppose a function f calls a function g, and f is recompiled while g is
running, I would need to be able, when returning from g to f, to jump to the
updated code for f. So, one way to implement this would be to insert a jump
after every call in the body of the old function f, that jump to the
corresponding point in the body of the new function. This would require me
to overwrite some of the code of f. If LLVM has no direct support for this,
I could potentially create auxiliary "call handler" functions which can do a
long jump to the proper code on return.

So what I would like to know is:

1. Does LLVM support code patching? By this, I mean overwriting some
instructions
2. Does LLVM support long jumps?
3. Has anyone here implemented code patching or on-stack replacement in
LLVM?

Another potential issue is that if I recompile some function, I would
ideally want to keep the same stack representation for both. This could
potentially be quite tricky. Any advice on how to go about this?
-- 
View this message in context: http://old.nabble.com/On-Stack-Replacement---Code-Patching-tp27855179p27855179.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.




More information about the llvm-dev mailing list