Commit 71782cf
committed
jit: close gh#152 deep-kept operand-stack resume gap (RPython register/liveness channel) (#436)
* majit: route successful-compile trace teardown to abort_trace_live
Four trace-close success edges in JitDriver called abort_trace(false),
which runs both the live history teardown and aborted_tracing accounting.
On a successful compile the accounting must not fire: raise_if_successful()
raises ContinueRunningNormally (pyjitpl.py:3095-3123), bypassing the
`except SwitchToBlackhole` handler that reaches aborted_tracing, and the
loop/bridge counter was already bumped at backend-compile time. Calling
the accounting half here bumped stats.loops_aborted on success and
double-counted the re-observe edge.
Change the four success edges (CompileTrace arm, the bridge Compiled
close, the CloseLoopWithArgs bridge Compiled close, and the
take_compile_trace_success re-observe) to abort_trace_live(false) so only
the live teardown runs. loops_aborted now reads 0 on nbody/fannkuch/
spectral_norm/nested_loop; loops_compiled, bridges_compiled, and
guard_failures are unchanged.
Assisted-by: Claude
* synth: correct mutation-count comment in kept_stack_deep_var_shortcircuit_mutate
The loop appends three times per iteration (g, h, and one conditional
g/h), so len(log) for f(40000) is 120000, not the 80000 the "2 mutations
per iteration" comment implied. State the 3x invariant.
Assisted-by: Claude
* jit: deep-kept operand-stack resume via register/liveness channel; delete FOR_ITER hazard gate
Restore deep kept operand-stack slots at a branch-guard resume from the
guard-PC register file instead of the pop-cleared vable positional shadow,
porting get_list_of_active_boxes (rpython/jit/metainterp/pyjitpl.py:177-234),
which captures resume boxes from registers_r[index] via the per-PC -live- set.
In walker_capture_snapshot_for_last_guard_impl (jitcode_dispatch.rs), a kept
operand slot the walk mirror (ctx.vstack_boxes) leaves NULL across a not-taken
branch merge is recovered from ctx.registers_r[color], where color is the
pcdep_color_slots[guard_py_pc] inverse (new state::semantic_slot_color_for_ref_slot).
The recovery is capture-only (transient snapshot overlay, never the live shadow)
and fills only Type::Ref slots; an unboxed-int kept temp is left a hole.
Delete the foriter_deep_kept_call_hazard gate (codewriter.rs) that withheld the
FOR_ITER per-iteration getarrayitem_vable_r reload for loop bodies with a CALL
across an in-body conditional branch. The reload is now unconditional for
portals, matching w_iterator = self.peekvalue() (pypy/interpreter/pyopcode.py:1303).
kept_stack_deep_var_{condexpr,nested_call,shortcircuit} and the shortcircuit
mutate canary run resident without the deep-guard SIGSEGV; check.py 155/155 on
dynasm and cranelift.
Assisted-by: Claude
* jit: rustfmt the FOR_ITER iterator-reload block
Reformat the `iter_value` binding after the `foriter_deep_kept_call_hazard`
gate removal collapsed the condition to a single `if is_portal`. No logic
change; `cargo fmt --check` clean.
Assisted-by: Claude
* majit: clear pending_abort payload on successful trace teardown
The four successful-compile teardown edges (CompileTrace, both bridge-Compiled
paths, and the re-observed-success path) call abort_trace_live(false) for live
cleanup but fire no aborted_tracing, so the pending_abort_green_key/permanent
that abort_trace_live stages was never consumed. A later unrelated abort would
then take() that stale key and fire on_trace_abort for the earlier
successfully-compiled greenkey.
Add MetaInterp::clear_pending_abort() and call it on each success edge, matching
the existing bridge-FINISH success path (pyjitpl.rs) which already cleared these
fields inline for the same reason. No aborted_tracing follows on success
(raise_if_successful raises ContinueRunningNormally, pyjitpl.py:3095-3123).
check.py 155/155 dynasm and cranelift; aborted_tracing tests pass.
Assisted-by: Claude
* interp: type(x) one-arg __init__ skip + null-mro subtype base-chain fallback
type.__call__ suppresses __init__ when self is the `type` builtin with no
keyword arguments and exactly one positional argument (type(x) returns the
class of x from __new__). Add `type_call_type_x_shortcut` and gate the three
plain-instantiation __init__ dispatch sites in call.rs on it
(typeobject.py:735-736).
w_type_issubtype falls back to a find_best_base base-chain walk when mro_w is
null instead of returning false, matching _issubtype_slow_and_wrong for a
partially initialised type (typeobject.py:1640-1655, find_best_base
1335-1354; the "incomplete type" raise is omitted since the fn returns bool).
Assisted-by: Claude
* jit: deep-kept Int-bank recovery channel (PYRE_FBW_DEEPKEPT_INT, default OFF)
Port the i-bank half of get_list_of_active_boxes (pyjitpl.py:206-210,
add_box_to_storage(registers_i[index])) to the deep-kept operand-stack
recovery in walker_capture_snapshot_for_last_guard_impl. A bank-0 (Int) stack
pcdep entry names the Int-bank color owning the slot; registers_i[color] holds
the raw int, boxed into a W_IntObject via wrapint so the uniformly Ref-typed
vable array carries a Ref.
Generalize semantic_slot_color_for_ref_slot into a bank-generic
semantic_slot_color_for_slot core; add semantic_slot_color_for_int_slot
(bank=0) alongside the ref (bank=1) delegate.
Gated default-OFF: flag-off is byte-identical to leaving the int a hole
(resume re-materializes it from its defining IR). On the current frontend the
operand stack is uniformly Ref-banked so no bank-0 stack entry exists and the
block fires nowhere; the real int-hole (a Ref-bank color whose OpRef is
Int-typed) cannot be boxed at capture time — wrapint emits into a settled
trace and trips store_final_boxes_in_guard (resume.py:397) — so it must be
synthesized at operand-stack push time, a frontend change tracked separately.
This is the RPython-parity read channel for when bank-0 stack entries exist.
Assisted-by: Claude1 parent b7b559b commit 71782cf
8 files changed
Lines changed: 366 additions & 111 deletions
File tree
- majit/majit-metainterp/src
- pyre
- bench/synth
- pyre-interpreter/src
- pyre-jit-trace/src
- pyre-jit/src/jit
- pyre-object/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1783 | 1783 | | |
1784 | 1784 | | |
1785 | 1785 | | |
1786 | | - | |
| 1786 | + | |
| 1787 | + | |
| 1788 | + | |
| 1789 | + | |
| 1790 | + | |
| 1791 | + | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
1787 | 1798 | | |
1788 | 1799 | | |
1789 | 1800 | | |
| |||
1906 | 1917 | | |
1907 | 1918 | | |
1908 | 1919 | | |
1909 | | - | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
1910 | 1925 | | |
1911 | 1926 | | |
1912 | 1927 | | |
| |||
2060 | 2075 | | |
2061 | 2076 | | |
2062 | 2077 | | |
2063 | | - | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
2064 | 2083 | | |
2065 | 2084 | | |
2066 | 2085 | | |
| |||
2440 | 2459 | | |
2441 | 2460 | | |
2442 | 2461 | | |
2443 | | - | |
| 2462 | + | |
| 2463 | + | |
| 2464 | + | |
| 2465 | + | |
| 2466 | + | |
| 2467 | + | |
2444 | 2468 | | |
2445 | 2469 | | |
2446 | 2470 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6982 | 6982 | | |
6983 | 6983 | | |
6984 | 6984 | | |
| 6985 | + | |
| 6986 | + | |
| 6987 | + | |
| 6988 | + | |
| 6989 | + | |
| 6990 | + | |
| 6991 | + | |
| 6992 | + | |
| 6993 | + | |
| 6994 | + | |
| 6995 | + | |
| 6996 | + | |
| 6997 | + | |
| 6998 | + | |
6985 | 6999 | | |
6986 | 7000 | | |
6987 | 7001 | | |
| |||
12575 | 12589 | | |
12576 | 12590 | | |
12577 | 12591 | | |
12578 | | - | |
12579 | | - | |
| 12592 | + | |
12580 | 12593 | | |
12581 | 12594 | | |
12582 | 12595 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2041 | 2041 | | |
2042 | 2042 | | |
2043 | 2043 | | |
2044 | | - | |
2045 | | - | |
| 2044 | + | |
| 2045 | + | |
| 2046 | + | |
2046 | 2047 | | |
2047 | | - | |
2048 | | - | |
2049 | | - | |
2050 | | - | |
2051 | | - | |
2052 | | - | |
2053 | | - | |
2054 | | - | |
2055 | | - | |
2056 | | - | |
2057 | | - | |
| 2048 | + | |
| 2049 | + | |
| 2050 | + | |
| 2051 | + | |
| 2052 | + | |
| 2053 | + | |
| 2054 | + | |
| 2055 | + | |
| 2056 | + | |
| 2057 | + | |
2058 | 2058 | | |
2059 | 2059 | | |
2060 | 2060 | | |
| |||
2363 | 2363 | | |
2364 | 2364 | | |
2365 | 2365 | | |
2366 | | - | |
| 2366 | + | |
| 2367 | + | |
| 2368 | + | |
2367 | 2369 | | |
2368 | 2370 | | |
2369 | 2371 | | |
| |||
2415 | 2417 | | |
2416 | 2418 | | |
2417 | 2419 | | |
| 2420 | + | |
| 2421 | + | |
| 2422 | + | |
| 2423 | + | |
| 2424 | + | |
| 2425 | + | |
| 2426 | + | |
| 2427 | + | |
2418 | 2428 | | |
2419 | 2429 | | |
2420 | 2430 | | |
| |||
3627 | 3637 | | |
3628 | 3638 | | |
3629 | 3639 | | |
3630 | | - | |
| 3640 | + | |
| 3641 | + | |
| 3642 | + | |
3631 | 3643 | | |
3632 | 3644 | | |
3633 | 3645 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7329 | 7329 | | |
7330 | 7330 | | |
7331 | 7331 | | |
| 7332 | + | |
| 7333 | + | |
| 7334 | + | |
| 7335 | + | |
| 7336 | + | |
| 7337 | + | |
| 7338 | + | |
| 7339 | + | |
| 7340 | + | |
| 7341 | + | |
| 7342 | + | |
| 7343 | + | |
| 7344 | + | |
| 7345 | + | |
| 7346 | + | |
| 7347 | + | |
| 7348 | + | |
| 7349 | + | |
| 7350 | + | |
| 7351 | + | |
| 7352 | + | |
| 7353 | + | |
7332 | 7354 | | |
7333 | 7355 | | |
7334 | 7356 | | |
| |||
10166 | 10188 | | |
10167 | 10189 | | |
10168 | 10190 | | |
| 10191 | + | |
| 10192 | + | |
| 10193 | + | |
| 10194 | + | |
| 10195 | + | |
| 10196 | + | |
| 10197 | + | |
| 10198 | + | |
| 10199 | + | |
| 10200 | + | |
| 10201 | + | |
| 10202 | + | |
| 10203 | + | |
| 10204 | + | |
| 10205 | + | |
| 10206 | + | |
| 10207 | + | |
| 10208 | + | |
| 10209 | + | |
| 10210 | + | |
| 10211 | + | |
| 10212 | + | |
| 10213 | + | |
| 10214 | + | |
| 10215 | + | |
| 10216 | + | |
| 10217 | + | |
| 10218 | + | |
| 10219 | + | |
| 10220 | + | |
| 10221 | + | |
| 10222 | + | |
| 10223 | + | |
| 10224 | + | |
| 10225 | + | |
| 10226 | + | |
| 10227 | + | |
| 10228 | + | |
| 10229 | + | |
| 10230 | + | |
| 10231 | + | |
| 10232 | + | |
| 10233 | + | |
| 10234 | + | |
| 10235 | + | |
| 10236 | + | |
| 10237 | + | |
| 10238 | + | |
| 10239 | + | |
| 10240 | + | |
| 10241 | + | |
| 10242 | + | |
| 10243 | + | |
| 10244 | + | |
| 10245 | + | |
| 10246 | + | |
| 10247 | + | |
| 10248 | + | |
| 10249 | + | |
| 10250 | + | |
| 10251 | + | |
| 10252 | + | |
| 10253 | + | |
| 10254 | + | |
| 10255 | + | |
| 10256 | + | |
| 10257 | + | |
| 10258 | + | |
| 10259 | + | |
| 10260 | + | |
| 10261 | + | |
| 10262 | + | |
| 10263 | + | |
| 10264 | + | |
| 10265 | + | |
| 10266 | + | |
| 10267 | + | |
| 10268 | + | |
| 10269 | + | |
| 10270 | + | |
| 10271 | + | |
| 10272 | + | |
| 10273 | + | |
| 10274 | + | |
| 10275 | + | |
| 10276 | + | |
| 10277 | + | |
| 10278 | + | |
| 10279 | + | |
| 10280 | + | |
| 10281 | + | |
| 10282 | + | |
| 10283 | + | |
| 10284 | + | |
| 10285 | + | |
| 10286 | + | |
| 10287 | + | |
| 10288 | + | |
| 10289 | + | |
| 10290 | + | |
| 10291 | + | |
| 10292 | + | |
| 10293 | + | |
| 10294 | + | |
| 10295 | + | |
| 10296 | + | |
| 10297 | + | |
| 10298 | + | |
| 10299 | + | |
| 10300 | + | |
| 10301 | + | |
| 10302 | + | |
| 10303 | + | |
| 10304 | + | |
| 10305 | + | |
| 10306 | + | |
| 10307 | + | |
| 10308 | + | |
| 10309 | + | |
| 10310 | + | |
| 10311 | + | |
| 10312 | + | |
| 10313 | + | |
| 10314 | + | |
| 10315 | + | |
| 10316 | + | |
| 10317 | + | |
| 10318 | + | |
| 10319 | + | |
| 10320 | + | |
| 10321 | + | |
| 10322 | + | |
| 10323 | + | |
| 10324 | + | |
| 10325 | + | |
| 10326 | + | |
| 10327 | + | |
| 10328 | + | |
| 10329 | + | |
10169 | 10330 | | |
10170 | 10331 | | |
10171 | 10332 | | |
| |||
0 commit comments