Skip to content
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
12 changes: 11 additions & 1 deletion scripts/dis_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,22 @@ def _resolve_arg_fallback(code, opname, arg):
"LOAD_ATTR",
"STORE_ATTR",
"DELETE_ATTR",
"IMPORT_NAME",
"IMPORT_FROM",
"LOAD_FROM_DICT_OR_GLOBALS",
):
if 0 <= arg < len(code.co_names):
return code.co_names[arg]
elif opname == "IMPORT_NAME":
name_idx, policy = arg, 0
if sys.version_info >= (3, 15):
name_idx, policy = arg >> 2, arg & 3
if 0 <= name_idx < len(code.co_names):
name = code.co_names[name_idx]
if policy & 1 and name:
return f"{name} + lazy"
if policy & 2 and name:
return f"{name} + eager"
return name
elif opname == "LOAD_SUPER_ATTR":
name_idx = arg >> 2
if 0 <= name_idx < len(code.co_names):
Expand Down
2 changes: 2 additions & 0 deletions tools/opcode_metadata/cpython.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import functools
import os
import pathlib
import sys
Expand All @@ -18,6 +19,7 @@
from stack import get_stack_effect


@functools.cache
def get_analysis() -> Analysis:
from generators_common import DEFAULT_INPUT

Expand Down
16 changes: 14 additions & 2 deletions tools/opcode_metadata/opcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ def deopts(self) -> dict[str, list[str]]:

for member in family.members:
member_name = to_pascal_case(member.name)
if member.name == family_name:
if member_name == family_name or member_name not in names:
continue

res[family_name].append(member_name)
if member_name not in res[family_name]:
res[family_name].append(member_name)

return dict(res)

Expand Down Expand Up @@ -76,6 +77,17 @@ def iter_opcodes(text: str, override_confs: OverrideConfs) -> Iterable[Opcode]:
opcode = Opcode.from_str(entry)

rust_name = opcode.rust_name
# Shared opcodes use CPython's wire-format IDs; RustPython-only
# instructions must occupy an otherwise unused slot.
expected_id = analysis.opmap.get(opcode.cpython_name)
if expected_id is not None and opcode.id != expected_id:
raise ValueError(
f"{rust_name} has opcode ID {opcode.id}; CPython requires {expected_id}"
)
if expected_id is None and opcode.id in analysis.opmap.values():
raise ValueError(
f"RustPython-only opcode {rust_name} collides with CPython ID {opcode.id}"
)
override = override_confs.get(rust_name, SKIP_OVERRIDE)

cpython_name = opcode.cpython_name
Expand Down
Loading