Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2bd04d4

Browse files
authored
gh-105481: combine regen-opcode-targets with regen-opcode to avoid calculating the specialized opcodes in two places (#107540)
1 parent6ef8f8c commit2bd04d4

File tree

5 files changed

+16
-68
lines changed

5 files changed

+16
-68
lines changed

‎Makefile.pre.in

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,7 @@ regen-limited-abi: all
13161316
# Regenerate all generated files
13171317

13181318
.PHONY: regen-all
1319-
regen-all: regen-cases regen-opcode regen-opcode-targets regen-typeslots \
1319+
regen-all: regen-cases regen-opcode regen-typeslots \
13201320
regen-token regen-ast regen-keyword regen-sre regen-frozen clinic \
13211321
regen-pegen-metaparser regen-pegen regen-test-frozenmain \
13221322
regen-test-levenshtein regen-global-objects
@@ -1428,8 +1428,10 @@ regen-opcode:
14281428
$(srcdir)/Lib/opcode.py \
14291429
$(srcdir)/Lib/_opcode_metadata.py \
14301430
$(srcdir)/Include/opcode.h.new \
1431+
$(srcdir)/Python/opcode_targets.h.new \
14311432
$(srcdir)/Include/internal/pycore_opcode.h.new
14321433
$(UPDATE_FILE) $(srcdir)/Include/opcode.h $(srcdir)/Include/opcode.h.new
1434+
$(UPDATE_FILE) $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/opcode_targets.h.new
14331435
$(UPDATE_FILE) $(srcdir)/Include/internal/pycore_opcode.h $(srcdir)/Include/internal/pycore_opcode.h.new
14341436

14351437
.PHONY: regen-token
@@ -1531,13 +1533,6 @@ Objects/unicodeobject.o: $(srcdir)/Objects/unicodeobject.c $(UNICODE_DEPS)
15311533
Objects/dictobject.o: $(srcdir)/Objects/stringlib/eq.h
15321534
Objects/setobject.o: $(srcdir)/Objects/stringlib/eq.h
15331535

1534-
.PHONY: regen-opcode-targets
1535-
regen-opcode-targets:
1536-
# Regenerate Python/opcode_targets.h from Lib/opcode.py
1537-
# using Python/makeopcodetargets.py
1538-
$(PYTHON_FOR_REGEN) $(srcdir)/Python/makeopcodetargets.py \
1539-
$(srcdir)/Python/opcode_targets.h.new
1540-
$(UPDATE_FILE) $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/opcode_targets.h.new
15411536

15421537
.PHONY: regen-cases
15431538
regen-cases:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove the make target ``regen-opcode-targets``, merge its work into ``regen-opcode`` which repeats most of the calculation. This simplifies the code for the build and reduces code duplication.

‎PCbuild/regen.targets

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@
5959
Inputs="@(_OpcodeSources)"Outputs="@(_OpcodeOutputs)"
6060
DependsOnTargets="FindPythonForBuild">
6161
<MessageText="Regenerate @(_OpcodeOutputs->'%(Filename)%(Extension)',' ')"Importance="high" />
62-
<ExecCommand="$(PythonForBuild) Tools\build\generate_opcode_h.py Lib\opcode.py Lib\_opcode_metadata.py Include\opcode.h Include\internal\pycore_opcode.h Include\internal\pycore_intrinsics.h"
63-
WorkingDirectory="$(PySourcePath)" />
64-
<ExecCommand="$(PythonForBuild) Python\makeopcodetargets.py Python\opcode_targets.h"
62+
<ExecCommand="$(PythonForBuild) Tools\build\generate_opcode_h.py Lib\opcode.py Lib\_opcode_metadata.py Include\opcode.h Python/opcode_targets.h Include\internal\pycore_opcode.h Include\internal\pycore_intrinsics.h"
6563
WorkingDirectory="$(PySourcePath)" />
6664
</Target>
6765

‎Python/makeopcodetargets.py

Lines changed: 0 additions & 56 deletions
This file was deleted.

‎Tools/build/generate_opcode_h.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def get_python_module_dict(filename):
6464
defmain(opcode_py,
6565
_opcode_metadata_py='Lib/_opcode_metadata.py',
6666
outfile='Include/opcode.h',
67+
opcode_targets_h='Python/opcode_targets.h',
6768
internaloutfile='Include/internal/pycore_opcode.h'):
6869

6970
_opcode_metadata=get_python_module_dict(_opcode_metadata_py)
@@ -161,9 +162,18 @@ def main(opcode_py,
161162
fobj.write(footer)
162163
iobj.write(internal_footer)
163164

165+
withopen(opcode_targets_h,"w")asf:
166+
targets= ["_unknown_opcode"]*256
167+
forop,nameinenumerate(opname_including_specialized):
168+
ifop<256andnotname.startswith("<"):
169+
targets[op]=f"TARGET_{name}"
170+
171+
f.write("static void *opcode_targets[256] = {\n")
172+
f.write(",\n".join([f" &&{s}"forsintargets]))
173+
f.write("\n};\n")
164174

165175
print(f"{outfile} regenerated from{opcode_py}")
166176

167177

168178
if__name__=='__main__':
169-
main(sys.argv[1],sys.argv[2],sys.argv[3],sys.argv[4])
179+
main(sys.argv[1],sys.argv[2],sys.argv[3],sys.argv[4],sys.argv[5])

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp