|
1. Java implementation
Java (see Bibliography for JavaSpec) has
become popular because it is a decent programming language, is
buzzword-compliant (object-oriented and web-enabled), and because it
is implemented by compiling to portable bytecodes (see Bibliography
for JavaVMSpec). The traditional Java
implementation model is to compile Java source code into
.class files containing machine-independent byte-code
instructions. These .class files are downloaded and
interpreted by a browser or some other Java "Virtual
Machine" (VM). See Figure 1 for a
model of the traditional Java implementation.

Figure 1: Typical Java implementation
However, interpreting bytecodes makes Java program many times
slower than comparable C or C++ programs. One approach to improving
this situation is "Just-In-Time" (JIT) compilers. These
dynamically translate bytecodes to machine code just before a method
is first executed.
This can provide substantial speed-up, but it is still slower than
C or C++. There are three main drawbacks with the JIT approach
compared to conventional compilers:
- The compilation is done every time the application is executed, which means start-up times are much worse than pre-compiled code.
- Since the JIT compiler has to run fast (it is run every time the application is run), it cannot do any non-trivial optimization. Only simple register allocation and peep-optimizations are practical. (Some have suggested that JIT could potentially produce faster code than a stand-alone compiler, since it can dynamically adjust to specific inputs and hardware. But the need for quick re-compilation will make it very difficult to make JIT faster in practice.)
- The JIT compiler must remain in (virtual) memory while the application is executing. This memory may be quite costly in an embedded application.
While JIT compilers have an important place in a Java system, for
frequently used applications it is better to use a more traditional
"ahead-of-time" or batch compiler. While many think of Java
as primarily an internet/web language, others are interested in using
Java as an alternative to traditional languages such as C++, provided
performance is acceptable. For embedded applications, it makes much
more sense to pre-compile the Java program, especially if the program
is to be in ROM.
Red Hat is building a Java programming environment that is based on
a conventional compiler, linker, and debugger, using Java-enhanced
versions of the existing GNU programming tools. These have been ported
to just about every chip in use (including many chips only used in
embedded systems), and so we will have a uniquely portable Java
system. See Figure 2 for a model of the
compilation process.

Figure 2: Compiled Java
|