Virtual Machines (December 3, 2009) assignment 6 is on the web apologies for the buggy sets.cc ** course evaluations on paper in class next Tuesday; please encourage classmates to attend ** -------- Library is preexisting code you can call. Run-time system is library that makes assumptions about how the compiler works may use tables generated by the compiler may examine or manipulate heap or stack layout e.g., GC requires help finding root pointers and type descriptors; needs compiler to generate write barriers Virtual machine is run-time system that provides/specifies everything the program needs, including instruction set -------- Java Virtual Machine (JVM) recall how Java works compiler translates Java source to Java byte code (JBC) byte code runs on virtual machine virtual machine may be implemented via interpretation, JIT compilation, or some combination of the two machine architecture has all & only Java's built-in types types safety definite assignment garbage collection threads global _constant pool_, per-thread stacks, heap, method (code) area [each stack frame contains array of locals & formals expression evaluation stack (sized to accommodate largest expression in the method)] implicit references to the current program counter, frame, top of operand stack within frame, symbol table info in constant pool defines format of .class files at start-up, JVM loads given class file (which must have a main()) verifies that it satisfies various invariants type safety no operand stack overflow or underflow definite assignment allocates and initializes static data links to library classes calls main in a single thread JBC load-store back and forth between local variable array and operand stack arithmetic all done implicitly on the operand stack type conversion object mgmt new, field and array element access, reflection push, pop, dup, swap branches, switch specify targets as indices in instruction array of current method static and virtual method calls specify target symbolically by name (index in constant pool) throw exception monitor enter, exit (wait, notify, notifyAll are method calls) << see list insertion example in the text >>