Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Cpython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sip
Cpython
Commits
22739a0e
Unverified
Commit
22739a0e
authored
Oct 24, 2022
by
C.A.M. Gerlach
Committed by
GitHub
Oct 24, 2022
Browse files
Options
Downloads
Patches
Plain Diff
gh-95913: Edit, expand & format Bytecode sect in 3.11 WhatsNew (GH-98559)
parent
e81fad6b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Doc/whatsnew/3.11.rst
+81
-39
81 additions, 39 deletions
Doc/whatsnew/3.11.rst
with
81 additions
and
39 deletions
Doc/whatsnew/3.11.rst
+
81
−
39
View file @
22739a0e
...
@@ -1481,58 +1481,100 @@ contributors are volunteers from the community.
...
@@ -1481,58 +1481,100 @@ contributors are volunteers from the community.
CPython bytecode changes
CPython bytecode changes
========================
========================
* The bytecode now contains inline cache entries, which take the form of
The bytecode now contains inline cache entries,
:opcode:`CACHE` instructions. Many opcodes expect to be followed by an exact
which take the form of the newly-added :opcode:`CACHE` instructions.
number of caches, and instruct the interpreter to skip over them at runtime.
Many opcodes expect to be followed by an exact number of caches,
Populated caches can look like arbitrary instructions, so great care should be
and instruct the interpreter to skip over them at runtime.
taken when reading or modifying raw, adaptive bytecode containing quickened
Populated caches can look like arbitrary instructions,
data.
so great care should be taken when reading or modifying
raw, adaptive bytecode containing quickened data.
* Replaced all numeric ``BINARY_*`` and ``INPLACE_*`` instructions with a single
:opcode:`BINARY_OP` implementation.
* Replaced the three call instructions: :opcode:`CALL_FUNCTION`,
.. _whatsnew311-added-opcodes:
:opcode:`CALL_FUNCTION_KW` and :opcode:`CALL_METHOD` with
:opcode:`PUSH_NULL`, :opcode:`PRECALL`, :opcode:`CALL`,
and :opcode:`KW_NAMES`.
This decouples the argument shifting for methods from the handling of
keyword arguments and allows better specialization of calls.
* Removed ``COPY_DICT_WITHOUT_KEYS`` and ``GEN_START``.
New opcodes
-----------
* :opcode:`ASYNC_GEN_WRAP`, :opcode:`RETURN_GENERATOR` and :opcode:`SEND`,
used in generators and co-routines.
* :opcode:`MATCH_CLASS` and :opcode:`MATCH_KEYS` no longer push an additional
* :opcode:`COPY_FREE_VARS`,
boolean value indicating whether the match succeeded or failed. Instead, they
which avoids needing special caller-side code for closures.
indicate failure with :const:`None` (where a tuple of extracted values would
otherwise be).
* Replace several stack manipulation instructions (``DUP_TOP``, ``DUP_TOP_TWO``,
* :opcode:`JUMP_BACKWARD_NO_INTERRUPT`,
``ROT_TWO``, ``ROT_THREE``, ``ROT_FOUR``, and ``ROT_N``) with new
for use in certain loops where handling interrupts is undesirable.
:opcode:`COPY` and :opcode:`SWAP` instructions.
* Replaced :opcode:`JUMP_IF_NOT_EXC_MATCH` by :opcode:`CHECK_EXC_MATCH` which
* :opcode:`MAKE_CELL`, to create :ref:`cell-objects`.
performs the check but does not jump.
* Replaced :opcode:`JUMP_IF_NOT_EG_MATCH` by :opcode:`CHECK_EG_MATCH` which
* :opcode:`CHECK_EG_MATCH` and :opcode:`PREP_RERAISE_STAR`,
performs the check but does not jump.
to handle the :ref:`new exception groups and except* <whatsnew311-pep654>`
added in :pep:`654`.
*
Replaced :opcode:`JUMP_ABSOLUTE` by the relative :opcode:`JUMP_BACKWARD`
.
*
:opcode:`PUSH_EXC_INFO`, for use in exception handlers
.
*
Added
:opcode:`
JUMP_BACKWARD_NO_INTERRUPT`, which is used in certain loops where it
* :opcode:`
RESUME`, a no-op,
is undesirable to handle interrupt
s.
for internal tracing, debugging and optimization check
s.
* Replaced :opcode:`POP_JUMP_IF_TRUE` and :opcode:`POP_JUMP_IF_FALSE` by
the relative :opcode:`POP_JUMP_FORWARD_IF_TRUE`, :opcode:`POP_JUMP_BACKWARD_IF_TRUE`,
:opcode:`POP_JUMP_FORWARD_IF_FALSE` and :opcode:`POP_JUMP_BACKWARD_IF_FALSE`.
* Added :opcode:`POP_JUMP_FORWARD_IF_NOT_NONE`, :opcode:`POP_JUMP_BACKWARD_IF_NOT_NONE`,
.. _whatsnew311-replaced-opcodes:
:opcode:`POP_JUMP_FORWARD_IF_NONE` and :opcode:`POP_JUMP_BACKWARD_IF_NONE`
opcodes to speed up conditional jumps.
* :opcode:`JUMP_IF_TRUE_OR_POP` an
d
:
opcode
:`JUMP_IF_FALSE_OR_POP` are now
Replace
d opcode
s
relative rather than absolute.
----------------
* :opcode:`RESUME` has been added. It is a no-op. Performs internal tracing,
+------------------------------------+-----------------------------------+-----------------------------------------+
debugging and optimization checks.
| Replaced Opcode(s) | New Opcode(s) | Notes |
+====================================+===================================+=========================================+
| | :opcode:`!BINARY_*` | :opcode:`BINARY_OP` | Replaced all numeric binary/in-place |
| | :opcode:`!INPLACE_*` | | opcodes with a single opcode |
+------------------------------------+-----------------------------------+-----------------------------------------+
| | :opcode:`!CALL_FUNCTION` | | :opcode:`CALL` | Decouples argument shifting for methods |
| | :opcode:`!CALL_FUNCTION_KW` | | :opcode:`KW_NAMES` | from handling of keyword arguments; |
| | :opcode:`!CALL_METHOD` | | :opcode:`PRECALL` | allows better specialization of calls |
| | | :opcode:`PUSH_NULL` | |
+------------------------------------+-----------------------------------+-----------------------------------------+
| | :opcode:`!DUP_TOP` | | :opcode:`COPY` | Stack manipulation instructions |
| | :opcode:`!DUP_TOP_TWO` | | :opcode:`SWAP` | |
| | :opcode:`!ROT_TWO` | | |
| | :opcode:`!ROT_THREE` | | |
| | :opcode:`!ROT_FOUR` | | |
| | :opcode:`!ROT_N` | | |
+------------------------------------+-----------------------------------+-----------------------------------------+
| | :opcode:`!JUMP_IF_NOT_EXC_MATCH` | | :opcode:`CHECK_EXC_MATCH` | Now performs check but doesn't jump |
+------------------------------------+-----------------------------------+-----------------------------------------+
| | :opcode:`!JUMP_ABSOLUTE` | | :opcode:`JUMP_BACKWARD` | See [#bytecode-jump]_; |
| | :opcode:`!POP_JUMP_IF_FALSE` | | :opcode:`POP_JUMP_BACKWARD_IF_* | ``TRUE``, ``FALSE``, |
| | :opcode:`!POP_JUMP_IF_TRUE` | <POP_JUMP_BACKWARD_IF_TRUE>` | ``NONE`` and ``NOT_NONE`` variants |
| | | :opcode:`POP_JUMP_FORWARD_IF_* | for each direction |
| | <POP_JUMP_FORWARD_IF_TRUE>` | |
+------------------------------------+-----------------------------------+-----------------------------------------+
| | :opcode:`!SETUP_WITH` | :opcode:`BEFORE_WITH` | :keyword:`with` block setup |
| | :opcode:`!SETUP_ASYNC_WITH` | | |
+------------------------------------+-----------------------------------+-----------------------------------------+
.. [#bytecode-jump] All jump opcodes are now relative, including the
existing :opcode:`JUMP_IF_TRUE_OR_POP` and :opcode:`JUMP_IF_FALSE_OR_POP`.
The argument is now an offset from the current instruction
rather than an absolute location.
.. _whatsnew311-changed-opcodes:
.. _whatsnew311-removed-opcodes:
.. _whatsnew311-changed-removed-opcodes:
Changed/removed opcodes
-----------------------
* Changed :opcode:`MATCH_CLASS` and :opcode:`MATCH_KEYS`
to no longer push an additional boolean value to indicate success/failure.
Instead, ``None`` is pushed on failure
in place of the tuple of extracted values.
* Changed opcodes that work with exceptions to reflect them
now being represented as one item on the stack instead of three
(see :gh:`89874`).
* Removed :opcode:`!COPY_DICT_WITHOUT_KEYS`, :opcode:`!GEN_START`,
:opcode:`!POP_BLOCK`, :opcode:`!SETUP_FINALLY` and :opcode:`!YIELD_FROM`.
.. _whatsnew311-deprecated:
.. _whatsnew311-deprecated:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment