Skip to content

gh-135447: Document new bytecodes in 3.14 #135803

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
Open
Changes from all commits
Commits
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
27 changes: 27 additions & 0 deletions Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,12 @@ operations on it as if it was a Python list. The top of the stack corresponds to
generate line tracing events.


.. opcode:: NOT_TAKEN
Do nothing code. Used as a hint to the interpreter that a branch was predicted
as not taken.
Comment on lines +589 to +590
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot what NOT_TAKEN does, but the rest look good. Maybe @iritkatriel knows?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It indeed does nothing. Not sure it's related to prediction though. It think it's to give tracing applications like code coverage a way to distinguish between the taken/not taken branches.

CC @markshannon

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pure inst(NOP, (--)) {
}

family(RESUME, 0) = {
    RESUME_CHECK,
};

macro(NOT_TAKEN) = NOP;

Can we consider its behavior to be the same as NOP?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes its a NOP but I forgot if its a hint or not.

.. versionadded:: 3.14


.. opcode:: POP_TOP

Removes the top-of-stack item::
Expand Down Expand Up @@ -1163,6 +1169,27 @@ iterations of the loop.
.. versionadded:: 3.6


.. opcode:: BUILD_INTERPOLATION

It expects as stack inputs (from top of stack down):

* ``format``: ``STACK[oparg & 1]``
* ``str``: ``STACK[-1 - (oparg & 1)]``
* ``value``: ``STACK[-2 - (oparg & 1)]``

It outputs the interpolation object to ``STACK[-1]`` after consuming its inputs.

.. versionadded:: 3.14


.. opcode:: BUILD_TEMPLATE

Consumes ``STACK[-1]`` (interpolations) and ``STACK[-2]`` (strings) and
outputs the template object to ``STACK[-1]``.

.. versionadded:: 3.14


.. opcode:: LIST_EXTEND (i)

Implements::
Expand Down
Loading