Check out the new USENIX Web site. next up previous
Next: Conclusions Up: Embedded Programming with C++ Previous: Link-time Efficiency

Java, Anyone?

We have considered, and are still considering, the use of Java in embedded programming. There is an important problem with it, however, that reduces its usefulness, and that is the lack of an ``asm'' statement, and other inlining.

It turns out, when dealing with physical hardware, that there is always some little bit of assembly code that needs to be written. The obvious first thought is to put the assembly code is a library somewhere and call it when needed. But that is not necessarily the right answer. Consider the following familiar example for an Intel i960 microprocessor:

inline int  isr_hot_flag()
{
      register unsigned tmp;
      asm("modpc 0, 0, %0" : "=r" (tmp));
      return tmp & 0x2000;
}

This function basically reduces to the single instruction, the ``modpc'' instruction. Put that in a library and you get around it two branches and some register file shuffling, maybe even a few memory accesses. Wrap it up in a java class somewhere, and you also get the overhead of leaving and entering java.

A just-in-time compiler for java byte code would address many performance issues by generating unrolled directly executable machine code as the program runs. A syntax would be needed to specify specific assembly instructions for inclusion in the stream, or the compiler will not be able to match the optimization performance of C++.



Stephen Williams
Sun May 4 15:28:26 PDT 1997