[LLVMdev] llvm-java state

Alkis Evlogimenos alkis at evlogimenos.com
Thu Mar 2 15:07:36 PST 2006

On 3/2/06, Kyle Wilkinson <kdwilkin at uiuc.edu> wrote:
> Hi,
> This question is mostly addressed at Alkis, as I understand that he
> last worked on llvm-java and I saw him reply to another thread
> recently :-)
> When I try and run class2llvm I get a bus error because function_ in
> VMMethod points to 0x8.

This can't be good :-)

> I think the problem lies in how I am using class2llvm.  When I read
> through the Debug output, I see that class2llvm is trying to compile
> all of the files distributed in the gnuclasspath, ~2500 classes. I
> can't imagine a Hello World program needing all of those classes.

Well this is about right. And this stil ignores a lot of packages.
With static compilation you need to compile the transitive closure of
of all classes referenced in the program. A 'simple' Hello Worls is
not that simple: it needs String, System, a bunch of the IO library,
which in their own pull in stuff like Locale's, regular expressions, a
bunch of java.util and so on. Note that you don't really need all of
these for hello world but you can't really know for sure which method
is called or not on each object.

My suggestion to solve this is to integrate class2llvm with the jit
and compile a method at a time as they are called. This will shorted
compilation by a lot as you will only get to compile functions that
are actually called not all the functions that can potentially be
called. My suggestion would be to first do that before you try to
implement more features for the java front end.

> Here is how I am using class2llvm currently:
> // In test/Regression/ClassFile
> jikes -cp /usr/local/share/classpath Hello.java
> class2llvm -cp /usr/local/share/classpath:. Hello

This looks right to me. But if Hello.java contains a call to
System.out.println() this will not work, because I/O doesn't work yet.
Read on.

> Am I doing something wrong or using the tool improperly?  I thought I
> would make sure I'm not doing something really stupid before I try
> and debug this error.
> Do you happen to remember the state of the source code before you
> left? After I get past this hurdle, I am planning on implementing
> synchronization and Prof. Adve thought that synchronization and
> exceptions were about the only things missing, but any advice or
> thoughts on that would be welcome.

Before I left I was at the point where I got most of the Java->Native
part of JNI working and made a lot of progress in the Native->Java
interface. This was an effort to get I/O working (finally) because I/O
actually uses native libraries for its implementation. Once you get to
the point where native code can call Java code without bugs you should
in theory be done and ready to run your Hello World using

If you take a look at the tests in the llvm-java directory, you can
see that I/O is done through a native library (as I said Java->Native
JNI works).

Also take a look at the way tests are compiled. Since the compiler
can't compile everything there are a lot of packages that are excluded
from compilation. This leaves a lot of referenced functions (through
vtables) undefined. There is a pass that runs in the final llvm code
which adds stubs for all these functions so that code generation can
actually create a native executable.

I hope this helps a bit :-)



More information about the llvm-dev mailing list