mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
gh-105481: combine regen-opcode-targets with regen-opcode to avoid calculating the specialized opcodes in two places (#107540)
This commit is contained in:
parent
6ef8f8ca88
commit
2bd04d4234
5 changed files with 16 additions and 68 deletions
|
@ -64,6 +64,7 @@ def get_python_module_dict(filename):
|
|||
def main(opcode_py,
|
||||
_opcode_metadata_py='Lib/_opcode_metadata.py',
|
||||
outfile='Include/opcode.h',
|
||||
opcode_targets_h='Python/opcode_targets.h',
|
||||
internaloutfile='Include/internal/pycore_opcode.h'):
|
||||
|
||||
_opcode_metadata = get_python_module_dict(_opcode_metadata_py)
|
||||
|
@ -161,9 +162,18 @@ def main(opcode_py,
|
|||
fobj.write(footer)
|
||||
iobj.write(internal_footer)
|
||||
|
||||
with open(opcode_targets_h, "w") as f:
|
||||
targets = ["_unknown_opcode"] * 256
|
||||
for op, name in enumerate(opname_including_specialized):
|
||||
if op < 256 and not name.startswith("<"):
|
||||
targets[op] = f"TARGET_{name}"
|
||||
|
||||
f.write("static void *opcode_targets[256] = {\n")
|
||||
f.write(",\n".join([f" &&{s}" for s in targets]))
|
||||
f.write("\n};\n")
|
||||
|
||||
print(f"{outfile} regenerated from {opcode_py}")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4])
|
||||
main(sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue