[LLVMdev] Running Objective-C in the JIT

Jules jules at rawmaterialsoftware.com
Mon May 7 08:07:19 PDT 2012


Hello, I've been trying to get some OSX code to execute within the JIT,
and it's been causing me some major headaches!

I'm attempting to JIT-compile some code which uses external OSX obj-C 
classes (Cocoa, etc), and also contains its own embedded obj-C classes.

My first hurdle in doing this was that when the code tried to call Cocoa
classes, the obj-C selectors weren't being recognised by the host 
process's objc_msgSend function.. After quite a bit of hair-pulling, I 
copied a trick from the lldb::IRForTarget class, which scans the compiled
module and replaces any selector constants with explicit function calls 
to sel_registerName().. By applying a similar transformation to my own 
modules, I've now managed to successfully invoke selectors on Cocoa classes.

But now I've hit a brick wall trying to use internal obj-C classes (i.e. 
classes that are defined within the JIT-ed code itself). With these, even
trying to alloc them causes a crash. Does anyone have enough of a grasp of
what's going on in the JIT and obj-C ABI to be able to give me some 
pointers here!?

Thanks!    





More information about the llvm-dev mailing list