Skip to content
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

GH-125837: Split LOAD_CONST into three. #125972

Merged
merged 34 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2a61cfc
Replace RETURN_VLAUE/RETURN_CONST with RETURN_VALUE_FUNC/RETURN_VALUE…
markshannon Oct 22, 2024
42a526c
Add LOAD_CONST_IMMORTAL
markshannon Oct 23, 2024
2a3b1e2
Fix up all the tests apart from test_dis
markshannon Oct 23, 2024
031f320
Update optimizer
markshannon Oct 23, 2024
cb5252b
Fix up test_dis
markshannon Oct 23, 2024
892edbc
Fix up a couple of comments
markshannon Oct 23, 2024
5ce99ca
Apply suggestions from code review
markshannon Oct 24, 2024
325c5fe
Clarify comment
markshannon Oct 24, 2024
6149153
Remove unused function
markshannon Oct 24, 2024
59a554a
Update test
markshannon Oct 24, 2024
bcb4e65
Update dis docs
markshannon Oct 24, 2024
f3383e5
Remove link to remove instruction
markshannon Oct 24, 2024
68e97ba
Restore RETURN_VALUE
markshannon Oct 25, 2024
0b8a5ad
Add LOAD_INT instruction
markshannon Oct 24, 2024
1bfdd70
Fix up dis and some tests
markshannon Oct 24, 2024
f934559
Fix up test dis
markshannon Oct 25, 2024
f135b69
Address review comments
markshannon Oct 25, 2024
8f2a781
Fix __annotate__ docstring
markshannon Oct 25, 2024
97c6cdc
Teach optimizer about LOAD_INT
markshannon Oct 25, 2024
eefcbdf
Remove remnants of earlier PR
markshannon Oct 25, 2024
58dab8e
Remove last remnant of earlier PR
markshannon Oct 25, 2024
81e4dd6
Remove the definitely last remnant of earlier PR
markshannon Oct 25, 2024
050fc1e
Document LOAD_INT and add news
markshannon Oct 25, 2024
46055c1
Revert unnecessary name changes
markshannon Oct 25, 2024
79305d2
Make functions static again to avoid warning
markshannon Oct 25, 2024
7e4b2a8
implement review suggestion
markshannon Oct 25, 2024
57e891e
Address review comments
markshannon Oct 28, 2024
207e35e
Fix typo
markshannon Oct 28, 2024
7c88f69
Remove extra argument
markshannon Oct 28, 2024
9d4e575
Rename LOAD_INT to LOAD_SMALL_INT
markshannon Oct 28, 2024
ae11453
Regenerate test file
markshannon Oct 28, 2024
3a50437
Fix test_dis
markshannon Oct 28, 2024
47927cf
Don't mark LOAD_SMALL_INT as having a constant, as it doesn't load fr…
markshannon Oct 28, 2024
3caac1a
Add back int to test
markshannon Oct 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -862,13 +862,6 @@ iterations of the loop.
Returns with ``STACK[-1]`` to the caller of the function.


.. opcode:: RETURN_CONST (consti)

Returns with ``co_consts[consti]`` to the caller of the function.

.. versionadded:: 3.12


.. opcode:: YIELD_VALUE

Yields ``STACK.pop()`` from a :term:`generator`.
Expand Down Expand Up @@ -1086,6 +1079,22 @@ iterations of the loop.
Pushes ``co_consts[consti]`` onto the stack.


.. opcode:: LOAD_INT (i)

Pushes the integer ``i`` onto the stack.
``i`` must be in ``range(256)``
iritkatriel marked this conversation as resolved.
Show resolved Hide resolved

.. versionadded:: 3.14


.. opcode:: LOAD_CONST_IMMORTAL (consti)

Pushes ``co_consts[consti]`` onto the stack.
Can be used when the constant value is known to be immortal.

.. versionadded:: 3.14


.. opcode:: LOAD_NAME (namei)

Pushes the value associated with ``co_names[namei]`` onto the stack.
Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ CPython bytecode changes
* Add the :opcode:`LOAD_SUPER_ATTR` instruction. (Contributed by Carl Meyer and
Vladimir Matveev in :gh:`103497`.)

* Add the :opcode:`RETURN_CONST` instruction. (Contributed by Wenyang Wang in :gh:`101632`.)
* Add the ``RETURN_CONST`` instruction. (Contributed by Wenyang Wang in :gh:`101632`.)

Demos and Tools
===============
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 @@ -261,6 +261,7 @@ Known values:
Python 3.14a1 3606 (Specialize CALL_KW)
Python 3.14a1 3607 (Add pseudo instructions JUMP_IF_TRUE/FALSE)
Python 3.14a1 3608 (Add support for slices)
Python 3.14a2 3609 (Add LOAD_INT and LOAD_CONST_IMMORTAL instructions)
iritkatriel marked this conversation as resolved.
Show resolved Hide resolved

Python 3.15 will start with 3650

Expand All @@ -273,7 +274,7 @@ PC/launcher.c must also be updated.

*/

#define PYC_MAGIC_NUMBER 3608
#define PYC_MAGIC_NUMBER 3609
/* 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
33 changes: 17 additions & 16 deletions Include/internal/pycore_opcode_metadata.h

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

1 change: 0 additions & 1 deletion Include/internal/pycore_opcode_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ extern "C" {

#define IS_SCOPE_EXIT_OPCODE(opcode) \
((opcode) == RETURN_VALUE || \
(opcode) == RETURN_CONST || \
(opcode) == RAISE_VARARGS || \
(opcode) == RERAISE)

Expand Down
Loading
Loading