10.07.2015 Views

An ARM Backend for PyPyls Tracing JIT - STUPS Group

An ARM Backend for PyPyls Tracing JIT - STUPS Group

An ARM Backend for PyPyls Tracing JIT - STUPS Group

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

12 3 JUST-IN-TIME COMPILATIONwhen the execution count <strong>for</strong> a certain block of code passed a defined threshold thisblock would be further optimized and trans<strong>for</strong>med to machine code. <strong>An</strong>other projectthat innovated in the area of dynamic compilation is the SELF 3 project. SELF is a dynamicobject oriented language, inspired in many ways – such as message passing – bySmalltalk, it was built on a prototype based object model [SU94, UCCH91]. Because ofthe dynamic nature of the language it is difficult to optimize. SELF developed differentapproaches, finally creating a compiler that, based on runtime profiling, generated<strong>for</strong> one SELF method different optimized code paths depending on the types of the inputarguments [CUL89]. For a in depth historic overview of dynamic compilation see[Ayc03], which also contains a more detailed overview as well as different categorizationapproaches <strong>for</strong> <strong>JIT</strong> compilers.There are two main groups in which <strong>JIT</strong> compilers can be classified depending on howthey per<strong>for</strong>m profiling and optimize the instructions be<strong>for</strong>e generating low level code.3.1 Method Based Just-In-Time CompilationMethod based <strong>JIT</strong>s, as the name suggests, per<strong>for</strong>m profiling and compilation on a permethod basis. There are different approaches in this area, some systems compile methodsto lower level code when a method is first executed, such as some Smalltalk systems[DS84]. Other systems per<strong>for</strong>m profiling by counting the executions of methods to selectcandidate methods <strong>for</strong> compilation such as the Rubinius Ruby VM [Pho10]. <strong>An</strong>d finallythere are approaches such as the Java HotSpot server compiler and Google’s V8 Javascriptengine which do not contain an interpreter but per<strong>for</strong>m two step compilation by firstcompiling a version of the code with a fast compiler that does not per<strong>for</strong>m all possibleoptimizations, then in a second step the generated code is profiled to select candidatesthat are compiled per<strong>for</strong>ming more aggressive optimizations. [PVC01, V8 11]3.2 Trace Based Just-In-Time Compilation<strong>An</strong> alternative approach to profile and optimize programs at runtime is taken by tracing<strong>JIT</strong>s. <strong>Tracing</strong> <strong>JIT</strong>s operate take loops as the basic unit <strong>for</strong> profiling and optimization. Theexact definition of a loop can vary depending on the VM, but <strong>for</strong> bytecode based VMsis usually is defined as a stream of bytecodes ending with a backwards jump, the jumptarget is then the beginning of the loop. The basic assumptions of tracing <strong>JIT</strong>s are that:• A program spends most of its time in loops.• Iterations of a loop usually take similar paths through the code.A tracing <strong>JIT</strong> runs a program by interpreting it, first converting it to bytecode and recordingprofiling in<strong>for</strong>mation on the interpreted code. Once a certain threshold is passed thetracing <strong>JIT</strong> records the operations per<strong>for</strong>med during one execution of the loop. This listof operations that corresponds to one possible path through the loop is called a trace.3 http://labs.oracle.com/self/

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!