Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Introduction to JVM Based on material produced by Bill Venners.

Similar presentations


Presentation on theme: "1 Introduction to JVM Based on material produced by Bill Venners."— Presentation transcript:

1 1 Introduction to JVM Based on material produced by Bill Venners

2 2 The Java programming environment

3 3 The Java platform byte code generated by the Java front-end is an intermediate representation (IR) –clean and compact –platform-independent

4 4 The role of the virtual machime Local or Remote

5 5 Java compilation model

6 6 Java bytecode format void spin () { int i; for (i = 0; i < 100; i++) {;} } 0 iconst_0 // push int constant 0 1 istore_1 // store into var 1 "i=0" 2 goto 8 // first time: don't incr 5 iinc 1 1 // incr var 1 by 1 "i++" 8 iload_1 // push local var 1 "i" 9 bipush 100 // push byte const "100" 11 if_icmplt 5 // loop if less "i < 100" 14 return // return void when done branch instructions use relative displacement, i.e., add/subtract from PC => easy combination disassembled code uses absolute pseudo-labels

7 7 Java bytecode basics no run-time tag checking (but objects have metadata) "untyped" local variables, reused for different types type tags are carried along the instructions the verification phase of class loading ensures validity: types are OK, no operand stack overflow.. bytecode categories –arithmetic: add, sub, mul, rem, div (typed versions) –operand stack management: load/store, dup, swap –control transfer: goto, if_icmpeq, ifeq,.. –type conversions: i2l, i2f, l2f, f2i, d2i, int2byte, etc. –method invocation and return: invokevirtual, invokestatic, ireturn, lreturn, return, etc. –throwing exceptions, monitors, etc..

8 8 Back-end transformation and execution (1) simple JVM –byte code interpretation, including resolution of symbolic references: finding the entity identified by a text symbol and replacing it with a direct reference (2) JIT (Just-In-Time) compiler –method byte codes are compiled into native machine code the first time they are invoked –the machine code is cached for subsequent invocation –compilation overhead & requires more memory (3) adaptive optimization: the interpreter monitors the program, compiling only heavily used parts..

9 9 The Java Virtual Machine

10 10 Shared data areas each JVM has one of each: –method area: byte code and class (static) data storage –heap: object storage

11 11 Example representation of objects in heap: -or can use handle ptrs pointing to an inderect handle pool the heap is garbage collected each JVM has its own heap - supports isolation

12 12 Frame in Execution Thread data areas every thread has its own stack of call frames in a frame, a fixed-sized stack for expr evaluation


Download ppt "1 Introduction to JVM Based on material produced by Bill Venners."

Similar presentations


Ads by Google