Skip to content

Commit

Permalink
interpreter jit is for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
iritkatriel committed Dec 6, 2024
1 parent aced06a commit bc8a50b
Showing 1 changed file with 13 additions and 7 deletions.
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.

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

0 comments on commit bc8a50b

Please sign in to comment.