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.

36 7 CROSS TRANSLATION6.6 BridgesWhen a specific guard fails often enough that its failure count passes a defined thresholdthe <strong>JIT</strong> frontend begins to trace the execution from the failing guard. The trace is recordeduntil the entry point of another loop is found. This kind of trace is called a bridge. Once abridge has been traced it is passed to the backend to be compiled. The compilation of theinstructions contained in a bridge is the same as <strong>for</strong> a loop. The difference is in the setupof the bridge and how it is entered. A bridge is entered from a failing guard. To makethe entering of the loop as efficient as possible we patch the previously generated code<strong>for</strong> the guard in the loop with a jump to the compiled bridge. The patched guard fromour example above would then look like shown in Figure 22. Now in case the guard failsinstead of the jump to the exit procedure it now jumps directly to the code of the bridge.This means that when we enter a bridge we are in the same frame as the loop, thus wehave the same state, i.e. allocated registers, spilled values etc. When we generate a bridgewe need to setup the state to be the same as it was in the loop at the time the guard failed,<strong>for</strong> this we use the same encoded in<strong>for</strong>mation used when leaving the loop, decoding itand restoring the register and stack bindings with the variables.......CMP r1, 0ADDNE PC, 20LDR pc, pc + 4ADDRESS OF THE BRIDGEADDRESS OF ENCODED LOCATIONSADDRESS OF EXIT PROCEDURE......Figure 22: Patched machine code <strong>for</strong> guard_true(i0, [p0, i0])7 Cross TranslationTranslating PyPy is a memory and computation intensive task. To translate the fullPython interpreter at least 2GB of memory are required. Most <strong>ARM</strong> devices target eithermobile or embedded plat<strong>for</strong>ms, these devices usually do not have the power orresources to translate larger programs such as PyPy’s Python interpreter on the device itself.There<strong>for</strong>e, based on the work done <strong>for</strong> PyPy on Maemo [PyP11a], we implemented across translation target to translate PyPy on a more powerful host machine and generatecode <strong>for</strong> <strong>ARM</strong>-processors.PyPy has a mechanism to select different plat<strong>for</strong>ms and compilers to translate the generatedC code. This mechanism also provides an interface to gather in<strong>for</strong>mation aboutthe plat<strong>for</strong>m, libraries and to compile and execute programs on the plat<strong>for</strong>m. For thisthesis we implemented an additional plat<strong>for</strong>m <strong>for</strong> PyPy which can generate a binary <strong>for</strong>

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

Saved successfully!

Ooh no, something went wrong!