Commit 654f1af
committed
jit: admit a call-bearing LIST_APPEND body in a FOR_ITER loop
`for_iter_body_is_jit_safe_at` admitted an inlined comprehension's
`LIST_APPEND` only when a preceding scan found no CALL anywhere in the body.
The scan's premise was that a compiled loop's live-at-exit values stay
reachable from the exit state, so a per-element call leaves a freshly
constructed object rooted past the `STORE_FAST` that unbinds the comprehension
slot, and `extra_tests/parity_tests/weakref_gc_lifeline.py` would see the last
element outlive the collection that should have run its weakref callback.
`SET_ADD` and `MAP_ADD` -- the set and dict comprehension accumulators, which
fill the same fresh container from the same per-element expression -- never
carried the scan. `{Target(i) for i in range(2000)}` and
`{i: Target(i) for i in range(2000)}` therefore already compiled, and each
reports 2000 of 2000 weakref callbacks with nothing left alive. The shape the
scan declined was reachable through two sibling opcodes all along and does not
retain, so the term was asymmetric rather than protective. Removing it makes
the scan dead, and it goes with it.
Direct measurement agrees. `PYRE_FOR_ITER_GATE_DIAG` names the two
comprehensions `weakref_gc_lifeline.py` builds -- `[Target() ...]` and
`[weakref.ref(target, callback) ...]`, 2000 elements each -- as that file's only
declines; with the term gone both compile and the file still passes, every
referent's callback running in the collection that drops it. All 127 parity
scripts pass on dynasm and on cranelift under `--gc-poison`, which fills
reclaimed nursery bytes so a dangling read aborts instead of decoding as a
plausible object.
Four fixtures' baselines move, identically on dynasm and cranelift:
`list_to_tuple_star` compiles its loop at all (`loops_compiled 0 -> 1`),
`mapdict_frozen_unboxing_fold` reaches `guard_failures 2 -> 11`,
`list_append_virtual_payload` `bridges_compiled 4 -> 7` and
`guard_failures 1001 -> 1403`, and `surrogate_class_kwargs`
`bridges_compiled 0 -> 1`, `loops_aborted 0 -> 1`, `guard_failures 0 -> 2658`.
The last one's abort is `abrt_bridge`, one aborted bridge attempt: pypy3 on the
same fixture compiles 14 loops and 9 bridges and aborts 4 times, against pyre's
3, 1 and 1, so the movement is toward the oracle with a wide margin left.
`list_to_tuple_star`'s header gave `loops_compiled=0` as its reason for carrying
no `max-pypy-ratio`, which no longer holds; it now gives the reason that does.
Assisted-by: Claude1 parent 388d7e8 commit 654f1af
14 files changed
Lines changed: 52 additions & 81 deletions
File tree
- pyre
- bench/synth
- pyre-jit/src
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
0 commit comments