Faculty of Information Technology
Software Engineering Group

The History of STX:LIBJAVA

The STX:LIBJAVA date back to 1996 when Claus Gittinger, author of Smalltalk/X decided to give it a try. Actually, first commit has been done on Monday April 15th, 1996, some 4 (!!!) month after Java 1.0 has been released by Sun. Claus has been working on it till roughly 1999. At that time, it could run a simple Java applet and the VM had a JIT support for Java code as well. At this point, Claus stopped working on it.

After some 10 years after, in September 2010, I (meaning Jan Vrany) and my colleagues - Jan Kurš and Marcel Hlopko decided to continue working on this. It was a next logical step in our research in multi-language virtual machines and programming environments. It was an interesting experiment - everybody runs all sort of dynamic languages on VM designed for rigid, statically typed language, nobody did it the other way round. Also the basic architecture laid out by Claus was, and still is, unique - this is the only system to my knowledge which support 2 different bytecode sets. And there were meny questions open - how to integrate such different languages? We had experience with integrating Ruby into Smalltalk/X, JavaScript was already integrated, but those are dynamic languages similar to Smalltalk. Java's very different beast. Also, this was great opportunity to learn and understand Java. I mean, really understand :-)

We spent first couple months just by trying to undestand current code, trying to understand fundamentals of Java and trying to run famous Hello World! program. At uni we're surrounded by Java experts so we thought understanding how it should work will be easy because we can ask true (and certified) experts with I-don-t-know-how-many-years of experience in Java. Too naive. Very, very few people knows whats going on there. Also, the original code got rotten - it was not maintained nor tested for more than 10 years while the rest of the system evolved. Nevertheless, 12.12.2010 we've managed to run Hello World!.

Since then on, we did a huge refactoring of whole code:

  • Marcel rewrote whole reference resolving from scratch, in a clear, consistent and (mostly :-) correct way
  • Marcel also rewrote java monitor support, thread management and support for classloaders.
  • Jan worked on Smalltalk/Java interop support, implemented first version and rewrote it many times as we were discussing how it should behave, what would programmers expect.
  • Jan enhanced method lookup MOP I've designed and implemented (with Claus support) before as we found out that the MOP is key feature for interop to be performant.
  • I did most of the VM work, spending nights in GDB, fixing the Java interpreter and other parts of the VM here and there.

In September 2011, we've to run Groovy on top of STX:LIBJAVA. In December 2011, we've to run Apache Tomcat. Sounds trivial, but it was a hard work :-)

In spring 2012 we've reimplemented Smalltalk/Java interop support (mainly to give it a fresh, clean design implementation-wise). Also we've added support for exception handling. Turned out to be a tricky issue. Then we're ready to present it at ESUG2012.

At that point, we had more or less functional Java implementation allowing us to use Java code from Smalltalk. However, performance was poor. It will never be as fast as OpenJDK/Oracle JVM's for with resources available we could never catch up, but it was way slower than Smalltalk code. One particular problem was that in Java everything is synchronized using monitors. Our implementation was inefficient, so at Camp Smalltalk in Ghent, we implemented thinlocks, an efficient locking scheme designed at IBM for their Java VM. Worked like a charm and gave us 30% more performance. Still, we need more. Time has come to fix the JIT.

I spent next 6 months by fixing Java JIT and doing various performance optimizations. That was quite interesting. I would never thought that one of the most time-consuming operations would be CHECKCAST/INSTANCEOF (so I've added couple nasty tricks to optimize them - gave me some 30% in certain benchmarks). After those optimizations (and I'm still not done with all of them) for certain benchmarks STX:LIBJAVA is 2-4 slower than OpenJDK 6. Not bad.

So, by early 2013 we've got reasonable performant Java VM. This opens a door to something really interesting - an incremental, interactive Java environment. An environment which would allow you to develop in Java pretty much the same way you do in Smalltalk. Allow to modify the code while it's running.

That's what we're working on right now. And we're quite far, I would say. But we could do much more...

Last modified 4 years ago Last modified on Nov 28, 2013, 2:20:57 AM