You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
port comprehension inlining to Python/compile.c also
Summary:
Original comprehension inlining diff from 3.8: D28940584 (03040db)
In D39216342 we ported comprehension inlining only to the py-compiler.
Since then we've discovered that py-compiler is in practice still used only for strict
and static modules, so we should port valuable optimizations to `compile.c` also.
This ports comprehension inlining to `compile.c` as well.
Ensure that we run the comprehension-inliner tests against both py-compiler
and compile.c.
Also requires moving the implementation in py-compiler from
`CinderCodeGenerator` up to the base class `CinderBaseCodeGenerator`, since
side-by-side comparison testing betweeen py-compiler and compile.c uses
`CinderBaseCodeGenerator`.
In 3.8 there was a difference in behavior between py-compiler and compile.c on
the two `nested_diff_scopes` inlining tests. This difference was not caught in 3.8
because the inlining tests only ran against `compile.c`, and the tested case did
not occur in the corpus for side-by-side testing. In porting inlining to py-compiler
in 3.10, we switched the inlining tests to run against py-compiler, and adjusted the
two `nested_diff_scopes` tests accordingly; this resulted in adding
`DELETE_DEREF` opcodes in those two tests that weren't present in those tests
in 3.8. In this diff I remove those opcodes again and adjust the py-compiler
implementation so that they aren't emitted.
In actual fact neither the presence nor absence of those `DELETE_DEREF`
opcodes is correct. It's not safe to inline a comprehension with cell vars at all,
so in the two `nested_diff_scopes` tests we should not be inlining the
comprehension with the lambda at all. I will make this change as a separate
bugfix in 3.8 and port it separately to 3.10.
Reviewed By: tekknolagi
Differential Revision: D40656285
fbshipit-source-id: 405d3fe
0 commit comments