Lecture 1 - Logistics of the Course - Syllabus - Learning objectives - Assessments - Textbook - Late Work - Collaboration What is a Virtual Machine? Four broad types of virtual machines 1. Hypervisor: allows (multiple) guest operating systems to run on a single machine - examples: VMWare, Xen, VirtualBox, Parallels - "cloud computing" - type 1 and type 2 hypervisors: bare metal and hosted on an existing OS 2. Emulator: emulates the behavior of an existing hardware architecture in software - examples: qemu - NES emulator 3. Bytecode Virtual Machine: executes a "made up" software-defined instruction set (or IR) - examples: JVM, CLR, p-code, o-code 4. Language Virtual Machine: executes a source code (often scripting) language - Python, Lua, R, JavaScript, bash - why a virtual machine is good (3/4) - less work for language designers, can evolve independently - portability over different hardware - split language frontends into separate process - new implementation techniques and optimizations for language features - differences between 3 and 4 - 4 langvm must have parser, support full language - langvm means the source language is a compilation target, e.g. javascript How Virtual Machines relate to compilers - diagram of front, middle, back end of compiler - but virtual machines can also *interpret* code - virtual machines have a lot more services - garbage collection - debugger / profiler - exception handling - libraries that support the language - virtual machine is even more complicated than a compiler, has compilers inside key terms: meta - the "representation of" or data about, something metadata - data about, or describing other data metaobject - the object which describes an object, e.g. a class object describes an instance intermediate representation - internal data structures representing code or data - any representation of code between source and machine code compile time - when translating source code to an intermediate or machine code form load time - when loading and linking code from disk into a running program run time - during execution of a program static - determinable without running the program dynamic - determinable or happening while running the program emulator / simulator - a software program that simulates the execution of an existing hardware architecture virtualization - managing resources in a way that makes them transparent to multiple users, e.g. multiplexing - implementing the semantics of a machine, bytecode, or source language on top of another machine "full" virtualization - complete implementation of semantics semantics - the complete rules for the behavior of a program or machine statically-typed - types exist in source code and apply to storage locations dynamically-typed - types exist at runtime and are attached to values guest language/CPU/ISA/VM - the language running "on top" of, or implemented by a VM host CPU/machine - the lowest level execution on which a VM is running implementation language - the language in which a virtual machine is written interpreter - executes the representation program without generating new host code compiler - translates a program from one representation to another JIT compiler - translates a program during runtime Components of a Virtual Machine - Code format - Code loader - could be text parser, or binary loader - Code verifier - Intermediate representation (IR) - Object model - Memory management - Garbage collector - Interpreter - JIT Compiler - Debugger - Profiler - Libraries