240 likes | 421 Views
Just-In-Time Compilation Keith W. Krajewski 3/4/2011 paper: A Brief History of Just-In-Time (2003) John Aycock. Overview. What is JIT? Why know about JIT? Who has used JIT (and to what end)? Simulation JIT in modern languages Classifying JIT techniques Tools for JIT compilation.
E N D
Just-In-Time Compilation Keith W. Krajewski 3/4/2011 paper: A Brief History of Just-In-Time (2003) John Aycock
Overview • What is JIT? • Why know about JIT? • Who has used JIT (and to what end)? • Simulation • JIT in modern languages • Classifying JIT techniques • Tools for JIT compilation
What is JIT? • Dynamic compilation • “JIT” itself a new term to computing, ~1993 • Theoretically unnecessary
Goals of JIT • Compiled programs are faster • Interpreted programs are smaller • Interpreted programs are more portable • Interpreter has access to runtime info
Because JIT is like the cure for scurvy. Why know about JIT?
Oberon Erlang O'caml Modern stuff Who has used JIT (and how)? • Early sightings • LC^2 • APL • mixed/throw-away code • Fortran • Smalltalk • Self
Ancient Runes • McCarthy, Lisp (1960), punch cards! • Univ. of Michigan IBM 7060 (1966) • Thompson, regular expressions (1968)
LC^2 • Language for conversational computing • Mitchell, Perlis, & van Zoeren (1968) • Mostly forgettable • Cached the actions it performed
APL • Phillip S. Abrams, 1970 • Drag-along • Beating
Mixed & Throw-Away Code • Mixed – Dakin & Poole (1973) & Dawson (1973) • Throw-away – Basic
Fortran • Hansen's 1974 optimization • Frequency-of-execution counter • Threshold levels • Ordered set of machine-specific optimizations
Smalltalk • Lazy compilation to native code • No pagination of compiled code
Self • David Ungar, Randall Smith, 1987 • Pure OO, dynamically typed • 3 generations • Customization (Pitfall: over-customization) • Optimized type info for loops (Pitfall: compilation time) • Illusion of speed • Influenced Sun's later works (Java)
Oberon • Niklaus Wirth, 1986 • Compiled to “slim binary” • Supported dynamic loading of modules • Continuous re-optimization in background
Erlang • Ericsson, 1986 • HiPe – explicit invocation • Mixed code, switch upon method invocation or exception
O'caml • Specialized the interpreter's instruction set to include “macro opcodes” • … without much benefit
Simulation • 1st gen – straight 1 by 1 translation • 2nd gen – 1 by 1 translation with cache • 3rd gen – blocks of source • 4th gen • Profiled execution • Hot path detection • Code generation • Bailout
HP Dynamo • Compiled HPA-8000 code into HPA-8000 code • ...amazingly, this worked. 30% performance increase • Important to be able to bail out
Java • Static explicit compilation to JVM bytecode • Early JVM did straight interpretation • Motivation for JIT research • Now very portable and relatively quick
C#/.Net • Static compilation to CIL (MSIL), then bytecode • Dynamic per-method compilation to native machine
Classifying JIT • 3 properties • Invocation – explicit/implicit • Executability – monoexecutable/polyexecutable • Concurrency
Toolkits for JIT compilation • Keppel (1991), Engler & Proebsting (1994), Ramsey & Fernandez (1995), Engler (1996), Fraser & Proebsting (1999) • Address three main problems • Binary code generation • Cache coherence • Execution
Summary • Dynamic compilation • Combines best features of both compiled and interpreted programs • Lazy compilation, incremental optimization, mixed code, throw-away code, hotspot detection, machine-specific optimization, customization, simulation • Don't re-invent the wheel again
Works cited • Aycock, John. A Brief History Of Just-In-Time. 2003. • Petzold, Charles. .NET Book Zero. 2006. http://www.charlespetzold.com/dotnet/DotNetBookZero11.pdf • Wikipedia: Just-In-Time Compilation. http://en.wikipedia.org/wiki/JIT_compilation