CACAO � a �� Bit Javavm Just�In�Time Compiler

CACAO � a �� Bit Javavm Just�In�Time Compiler

CACAO A bit JavaVM JustinTime Compiler Andreas Krall and Reinhard Gra Institut fur Computersprachen Technische Universitat Wien Argentinierstrae A Wien httpwwwcomplangtuwienacatandi Abstract for native co de compilation since it is more p ortable and gives more opp ortunities for improving the execu tion sp eed Compiling to native co de can b e done in This article describ es the design and implementation of two dierent ways compilation of the complete pro CACAO a just in time compiler for Java The CACAO gram in advance or compilation on demand of only the system translates Java byte co de on demand into native functions which are executed just in time compiler co de for the ALPHA pro cessor During this transla JIT Our JIT compiler is describ ed in detail in Gra tion pro cess the stack oriented Java byte co de is trans in German and is freely available via the world wide formed into a register oriented intermediate co de Lo web cal variables and stack lo cations are replaced by pseudo registers eliminating the bit restriction on address typ es A fast register allo cation algorithm is applied to Previous Work map the pseudo registers to machine registers During co de generation eld osets are computed for prop er The idea of machine indep endent program represen alignment on bit architectures Even though the tations is quite old and go es back to the year CACAO system has to incur loading and compilation TBS An intermediate language UNCOL UNiver time it executes Java programs up to times faster sal Computer Oriented Language was prop osed for than the JDK interpreter up to times faster than the use in compilers to reduce the development eort of kae JIT compiler It is slightly slower than equivalent compiling many dierent languages to many dierent C programs compiled at the highest optimization level architectures The design of the JavaVM has b een strongly inuenced by P co de the abstract machine used by many Pascal implementations PD P co de Intro duction is well known from its use in the UCSD Pascal system There have even b een eorts to develop micropro ces Javas AG success as a programming language re sors which execute P co de directly sults from its role as an Internet programming lan The Amsterdam compiler kit TvSKS TKLJ guage The basis for this success is the machine inde uses a stack oriented intermediate language This lan p endent distribution format of programs with the Java guage has b een designed for fast compilers which emit virtual machine LY The standard interpretive im ecient co de The intermediate representation of the plementation of the Java virtual machine makes execu Gardens Point compiler pro ject is also based on a stack tion of programs slow This do es not matter if small machine called Dcode Gou Dcode was inuenced applications are executed in a browser but b ecomes by Pascal P co de Both Dcode interpreters and co de intolerable if big applications are executed There are generators for dierent architectures exist two solutions to solve this problem The problems of compiling a stack oriented abstract machine co de to native co de are well known from the sp ecialized JavaVM pro cessors programming language Forth In Ert and his thesis compilation of byte co de to the native co de of a Ert Ertl describ es RAFTS a Forth system that gen standard pro cessor erates native co de at run time Translating the stack op erations to native co de is done by translating the SUN to ok b oth paths and is developing b oth Java op erations back to expressions represented as directed pro cessors and native co de compilers We chose to go acyclic graphs as an intermediate step In EM he translates Forth to native co de using C as an interme only correct programs The following examples show diate language In this system the stack slots are trans some imp ortant JavaVM instructions and how a Java lated to lo cal variables of a function Optimization and program is represented by these instructions co de generation are p erformed by the C compiler x push integer constant with value x iconst iload n load contents of lo cal variable n In his thesis Fra Franz claims that generating istore n store stack top in lo cal variable n native co de on the y at load time is faster than loading iadd sum of two topmost stack elements a much bigger native co de image from a oppy or hard imul pro duct of topmost stack elements disk Franz uses a compressed representation of the abstract syntax tree as an intermediate representation The Java assignment statement a b c is trans Generating native co de is so fast that this idea has b een lated into extended to dynamic run time reoptimization Kis Sp ecializing and optimizing co de at run time is also iload b load contents of variable b p erformed in the Self system US and in some Prolog iload c load contents of variable c systems KB iadd compute b c The rst implementations of JIT compilers b ecame istore a store stack top in variable a available last year for the browsers from Netscap e and Microsoft on PCs They were followed by Syman Figure shows the contents of the stack b efore and tecs development environment Recently SUN released after execution of each instruction Prior to the rst a JIT compiler for the Sparc and PowerPC pro ces instruction and after the last instruction the stack is sors Silicon Graphics develop ed a JIT compiler for empty the MIPS pro cessor A public domain JIT compiler for several architec tures is the kae system develop ed by Tim Wilkinson httpwwwkaffeorg For all the ab ove men tioned systems no publicly available description of the c compilation techniques exists b b c b The translation scheme of the Caeine system is de iload b iload c iadd istore a scrib ed in HGmWH It supp orts b oth a simple translation scheme which emulates the stack architec Figure JavaVM stack op erations ture and a more sophisticated one which eliminates the stack completely and uses registers instead Caeine is not intended as a JIT compiler It compiles a complete The iload b instruction pushes the contents of the program in advance DAISY Dynamically Architected lo cal variable b onto the stack iload c works in a Instruction Set from Yorktown is a VLIW architecture similar way iadd adds the two elements at the top of develop ed at IBM for fast execution of x PowerPC the stack p ops these two values and pushes the sum S and JavaVM co de Compatibility with dierent onto the stack The istore a writes the value at the old architectures is achieved by using a JIT compila topmost stack p osition into the lo cal variable a and tion technique The JIT compilation scheme for the p ops this value JavaVM is describ ed in EAH Accessing the elds of ob jects is handled by the in structions getfield and putfield getfield exp ects an ob ject reference on the stack and has an index into The Java Virtual Machine the constant p o ol as an op erand The index into the constant p o ol must b e a reference to a pair contain The JavaVM is a typ ed stack architecture LY ing the class name and a eld name The typ es of the There are dierent instructions for integer long inte classes referenced by the constant p o ol index and by ger oating p oint and address typ es Byte and charac the ob ject reference must b e compatible a fact which ter typ es have only sp ecial memory access instructions is usually checked statically at load time The ob ject and are treated as integers for arithmetic op erations reference has to b e dierent from the null p ointer a The main instruction set consists of arithmeticlogical fact which must usually b e checked at run time and loadstoreconstant instructions There are sp e Array access is handled by the aload and astore cial instructions for array access and for accessing the instructions Separate versions of these instructions elds of ob jects memory access for metho d invo ca exist for each of the basic typ es byte int float tion function call and typ e checking A JavaVM has ref etc The aload instruction exp ects a reference to check the program for typ e correctness and executes to an array and an index of typ e int on the stack Translation to Register Form The array reference must not b e the null p ointer The index must b e greater than or equal to zero and less The architecture of a RISC pro cessor is completely dif than the array length ferent from the stack architecture of the JavaVM RISC pro cessors have large sets of registers The Alpha has The Java metho d invo cation oprinta is integer registers and oating p oint registers which translated into are b oth bits wide They execute arithmetic and aload o load object pointer o logic op erations only on values which are held in regis iload a load contents of variable a ters Load and store instructions are provided to move iconst push constant data b etween memory and registers Lo cal variables iadd compute a of metho ds usually reside in registers and are saved in invokevirtual print call oprint memory only during a metho d call or if there are to o few registers If JavaVM co de is translated to machine co de the stack is eliminated and temp orary registers replace the stack slots a a a Machine co de translation examples o o o o aload o iload a iconst iadd invoke The example expression a b c d has the JavaVM co de Figure JavaVM metho d invo cation iload b load contents of variable b iload c load contents of variable c Figure shows the contents of the stack for a metho d imul compute b c invo cation Each metho d has its own virtual stack and iload d load contents of variable d an area

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    9 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us