[LLVMdev] Newbie questions

Vikram Adve vadve at cs.uiuc.edu
Mon Apr 24 09:46:00 PDT 2006

On Apr 23, 2006, at 9:32 PM, Archie Cobbs wrote:

> Chris Lattner wrote:
>>> I think the point of llvm-java was to avoid a JVM. That is, it  
>>> converts
>> llvm-java is the JVM.
>>> either Java source or Java bytecode into equivalent LLVM bytecode. I
>> llvm-java only supports input from Java bytecode.
>>> think the big thing lacking so far are the Java library and  
>>> support for
>> llvm-java uses classpath for it's library.
>>> things that LLVM doesn't natively support (threading,  
>>> synchronization
>>> come to mind).  If you need more detail, Alkis (author of llvm- 
>>> java) is
>>> going to have to respond. Otherwise, you'll need to take a look  
>>> at the
>>> code.
>> It's actually missing quite a bit.  It is missing too much to  
>> support programs that use System.Out, for example.  Alkis is  
>> definitely the person to talk to if you're interested in it.
> Thanks.. I'm actually more interested in what would be involved to
> hook up LLVM to an existing JVM. In particular JCVM (http:// 
> jcvm.sf.net).
> JCVM analyzes bytecode using Soot, emits C code, compiles that with  
> GCC,
> and then loads executable code from the resulting ELF files.. given  
> this
> design, using LLVM/modules instead of Soot/GCC/ELF would not be  
> very much
> different, but would allow more cool things to happen.

If you're only interested in using LLVM for "cool things" (such as  
optimization), you could use it directly on the C code you emit.

Either way, one issue that you will have to deal with is preserving  
the behavior of Java exceptions (assuming you care about that).  LLVM  
does not preserve the order of potentially excepting instructions  
(e.g., a divide or a load).  This would have to be handled  
explicitly, whether you use llvm-java or simply used LLVM on the C  
code from Soot.  I don't know if/how libgcj handles this but Tom may  
be able to say more about that.

> The main barrier to this idea for me are (besides the usual:  
> limited time
> for fun projects) is understanding how it could work. In  
> particular, how
> would one bridge the C vs. C++ gap. JCVM is written in C, and I  
> have lots
> of C and Java experience, but zero with C++. Dumb question: can a C  
> program
> link with and invoke C++ libraries? Or perhaps a little C++ starter  
> program
> is all that is needed, then the existing code can be used via  
> extern "C"?
> Alternately, if there were Java JNI wrappers, I could invoke  
> those... Etc.
> -Archie


More information about the llvm-dev mailing list