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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

20 5 PYPY’S APPROACH TO TRACING <strong>JIT</strong>S5.2 OptimizationsIn this section we are going to describe some of the optimizations per<strong>for</strong>med by PyPy’stracing <strong>JIT</strong> on the recorded traces be<strong>for</strong>e they are trans<strong>for</strong>med into machine code. Optimizationsapplicable to traces are well known optimizations used in compilers, but havethe advantage that the trace they operate on is a linear structure and do not have to takebranching and conditional execution into account.Some optimizations are described below, other optimizations are:• reducing memory accesses by removing read and write operations and reusing previousresults• reusing results of pure operations• removing redundant guardsGreen Folding Because the tracing <strong>JIT</strong> is applied to the language interpreter many ofthe operations in the trace deal with manipulating the data structures of the languageinterpreter and not with the calculation per<strong>for</strong>med by the user program itself. Specificallymost of the operations work on the bytecode and program counter. The values of thesedata structures are known when entering the loop, since they are part of the hints <strong>for</strong>the <strong>JIT</strong>. Operations on these variables can be constant folded, because the operationsinvolved are side effect free and the string holding the bytecode is immutable.Figure 9 shows the trace be<strong>for</strong>e removing the operations on the interpreter data structuresby constant folding and Figure 10 shows the resulting trace after removing theseoperations.Allocation Removal This optimization, described in [BCF + 11], tries to avoid object allocationsby virtualizing objects allocated within the trace. If the object does not escapethe trace, i.e. it is only used within the trace the allocation can be removed completelyand the object is replaced by its fields which are treated as local variables.Loop Invariant Code Motion Is a technique to optimize loops by moving loop invariantexpressions [ALSU06] outside of the loop body, i.e. values that do not change overiterations and are not dependent of variables modified in the loop. The core idea abouthow this optimization is applied to traces is described in [Ard11].

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

Saved successfully!

Ooh no, something went wrong!