Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
gh-105775: Update documentation, whitespace tweaks
- Describe the LOAD_CLOSURE change using more neutral language
- Add back in deleted whitespace
- Add an assertion to
  IsolatedAssembleTests.test_expression_with_pseudo_instruction_load_closure
- Regenerate generated files
  • Loading branch information
polynomialherder committed Jun 27, 2023
commit 988189df3788c161834079e9bad9da5e0071a74f
2 changes: 1 addition & 1 deletion Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1721,7 +1721,7 @@ but are replaced by real opcodes or removed before bytecode is generated.
Note that ``LOAD_CLOSURE`` is replaced with ``LOAD_FAST`` in the assembler.

.. versionchanged:: 3.13
This opcode was demoted from full opcode to pseudo-instruction
This opcode is now a pseudo-instruction.


.. opcode:: LOAD_METHOD
Expand Down
2 changes: 1 addition & 1 deletion Lib/importlib/_bootstrap_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def _write_atomic(path, data, mode=0o666):
# Python 3.13a1 3553 (Add SET_FUNCTION_ATTRIBUTE)
# Python 3.13a1 3554 (more efficient bytecodes for f-strings)
# Python 3.13a1 3555 (generate specialized opcodes metadata from bytecodes.c)
# Python 3.13a1 3556 (Remove LOAD_CLOSURE)
# Python 3.13a1 3556 (Convert LOAD_CLOSURE to a pseudo-op)

# Python 3.14 will start with 3600

Expand Down
2 changes: 1 addition & 1 deletion Lib/opcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,9 @@ def pseudo_op(name, op, real_ops):
pseudo_op('LOAD_SUPER_METHOD', 263, ['LOAD_SUPER_ATTR'])
pseudo_op('LOAD_ZERO_SUPER_METHOD', 264, ['LOAD_SUPER_ATTR'])
pseudo_op('LOAD_ZERO_SUPER_ATTR', 265, ['LOAD_SUPER_ATTR'])
pseudo_op('LOAD_CLOSURE', 267, ['LOAD_FAST'])

pseudo_op('STORE_FAST_MAYBE_NULL', 266, ['STORE_FAST'])
pseudo_op('LOAD_CLOSURE', 267, ['LOAD_FAST'])

MAX_PSEUDO_OPCODE = MIN_PSEUDO_OPCODE + len(_pseudo_ops) - 1

Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_compiler_assemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def inner():
return inner() % 2

inner_code = mod_two.__code__.co_consts[1]
Comment thread
iritkatriel marked this conversation as resolved.
assert isinstance(inner_code, types.CodeType)

metadata = {
'filename' : 'mod_two.py',
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Remove the LOAD_CLOSURE opcode and make it a pseudo-op instead.
Convert :opcode:`LOAD_CLOSURE` to a pseudo-op.
Comment thread
polynomialherder marked this conversation as resolved.
Outdated
2 changes: 2 additions & 0 deletions Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ dummy_func(
// BEGIN BYTECODES //
inst(NOP, (--)) {
}

inst(RESUME, (--)) {
assert(tstate->cframe == &cframe);
assert(frame == cframe.current_frame);
Expand Down Expand Up @@ -195,6 +196,7 @@ dummy_func(
// do not use SETLOCAL here, it decrefs the old value
GETLOCAL(oparg) = NULL;
}

inst(LOAD_FAST_LOAD_FAST, ( -- value1, value2)) {
uint32_t oparg1 = oparg >> 4;
uint32_t oparg2 = oparg & 15;
Expand Down
1 change: 1 addition & 0 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@ stack_effect(int opcode, int oparg, int jump)
* of __(a)enter__ and push 2 values before jumping to the handler
* if an exception be raised. */
return jump ? 1 : 0;

case STORE_FAST_MAYBE_NULL:
return -1;
case LOAD_CLOSURE:
Expand Down
Loading