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

Commit6e8128f

Browse files
authored
bpo-41323: Perform 'peephole' optimizations directly on the CFG. (GH-21517)
* Move 'peephole' optimizations into compile.c and perform them directly on the CFG.
1 parentba18c0b commit6e8128f

File tree

12 files changed

+4358
-4577
lines changed

12 files changed

+4358
-4577
lines changed

‎Lib/test/test_dis.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,6 @@ def _tryfinallyconst(b):
360360
16 CALL_FUNCTION 0
361361
18 POP_TOP
362362
20 RERAISE
363-
22 LOAD_CONST 0 (None)
364-
24 RETURN_VALUE
365363
"""% (_tryfinally.__code__.co_firstlineno+1,
366364
_tryfinally.__code__.co_firstlineno+2,
367365
_tryfinally.__code__.co_firstlineno+4,
@@ -385,8 +383,6 @@ def _tryfinallyconst(b):
385383
16 CALL_FUNCTION 0
386384
18 POP_TOP
387385
20 RERAISE
388-
22 LOAD_CONST 0 (None)
389-
24 RETURN_VALUE
390386
"""% (_tryfinallyconst.__code__.co_firstlineno+1,
391387
_tryfinallyconst.__code__.co_firstlineno+2,
392388
_tryfinallyconst.__code__.co_firstlineno+4,

‎Lib/test/test_peepholer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,9 +416,9 @@ def f(cond1, cond2):
416416
ifcond1:return4
417417
self.assertNotInBytecode(f,'JUMP_FORWARD')
418418
# There should be one jump for the while loop.
419-
returns= [instrforinstrindis.get_instructions(f)
420-
ifinstr.opname=='JUMP_ABSOLUTE']
421-
self.assertEqual(len(returns),1)
419+
jumps= [instrforinstrindis.get_instructions(f)
420+
if'JUMP'ininstr.opname]
421+
self.assertEqual(len(jumps),1)
422422
returns= [instrforinstrindis.get_instructions(f)
423423
ifinstr.opname=='RETURN_VALUE']
424424
self.assertLessEqual(len(returns),2)

‎Lib/test/test_sys_settrace.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,7 @@ def test_jump_in_nested_finally_3(output):
948948
output.append(11)
949949
output.append(12)
950950

951-
@jump_test(5,11, [2,4], (ValueError,'unreachable'))
951+
@jump_test(5,11, [2,4], (ValueError,'after'))
952952
deftest_no_jump_over_return_try_finally_in_finally_block(output):
953953
try:
954954
output.append(2)
@@ -1457,7 +1457,7 @@ async def test_jump_between_async_with_blocks(output):
14571457
asyncwithasynctracecontext(output,4):
14581458
output.append(5)
14591459

1460-
@jump_test(5,7, [2,4], (ValueError,"unreachable"))
1460+
@jump_test(5,7, [2,4], (ValueError,"after"))
14611461
deftest_no_jump_over_return_out_of_finally_block(output):
14621462
try:
14631463
output.append(2)

‎Makefile.pre.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,6 @@ PYTHON_OBJS=\
354354
Python/mysnprintf.o \
355355
Python/mystrtoul.o \
356356
Python/pathconfig.o \
357-
Python/peephole.o \
358357
Python/preconfig.o \
359358
Python/pyarena.o \
360359
Python/pyctype.o \
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Bytecode optimizations are performed directly on the control flow graph.
2+
This will result in slightly more compact code objects in some
3+
circumstances.

‎PCbuild/pythoncore.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,6 @@
460460
<ClCompileInclude="..\Python\mysnprintf.c" />
461461
<ClCompileInclude="..\Python\mystrtoul.c" />
462462
<ClCompileInclude="..\Python\pathconfig.c" />
463-
<ClCompileInclude="..\Python\peephole.c" />
464463
<ClCompileInclude="..\Python\preconfig.c" />
465464
<ClCompileInclude="..\Python\pyarena.c" />
466465
<ClCompileInclude="..\Python\pyctype.c" />

‎PCbuild/pythoncore.vcxproj.filters

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,9 +1028,6 @@
10281028
<ClCompileInclude="..\Python\pathconfig.c">
10291029
<Filter>Python</Filter>
10301030
</ClCompile>
1031-
<ClCompileInclude="..\Python\peephole.c">
1032-
<Filter>Python</Filter>
1033-
</ClCompile>
10341031
<ClCompileInclude="..\Python\preconfig.c">
10351032
<Filter>Python</Filter>
10361033
</ClCompile>
@@ -1184,4 +1181,4 @@
11841181
<Filter>Resource Files</Filter>
11851182
</ResourceCompile>
11861183
</ItemGroup>
1187-
</Project>
1184+
</Project>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp