summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorBrandt Bucher <brandtbucher@microsoft.com>2024-01-29 02:48:48 (GMT)
committerGitHub <noreply@github.com>2024-01-29 02:48:48 (GMT)
commitf6d9e5926b6138994eaa60d1c36462e36105733d (patch)
tree53362fa9918ab65519ccf9a343cfcdfcfa9c4f6f /Python/ceval.c
parentf7c05d7ad3075a1dbeed86b6b12903032e4afba6 (diff)
downloadcpython-f6d9e5926b6138994eaa60d1c36462e36105733d.zip
cpython-f6d9e5926b6138994eaa60d1c36462e36105733d.tar.gz
cpython-f6d9e5926b6138994eaa60d1c36462e36105733d.tar.bz2
GH-113464: Add a JIT backend for tier 2 (GH-113465)
Add an option (--enable-experimental-jit for configure-based builds or --experimental-jit for PCbuild-based ones) to build an *experimental* just-in-time compiler, based on copy-and-patch (https://fredrikbk.com/publications/copy-and-patch.pdf). See Tools/jit/README.md for more information on how to install the required build-time tooling.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 49388cd..4f20800 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -11,6 +11,7 @@
#include "pycore_function.h"
#include "pycore_instruments.h"
#include "pycore_intrinsics.h"
+#include "pycore_jit.h"
#include "pycore_long.h" // _PyLong_GetZero()
#include "pycore_moduleobject.h" // PyModuleObject
#include "pycore_object.h" // _PyObject_GC_TRACK()
@@ -955,9 +956,24 @@ resume_with_error:
-// The Tier 2 interpreter is also here!
+// Tier 2 is also here!
enter_tier_two:
+#ifdef _Py_JIT
+
+ ; // ;)
+ jit_func jitted = current_executor->jit_code;
+ next_instr = jitted(frame, stack_pointer, tstate);
+ frame = tstate->current_frame;
+ Py_DECREF(current_executor);
+ if (next_instr == NULL) {
+ goto resume_with_error;
+ }
+ stack_pointer = _PyFrame_GetStackPointer(frame);
+ DISPATCH();
+
+#else
+
#undef LOAD_IP
#define LOAD_IP(UNUSED) (void)0
@@ -1073,6 +1089,8 @@ deoptimize:
Py_DECREF(current_executor);
DISPATCH();
+#endif // _Py_JIT
+
}
#if defined(__GNUC__)
# pragma GCC diagnostic pop