Skip to content

Commit 6afe66c

Browse files
DinoVfacebook-github-bot
authored andcommitted
Create new block for final instructions inserted into a lambda
Summary: CPython will usually insert a `LOAD_CONST`/`RETURN_VALUE` at the end of a lambda, and then this will get optimized away. This has a side effect of leaving a `None` const on the lambda. We emit it in the same block currently which can prevent some other optimizations because we'll see the return block as being too large. Reviewed By: jbower-fb Differential Revision: D81977406 fbshipit-source-id: e6cccd87799330b3d65534f9ed6ed5c4c13b6b23
1 parent 0b8c532 commit 6afe66c

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

cinderx/PythonLib/cinderx/compiler/pycodegen.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4547,6 +4547,7 @@ def generate_function_with_body(
45474547
else:
45484548
gen.set_pos(SrcLocation(node.lineno, node.lineno or 0, 0, 0))
45494549
gen.emit("RETURN_VALUE")
4550+
gen.nextBlock()
45504551
gen.finish_function()
45514552
else:
45524553
if isinstance(node, ast.Lambda):
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
lambda oparg, jmp: ((
2+
2 if oparg[0] in ("1", "2") else 1
3+
)
4+
- 3)

0 commit comments

Comments
 (0)