From bc8a50bf7eed9f0b49e729ffd5981dda2186a32b Mon Sep 17 00:00:00 2001 From: Irit Katriel Date: Fri, 6 Dec 2024 15:14:04 +0000 Subject: [PATCH] interpreter jit is for debugging --- InternalDocs/jit.md | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/InternalDocs/jit.md b/InternalDocs/jit.md index e1308806a96f06..5b87226b073a7c 100644 --- a/InternalDocs/jit.md +++ b/InternalDocs/jit.md @@ -59,18 +59,24 @@ and an instance of `_PyUOpExecutor_Type` is created to contain it. After a `JUMP_BACKWARD` instruction invokes the uop optimizer to create a uop executor, it transfers control to this executor via the `GOTO_TIER_TWO` macro. -When the JIT is configured to run on its interpreter (i.e., python is -configured with -[`--enable-experimental-jit=interpreter`](https://docs.python.org/dev/using/configure.html#cmdoption-enable-experimental-jit)), -the executor jumps to `tier2_dispatch:` in +CPython implements two executors. Here we describe the JIT interpreter, +which is the simpler of them and is therefore useful for debugging and analyzing +the uops generation and optimization stages. To run it, we configure the +JIT to run on its interpreter (i.e., python is configured with +[`--enable-experimental-jit=interpreter`](https://docs.python.org/dev/using/configure.html#cmdoption-enable-experimental-jit)). + +When invoked, the executor jumps to the `tier2_dispatch:` label in [`Python/ceval.c`](../Python/ceval.c), where there is a loop that -executes the micro-ops. The micro-ops are are defined in -[`Python/executor_cases.c.h`](../Python/executor_cases.c.h), +executes the micro-ops. The body of this loop is a switch statement over +the uops IDs, reselmbling the one used in the adaptive interpreter. + +The swtich implementing the uops is in [`Python/executor_cases.c.h`](../Python/executor_cases.c.h), which is generated by the build script [`Tools/cases_generator/tier2_generator.py`](../Tools/cases_generator/tier2_generator.py) from the bytecode definitions in [`Python/bytecodes.c`](../Python/bytecodes.c). -This loop exits when an `_EXIT_TRACE` or `_DEOPT` uop is reached, + +When an `_EXIT_TRACE` or `_DEOPT` uop is reached, the uop interpreter exits and execution returns to the adaptive interpreter. ## Invalidating Executors