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.

28 6 A BACKEND FOR PYPY’S <strong>JIT</strong>to be spilled is based on the previously calculated longevity of the variables, spilling thevariable that survives <strong>for</strong> the longest time. This selection scheme should avoid blockingregisters by linking them to very long lived variables. A possible drawback is althoughif the variable is long-lived and often used, then it could occur that it needs to be readfrequently from memory if spilling occurs between usages. Once a variable is selected <strong>for</strong>spilling we generate an instruction to move this variable to the spilling area on the stackand store the in<strong>for</strong>mation about where on the stack the variable is stored in the registerallocator. After moving the variable away we can free the previously bound register andassociate it with a new variable.6.3 Setup to Execute a Compiled LoopApart from compiling a trace, we need a way to actually execute the compiled instructions.This means that we need a mechanism to call into the compiled code once the frontendtries to execute the same loop again. Similar to the approach described in [GFE + 09]we generate code that follows the plat<strong>for</strong>m calling conventions (see Section 2.2.3 <strong>for</strong> howto create a procedure interface [Ear09]) so it can be casted to a function pointer at runtimeand called as a normal function/procedure.The compilation process <strong>for</strong> a loop is started when the frontend passes an optimized traceto the backend. Be<strong>for</strong>e the instructions contained in the trace can be compiled the backendneeds to take some preparing steps to provide an interface to the compiled trace thatcan be executed. This consist of creating a callable interface and generating the instructionsto set up the frame and load the arguments <strong>for</strong> the loop.6.3.1 Frame LayoutBe<strong>for</strong>e we can execute instruction we need to setup the frame of the procedure. For thiswe generate instructions that create a frame as described below.The frame layout is composed of four parts:• callee saved registers, according to the calling convention• a slot to store the <strong>for</strong>ce index, a value used to check if the interpreter level framewas <strong>for</strong>ced (see Section 6.4.6)• an area to store spilled variables• and the stack where push and pop instructions operateThe frame begins with the registers the function has to save according to the calling conventiondescribed in Section 2.2.3, which are on <strong>ARM</strong> registers r4 up to r11 or FP. Afterthese registers one word on the stack is left to store the <strong>for</strong>ce index, see Section 6.4.6.After the location <strong>for</strong> the <strong>for</strong>ce index the frame contains space <strong>for</strong> spilled register values.The address of the beginning of this area is stored in the FP register and spilled valuesare addressed by their offset from the FP. After this area the classic stack area begins

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

Saved successfully!

Ooh no, something went wrong!