In this chapter, some introduction materials are presented to help readers understand the essential concepts behind and the terms in the title of our research. First, we give an over-view of the current status of the Java technology in embedded environment. Second, we explain the meaning of mixed-mode, which actually combines interpretation and just-in-time (JIT) compilation, and the reason it suits for embedded JVM. Third, we discuss dual instruction set, an issue that is specifically relevant to embedded processors. After the intro-duction comes our research motivation and objectives. Finally, organization of this thesis is provided.
1.1 Embedded Java Environment
Developed by Sun in 1991, Java technology has evolved rapidly and becomes popular in all application fields, such as desktop PCs, powerful large-scale server, or even in small portable consumer devices. Recognizing the fact that different application fields possess different characteristics and demands, Sun in 1999 has grouped Java technologies into the Java 2 platform [1], which consists of three editions as in Figure 1-1, and each of which aims at a specific area:
• Java 2 Enterprise Edition (J2EE) - targeted at scalable, transactional, and database-centered enterprise applications with an emphasis on server-side development.
• Java 2 Standard Edition (J2SE) - targeted at conventional desktop applications.
• Java 2 Micro Edition (J2ME) - targeted at embedded and consumer devices, such as wireless handhelds, PDAs, TV set-top boxes, and other devices that lack the resources to support full J2SE implementation.
Figure 1-1. Java 2 Platform (extracted from Sun)
To address the diversity of large embedded world, which covers a wide range of devices, J2ME specifies two configurations: Connected Limited Device Configuration (CLDC) and Connected Device Configuration (CDC). Each configuration targets at differ-ent types of devices and therefore provides differdiffer-ent class libraries and APIs. Table 1-1 gives an overview of the differences of the two configurations.
Table 1-1. J2ME Configurations
Configurations Name
Connected Device Configuration (CDC)
Connected Limited Device Configuration (CLDC) Target Devices high-end PDAs, set-top
boxes, screen phones, and etc.
cell phones, two-way pagers, low-end PDAs, and etc.
Typical Memory Requirement
2MB~16MB 128KB ~ 512KB
Target Processor Type 32-bit 16-bit, 32-bit
Reference Virtual Machine CVM KVM
Other Features high bandwidth network connection, most often based on TCP/IP
limited, low bandwidth network connection
1.2 Embedded Mixed-Mode Execution JVM
Although the JVM can be easily realized by an interpreter, its slow performance is always a concern in performance-aware system. In order to overcome this problem, some compilation technologies must be applied. Ahead-of-time (AOT) compilers [2] allows off-line compilation, so no run-time compilation overhead is needed. Conventional JIT com-pilers translate bytecode into machine code on the fly, and incorporate more optimization techniques for better performance with the expense of VM code size increase and run-time compilation overhead. However, memory-constrained JVM can tolerate neither the static compiled code size expansion imposed by AOT compilers nor the code size/compilation overhead imposed by conventional JIT compilers.
The approach of mixed-mode execution in [3][4] relies an interpreter to execute inter-preted code for some parts of the program, and also executes compiled code dynamically produced by a JIT compiler for the remaining parts. The line between a conventional JIT compiler and a JIT compiler that supports mixed-mode execution is, in actuality, indistinct.
Nevertheless, the principles of mixed-mode execution can be clarified as follows.
• Performance-critical parts of the program are compiled by a JIT compiler, and then natively executed.
• Non-performance-critical parts of the program are interpreted by a interpreter.
• Close interactions between the JIT compiler and the interpreter is necessary.
As discussed in Section 1.1, embedded JVM (including its class libraries) has very lim-ited memory budget, usually in the range of hundreds of kilobytes. For this reason, embed-ded JVM usually employs merely an interpreter as its execution engine. But with the increasing demands for speed performance, embedded JVM also seeks ways to improve its slow execution speed. The most effective way is to incorporate a JIT compiler, as most desktop/server JVMs do. Still, taken limited memory resources into consideration, a full-fledged JIT compiler does not suit for an embedded JVM. Therefore, a lightweight JIT compiler, which is highly-customized for an embedded JVM, is needed. To this end, a mixed-mode JVM seems to be promising in embedded environment. By tightly coupling
with an interpreter, a JIT compiler can reuse the interpreter-based JVM as its infrastructure, in order to keep itself compact. And overall the combination (an interpreter-based JVM and a JIT compiler) builds up an embedded mixed-mode JVM.
1.3 Dual Instruction Set For Code Size Reduction
Due to the requirements of low manufacturing cost, low power consumption, and small volume size, embedded systems usually have limited hardware resources, especially in memory size. 8-bit, 16-bit MCU processors have dominated the embedded system for a long time. However, with the increasing demands on more data applications in high-per-formance embedded system, 32-bit embedded processors have become mainstream these days.
Most 32-bit embedded processors are RISC-based, which suffer from the problem of poor code density and thus require more memory space. This is a severe limitation for cost-sensitive embedded systems. An innovative solution in architectural level is to employ
“dual instruction set” [5]. One, the full instruction set, contains original 32-bit instruction set; the other, the compressed instruction set or the reduced bit-width instruction set, encodes most commonly used instructions in fewer bits (usually 16 bits).
According to previous researches, a program compiled in compressed instruction set will be much smaller than that in full instruction set. For example, the code size reduction of Thumb/ARM is 30% [6], while the case of MIPS16/MIPS32 is 30%~40% [7]. However, due to a limited set of instructions and access to a limited set of registers, a program will be compiled into more instructions in the compressed instruction set, which may result in overall performance degradation. Therefore, how to effectively facilitate dual instruction set to keep a balance between code size and performance, is both a practical industrial prob-lem and a hot research topic.
1.4 Research Motivation and Objectives
Our observations are that while an embedded JVM manages to improve its execution speed, it still faces the problem of limited memory resources. Motivated by this fact, our objective is to design and implement an embedded JVM, which is small footprint compared to other existing embedded JVMs. We employ mixed-mode execution in our embedded JVM and further facilitate the “dual instruction set” feature that hardware architectural pro-vides, aiming at striking a balance between speed performance and memory usage.
In addition, some practical decisions of our research are listed as follows.
• Our focus is on the design and implementation of a baseline JIT compiler for an embed-ded mixed-mode JVM, based on Sun’s CLDC KVM 1.0.4 (interpreter-based). For ease of reference, the JIT compiler is hereafter termed KJITC, an abbreviation for “Kilobyte Just-In time Compiler”.
• KJITC targets the ARM/Thumb dual instruction set processor.
1.5 Organization of This Thesis
The remaining parts of this thesis is organized as follows. Chapter 2 provides more detailed background knowledge on JVM internals and common JIT compiler optimizations. In Chapter 3, the design of KJITC is presented along with speed performance analysis and the design of ARM/Thumb instruction setction. In Chapter 4, experiemnt results are exhibited. In the end we make a brief summary in Chapter 5.