8000 gh-105481: generate op IDs from bytecode.c instead of hard coding them in opcode.py by iritkatriel · Pull Request #107971 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-105481: generate op IDs from bytecode.c instead of hard coding them in opcode.py #107971

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

Merged
merged 18 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
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
540 changes: 0 additions & 540 deletions Include/internal/pycore_opcode.h

Large diffs are not rendered by default.

490 changes: 490 additions & 0 deletions Include/internal/pycore_opcode_metadata.h

Large diffs are not rendered by default.

436 changes: 219 additions & 217 deletions Include/opcode_ids.h

Large diffs are not rendered by default.

226 changes: 225 additions & 1 deletion Lib/_opcode_metadata.py

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

10 changes: 5 additions & 5 deletions Lib/dis.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
_intrinsic_1_descs,
_intrinsic_2_descs,
_specializations,
_specialized_instructions,
_specialized_opmap,
)

__all__ = ["code_info", "dis", "disassemble", "distb", "disco",
Expand Down Expand Up @@ -49,11 +49,11 @@

_all_opname = list(opname)
_all_opmap = dict(opmap)
_empty_slot = [slot for slot, name in enumerate(_all_opname) if name.startswith("<")]
for spec_op, specialized in zip(_empty_slot, _specialized_instructions):
for name, op in _specialized_opmap.items():
# fill opname and opmap
_all_opname[spec_op] = specialized
_all_opmap[specialized] = spec_op
assert op < len(_all_opname)
_all_opname[op] = name
_all_opmap[name] = op

deoptmap = {
specialized: base for base, family in _specializations.items() for specialized in family
Expand Down
3 changes: 2 additions & 1 deletion Lib/importlib/_bootstrap_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ def _write_atomic(path, data, mode=0o666):
# Python 3.13a1 3556 (Convert LOAD_CLOSURE to a pseudo-op)
# Python 3.13a1 3557 (Make the conversion to boolean in jumps explicit)
# Python 3.13a1 3558 (Reorder the stack items for CALL)
# Python 3.13a1 3559 (Generate opcode IDs from bytecodes.c)

# Python 3.14 will start with 3600

Expand All @@ -470,7 +471,7 @@ def _write_atomic(path, data, mode=0o666):
# Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array
# in PC/launcher.c must also be updated.

MAGIC_NUMBER = (3558).to_bytes(2, 'little') + b'\r\n'
MAGIC_NUMBER = (3559).to_bytes(2, 'little') + b'\r\n'

_RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c

Expand Down
Loading
0