Building OpenJDK Multi-Language VM aka The Da Vinci Machine
Sunday, February 3, 2008
Life is more exciting with multi-language support on JVM. Recently john rose @ sun, created patch for loading anonymous classes in the VM ( read carefully, we are not talking about anonymous classes in JDK, we are talking about loading anonymous classes at VM level ). JVM wouldn't not allow someone to change structure of a class once it loaded. Though this security feature brings-in stability to JVM, dynamic language implementors for JVM are forced to write lots of boiler plate code to simulate dynamism on top of JVM (Ex: In Ruby, methods can be added, removed, modified at runtime, even class structure can be changed @ runtime too). The recent patch added by john for OpenJDK allows us to load an arbitrary class from a block of bytecodes and associate the new class with a pre-existing host class, inheriting its access, linkage, and permission characteristics. Very interesting thing is, a block of bytecodes can be template class file and this template class can be customized at runtime using various constant pool patching methods in java.dyn.AnonymousClassLoader, just before loaded by AnonymousClassLoader class loader. This patch not only alienate pain of other language implementers to a greater extent but accentuate complete JDK and Hotspot with new way of loading and linking anonymous classes in JVM, thereby opening up developers mind in yet another innovative direction. Read john's blog on anonymous classes in the vm for more details on this feature. Pretty exciting ha?, Wanna try it out yourself?. Here is the step by step instruction for applying multi-language path to Open JDK Hotspot VM and building mlvm aka The Davinci VM.
If you haven't successfully built Open JDK and Hotspot VM, go through simonis blog on building Open JDK and hotspot on linux. Once you successfully built OpenJDK and Hotspot, follow
below instructions for building and running mlvm,
- Download mlvm paths and related files
http://homepage.mac.com/rose00/work/webrev/6653858/anonk.patch
http://homepage.mac.com/rose00/work/webrev/6653858/DVMTest.zip
- Applying patchs
Build OpenJDK Hotspot VM
ALT_BOOTDIR=/share/software/jdk1.6.0_04/ \ HOTSPOT_BUILD_JOBS=1 \ ALT_OUTPUTDIR=../../build/hotspot_debug \ make jvmg 2>&1 | tee ../../build/hotspot_debug.log
Give necessary permissions to libjvm.so under linux,
set PATH and JAVA_HOME
Running sample mlvm program