[LLVMdev] Follow-up on: Dynamic updates of current executed code

Chris Lattner sabre at nondot.org
Tue May 11 10:06:05 PDT 2004


On Tue, 11 May 2004, Anders Alexandersson wrote:


> The questionmark is at this pseudocode row:
> %myNewFunction = %getPointerToGlobal(%dynamically_compiled_function_code)
>
> Is there an llvm version of the getPointerToGlobal() function as
> outlined, and can the %myNewFunction pointer be used as described?
> Also, does the getPointerToGlobal() take human readable code (.ll) or
> only binary byte code (.bc)? Is there a specification of how to write
> binary byte code directly, so we do not have to externally call the
> llvm-as utility?

getPointerToGlobal can not take either of those (a .bc or .ll file).  It
must take an LLVM "Function*" to tell it what to compile.

I think the way you really want to approach this is to write your ruby
compiler in C++, and have a public function that you expose
"compileThisStringOfRubyCodeToAFunctionAndReturnAPointerToIt(const
char*)".

Your compiler would lex and parse the ruby code in the string, translate
it to LLVM (to a Function *) and then ask the JIT to compile it for you,
returning a pointer to the function.

-Chris

-- 
http://llvm.cs.uiuc.edu/
http://www.nondot.org/~sabre/Projects/




More information about the llvm-dev mailing list