]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-115999: Refactor `LOAD_GLOBAL` specializations to avoid reloading {globals, builti...
authormpage <mpage@meta.com>
Wed, 9 Oct 2024 15:18:25 +0000 (08:18 -0700)
committerGitHub <noreply@github.com>
Wed, 9 Oct 2024 15:18:25 +0000 (15:18 +0000)
commitf978fb4f8d6eac0585057e463bb1701dc04a9900
tree72dc60eb608119b7c6f9315788132b7bb1b8ff92
parentb9a8ca0a6aa9251cb798f34f0c9d2cc95107eec6
gh-115999: Refactor `LOAD_GLOBAL` specializations to avoid reloading {globals, builtins} keys (gh-124953)

Each of the `LOAD_GLOBAL` specializations is implemented roughly as:

1. Load keys version.
2. Load cached keys version.
3. Deopt if (1) and (2) don't match.
4. Load keys.
5. Load cached index into keys.
6. Load object from (4) at offset from (5).

This is not thread-safe in free-threaded builds; the keys object may be replaced
in between steps (3) and (4).

This change refactors the specializations to avoid reloading the keys object and
instead pass the keys object from guards to be consumed by downstream uops.
Include/internal/pycore_opcode_metadata.h
Include/internal/pycore_uop_ids.h
Include/internal/pycore_uop_metadata.h
Python/bytecodes.c
Python/executor_cases.c.h
Python/generated_cases.c.h
Python/optimizer_analysis.c
Python/optimizer_bytecodes.c
Python/optimizer_cases.c.h