14/07/2011

FijiVM - A Real-time Java VM Overview

FijiVM is a real-time Java implementation which runs on RTEMS (a real-time OS for embedded devices) and a number of POSIX-compliant operating systems. It has the following components:
  • AOT Java2C Compiler: An ahead-of-time compiler written in Ruby and Java. This compiler takes in Java byte code and produces machine independent C. The Java component performs the code generation whilst the Ruby component acts as a harness for the Java component — providing configuration, marshalling input files, directing output to the appropriate location and finally invoking the C compiler on the generated code.
  • Fiji Runtime: A Java run-time written in C and Java. The runtime includes a real-time garbage collector as described in Section 2.5.2. The C code is invoked by the Java code by calling methods marked with Java’s native keyword.
  • FijiCore lib: A Java class library called FijiCore written in C and Java. Similarly to the run-time, C and Java code is bridged by the native keyword.
  • Real-time Garbage Collector - a set of GC algorithms offering both performance and real-time guarantees.
  • SCJ and RTSJ libraries (RTSJ is supported only partially) - SCJ and RTSJ libraries are distributed with FijiVM to offer alternatives to regular Java and Java+RTGC.
Let's look at some of these components in detail.

Garbage Collector

The key part of the FijiVM is a set of garbage collector algorithms that offer various performance characteristics and real-time guarantees. You can find more information about FijiVM's GC in Schism: Fragmentation-Tolerant Real-Time Garbage Collection. PLDI'10.

FijiVM Compilation Process


Since the FijiVM is based on an AOT compiler that translates the application from its Java byte-code to native C code, the compilation process is different from what we are used to in regular Java VMs. It is best illustrated on the following picture:




AOT Java2C Compiler

The Java2C compiler not only translates byte-code to C code but it performs number of tasks. There is several level of transformation, each introducing various code optimization techniques known from standard compilers. The byte-code is translated into Fiji's specific intermediate representation (IR) where the code is optimized further again. Until the final transformation generating the C-code, several phases of transformation+optimization is performed, each closer to the final product which is the generated C code. Again, illustrated on the following picture:



Fiji Libraries

FijiCore contains a subset of the standard Java class library, including generic collections and events from java.util, I/O and character set support from java.nio and java.io, arbitrary-sized arithmetic from java.math and all of java.lang, including annotations and reflections.

Instead of FijiCore, developers may also elect to use GNU Classpath (an open source implementation of the standard Java library). A second Fiji-specific class library called HardRTJ is currently in development. HardRTJ is intended to provide a library option with a smaller memory footprint than FijiCore, and a yet smaller feature set (note that to use any alternate library the library must be supported on the target platform).

SCJ and RTSJ support

Apart from the FijiVM libraries that replace a standard Java library known from a regular JavaVM distributions, FijiVM offers a support for extending libraries focused on real-time and safety-critical systems. The FijiVM comes with a distribution of oSCJ - an open-source Safety-critical Java implementation based on the JSR-302. Further, FijiVM offers a basic RTSJ (the JSR-1 implementation) support.


Resources
In the next post, I plan to show you how to use FijiVM to compile basic Java programs and how to use the VM in practice.

2 comments:

  1. this is very cool to find out about. i want a "real" programming language (yes, i hold my nose when i say that about java ;-) with a realtime-of-some-kind gc. very exciting. i sure do hope it keeps on ticking!

    ReplyDelete
  2. Hii Sir,

    Your Provided Java projects helped me to get good score in engineering. thank you for providing java projects with source code.

    ReplyDelete