Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-119786: Add jit.md. Move adaptive.md to a section of interpreter.md. #127175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Dec 6, 2024
Prev Previous commit
Next Next commit
cache layouts
  • Loading branch information
iritkatriel committed Dec 5, 2024
commit 43aa0dfd62f7da5b402f942e483e007fe9cddf6c
12 changes: 7 additions & 5 deletions InternalDocs/interpreter.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,13 @@ the same. Cache entries are reserved by the compiler and initialized with zeros
Although they are represented by code units, cache entries do not conform to the
`opcode` / `oparg` format.

If an instruction has an inline cache, the layout of its cache is described by
a `struct` definition in [`pycore_code.h`](../Include/internal/pycore_code.h).
This allows us to access the cache by casting `next_instr` to a pointer to this `struct`.
The size of such a `struct` must be independent of the machine architecture, word size
and alignment requirements. For a 32-bit field, the `struct` should use `_Py_CODEUNIT field[2]`.
If an instruction has an inline cache, the layout of its cache is described in
the instruction's definition in [`Python/bytecodes.c`](../Python/bytecodes.c).
The structs defined in [`pycore_code.h`](../Include/internal/pycore_code.h)
allow us to access the cache by casting `next_instr` to a pointer to the relevant
`struct`. The size of such a `struct` must be independent of the machine
architecture, word size and alignment requirements. For a 32-bit field, the
`struct` should use `_Py_CODEUNIT field[2]`.

The instruction implementation is responsible for advancing `next_instr` past the inline cache.
For example, if an instruction's inline cache is four bytes (that is, two code units) in size,
Expand Down