| 1 |
#include "Python.h" |
| 2 |
|
| 3 |
#include "pycore_ceval.h" |
| 4 |
#include "pycore_frame.h" |
| 5 |
#include "pycore_jit.h" |
| 6 |
|
| 7 |
// This is where the calling convention changes, on platforms that require it. |
| 8 |
// The actual change is patched in while the JIT compiler is being built, in |
| 9 |
// Tools/jit/_targets.py. On other platforms, this function compiles to nothing. |
| 10 |
_Py_CODEUNIT * |
| 11 |
_ENTRY(_PyInterpreterFrame *frame, PyObject **stack_pointer, PyThreadState *tstate) |
| 12 |
{ |
| 13 |
// This is subtle. The actual trace will return to us once it exits, so we |
| 14 |
// need to make sure that we stay alive until then. If our trace side-exits |
| 15 |
// into another trace, and this trace is then invalidated, the code for |
| 16 |
// *this function* will be freed and we'll crash upon return: |
| 17 |
PyAPI_DATA(void) _JIT_EXECUTOR; |
| 18 |
PyObject *executor = (PyObject *)(uintptr_t)&_JIT_EXECUTOR; |
| 19 |
Py_INCREF(executor); |
| 20 |
// Note that this is *not* a tail call: |
| 21 |
PyAPI_DATA(void) _JIT_CONTINUE; |
| 22 |
_Py_CODEUNIT *target = ((jit_func)&_JIT_CONTINUE)(frame, stack_pointer, tstate); |
| 23 |
Py_SETREF(tstate->previous_executor, executor); |
| 24 |
return target; |
| 25 |
} |