8000 GH-132532: Make CHECK_PERIODIC an instruction, not just a uop. by markshannon · Pull Request #135772 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-132532: Make CHECK_PERIODIC an instruction, not just a uop. #135772

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
11 changes: 11 additions & 0 deletions Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ the following command can be used to display the disassembly of
3 LOAD_GLOBAL 1 (len + NULL)
LOAD_FAST_BORROW 0 (alist)
CALL 1
CHECK_PERIODIC
RETURN_VALUE

(The "2" is a line number).
Expand Down Expand Up @@ -217,6 +218,7 @@ Example:
LOAD_GLOBAL
LOAD_FAST_BORROW
CALL
CHECK_PERIODIC
RETURN_VALUE


Expand Down Expand Up @@ -1751,6 +1753,15 @@ iterations of the loop.
.. versionadded:: 3.11


.. opcode:: CHECK_PERIODIC

Checks the eval breaker and performs periodic tasks if the eval breaker is set.
Tasks inlcude switching threads and performing GC amongst others.
All :opcode:`CALL` instructions must be followed by :opcode:`CHECK_PERIODIC`.

.. versionadded:: 3.14


.. opcode:: HAVE_ARGUMENT

This is not really an opcode. It identifies the dividing line between
Expand Down
3 changes: 2 additions & 1 deletion Include/internal/pycore_magic_number.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ Known values:
Python 3.15a1 3651 (Simplify LOAD_CONST)
Python 3.15a1 3652 (Virtual iterators)
Python 3.15a1 3653 (Fix handling of opcodes that may leave operands on the stack when optimizing LOAD_FAST)
Python 3.15a2 3654 (Add CHECK_PERIODIC opcode)


Python 3.16 will start with 3700
Expand All @@ -294,7 +295,7 @@ PC/launcher.c must also be updated.

*/

#define PYC_MAGIC_NUMBER 3653
#define PYC_MAGIC_NUMBER 3654
/* This is equivalent to converting PYC_MAGIC_NUMBER to 2 bytes
(little-endian) and then appending b'\r\n'. */
#define PYC_MAGIC_NUMBER_TOKEN \
Expand Down
75 changes: 40 additions & 35 deletions Include/internal/pycore_opcode_metadata.h

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Include/internal/pycore_optimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ typedef struct _JitOptContext {
char done;
char out_of_space;
bool contradiction;
bool can_skip_periodic;
// The current "executing" frame.
_Py_UOpsAbstractFrame *frame;
_Py_UOpsAbstractFrame frames[MAX_ABSTRACT_FRAME_DEPTH];
Expand Down
134 changes: 68 additions & 66 deletions Include/internal/pycore_uop_ids.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions Include/internal/pycore_uop_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
0