Skip to content
Prev Previous commit
Next Next commit
interpreter jit is for debugging
  • Loading branch information
iritkatriel committed Dec 6, 2024
commit bc8a50bf7eed9f0b49e729ffd5981dda2186a32b
20 changes: 13 additions & 7 deletions InternalDocs/jit.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Comment thread
iritkatriel marked this conversation as resolved.
Outdated

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
Expand Down