Commit bffec89
committed
W22: yield-from pattern-deopt — Alex explicit one-case bypass (C scope)
Replaces the no-op YIELD_FROM-bytecode removal in d25b2f3 with a
correct pattern-deopt for CPython 3.12 'yield from' semantics.
CPython 3.12 desugars 'yield from EXPR' into the SEND-loop sequence
(GET_YIELD_FROM_ITER, SEND, YIELD_VALUE, RESUME 2, JUMP_BACKWARD_NO_
INTERRUPT, END_SEND). The YIELD_FROM bytecode is a stub in 3.12 (see
Python/jit_common/opcode_stubs.h) and never appears in real code, so
removing it from isSupportedOpcode was a no-op (caught by testkeeper +
medic L3076 epistemic-decay catch).
The HIR YieldFrom instruction that triggers W22 is emitted in
builder_emit_c.c:hir_builder_emit_yield_value_c when the YIELD_VALUE
bytecode is followed by RESUME with oparg==2 (RESUME oparg semantics:
0=function-start, 1=after-plain-yield, 2=after-yield-from, 3=after-
await).
This commit:
1. Restores 'case YIELD_FROM:' in isSupportedOpcode (the prior
d25b2f3 removal was based on incorrect bytecode-existence
analysis; the case is dead in 3.12 either way but the misleading
comment is removed).
2. Adds pattern-deopt to checkTranslate: when YIELD_VALUE bytecode
is followed by RESUME oparg==2, throw runtime_error so the
function falls back to the interpreter. This is the EXACT
'yield from' surface — plain yield (RESUME oparg==1) and await
(RESUME oparg==3) remain JIT-compiled.
dis.dis verification (3 fixtures, /tmp/w22_disdis_fixtures.py):
Fixture A yield_from_fn: YIELD_VALUE oparg=2, next=RESUME oparg=2
-> W22 pattern triggers: True (expected)
Fixture B plain_yield_fn: YIELD_VALUE oparg=1, next=RESUME oparg=1
-> W22 pattern triggers: False (expected)
Fixture C await_fn: YIELD_VALUE oparg=2, next=RESUME oparg=3
-> W22 pattern triggers: False (expected)
VERIFICATION: PASS
Author authority bypass per Alex L3076 + gatekeeper L3076 + theologian
L3076 + supervisor L3076 concur on (C) pattern-deopt scope (narrowest
correct option vs (A) deopt-all-yield or (B) deopt-all-SEND). RULE
STANDS for future cases — feedback_no_workarounds.md remains in force.
Refs: medic L3076 epistemic-decay catch (added discipline lesson:
deopt-class commits require dis.dis bytecode-existence verification
before commit).1 parent d25b2f3 commit bffec89
1 file changed
Lines changed: 24 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
262 | 262 | | |
263 | 263 | | |
264 | 264 | | |
| 265 | + | |
265 | 266 | | |
266 | 267 | | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | 268 | | |
276 | 269 | | |
277 | 270 | | |
| |||
4934 | 4927 | | |
4935 | 4928 | | |
4936 | 4929 | | |
| 4930 | + | |
| 4931 | + | |
| 4932 | + | |
| 4933 | + | |
| 4934 | + | |
| 4935 | + | |
| 4936 | + | |
| 4937 | + | |
| 4938 | + | |
| 4939 | + | |
| 4940 | + | |
| 4941 | + | |
| 4942 | + | |
| 4943 | + | |
| 4944 | + | |
| 4945 | + | |
| 4946 | + | |
| 4947 | + | |
| 4948 | + | |
| 4949 | + | |
| 4950 | + | |
| 4951 | + | |
| 4952 | + | |
4937 | 4953 | | |
4938 | 4954 | | |
4939 | 4955 | | |
| |||
0 commit comments