150 likes | 236 Views
Optimizing Compilers CISC 673 Spring 2009 Dynamic Compilation I. John Cavazos University of Delaware. Quiz Time. What’s a managed language ?. Quiz Time. What’s a managed language ? Java or C# Runs under management of a VM Object Oriented, Garbage collected Dynamic compilation.
E N D
Optimizing CompilersCISC 673Spring 2009Dynamic Compilation I John Cavazos University of Delaware
Quiz Time What’s a managed language?
Quiz Time What’s a managed language? Java or C# • Runs under management of a VM • Object Oriented, Garbage collected • Dynamic compilation
Quiz Time True or False? • Because they execute at runtime, dynamiccompilers must be blazingly fast? • Dynamic class loading is a fundamental roadblock to cross-method optimization? • A static compiler will always produce better code than a dynamic compiler? • Sophisticated profiling is too expensive to perform online?
What is a VM? A software execution engine that provides a machine-independent language implementation
What’s in a VM for a Managed Language? • Program loader • Program “checkers”, e.g., bytecode verifiers, security services • Dynamic compilation system • Memory management • Thread scheduler • Profiling & monitoring • Libraries
Basic VM Structure Program/Bytecode Executing Program Class Loader, Verifier, etc. Heap Thread Scheduler Dynamic Compilation Subsystem Garbage Collector
Adaptive Optimization Hall of Fame • 1958-1962: LISP • 1974: Adaptive Fortran • 1980-1984: ParcPlace Smalltalk • 1986-1994: Self • 1995-present: Java
Quick History of VMs • Adaptive Fortran [Hansen’74] • First in-depth exploration of adaptive optimization • Selective optimization, models, multiple optimization levels, online profiling and control systems • LISP Interpreters [McCarthy’78] • First widely used VM • Pioneered VM services • memory management, • Eval -> dynamic loading
Quick History of VMs • ParcPlace Smalltalk[Deutsch&Schiffman’84] • First modern VM • Introduced full-fledge JIT compiler • Demonstrated software-only VMs were viable • Self [Chambers&Ungar’91, Hölzle&Ungar’94] • Developed many advanced VM techniques • Introduced polymorphic inline caches, on-stack replacement, dynamic de-optimization, advanced selective optimization, type prediction and splitting, profile-directed inlining integrated with adaptive recompilation
Quick History of VMs • Java/JVM [Gosling, Joy, Steele ‘96] • First VM with mainstream market penetration • Java vendors embraced and improved Smalltalk and Self technology • Encouraged VM adoption by others → CLR
Promise of Dynamic Optimization • Compilation tailored to current execution context performs better than ahead-of-time compiler
Promise of Dynamic Optimization • Common wisdom: C will always be better • Proof? • Not much • One interesting comparison: VM performace • HotSpot, J9, Apache DRLVM written in C • Jikes RVM, Java-in-Java • 1999: they performed with in 10% • 2007: Jikes RVM ~20% slower than HotSpot & J9, Jikes RVM ~60-0% faster Apache DRLVM • Aside: GCC code 20-10% slower than product compilers