1 / 12

Introduction to JVM

Introduction to JVM. Based on material produced by Bill Venners. The Java programming environment. The Java platform. byte code generated by the Java front-end is an intermediate representation (IR) clean and compact platform-independent. The role of the virtual machime. Local or

dessa
Download Presentation

Introduction to JVM

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. The Java programming environment

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

  4. The role of the virtual machime Local or Remote

  5. Java compilation model

  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 incr5 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. 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 <offset>, 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. 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. The Java Virtual Machine

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

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

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

More Related