Skip to content

Commit 3e2aa02

Browse files
authored
jit: restore recursive unroll state transitions (#1176)
* jit: restore recursive unroll state transitions * wasm: keep recursive bridges compiled
1 parent 0d83827 commit 3e2aa02

35 files changed

Lines changed: 139 additions & 103 deletions

File tree

‎majit/majit-backend-wasm/src/lib.rs‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,17 @@ fn diag_bump(i: usize) {
100100
// A source token is compiled before a later guard may become a CA bridge.
101101
// Freeze modest room for that bridge at first compilation; a later trace that
102102
// exceeds either bound is declined rather than changing the live frame's
103-
// offsets. The fib CA path measured raw maxima of 9 positional slots and 15
104-
// Ref homes, but that is not a bridge fail-arg census for the full suite; keep
105-
// both existing floors until such a census establishes smaller safe bounds.
103+
// offsets. The recursive-unroll fib CA bridge needs more than 64 Ref homes:
104+
// declining it leaves the recursive return guard permanently blackholed and
105+
// turns every later invocation into a host round-trip. Keep enough bounded
106+
// per-token reserve for that bridge and the existing full-suite shapes.
106107
// A CALL_ASSEMBLER target must retain enough frozen spill/home geometry for a
107108
// later exit bridge. nbody's callee bridge needs more Ref homes than the old
108109
// 16-slot floor; declining it turns every CA invocation into a blackhole. The
109110
// larger fixed reserve keeps the bridge in compiled wasm and is still bounded
110111
// per compiled token.
111112
const FROZEN_CHAIN_VALUE_SLOTS: usize = 64;
112-
const FROZEN_CHAIN_REF_HOMES: usize = 64;
113+
const FROZEN_CHAIN_REF_HOMES: usize = 128;
113114

114115
/// An op whose result advances loop-carried state. A value produced inside the
115116
/// re-running region by arithmetic or by a heap load is fresh on each pass, so

‎majit/majit-metainterp/src/pyjitpl.rs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13831,11 +13831,11 @@ impl<M: Clone> MetaInterp<M> {
1383113831

1383213832
// pyjitpl.py:1404 `dont_trace_here(greenboxes)` — the only `&mut`,
1383313833
// flagged by `decide_recursive_inline` when recursion reached
13834-
// `max_unroll_recursion`. This is the ONLY place the recursion bound
13835-
// applies it: pyre's FBW walker bounds self-recursive inlining with
13836-
// its own counter (`pyre-jit-trace` `jitcode_dispatch::inline_call`,
13837-
// against `FBW_MAX_INLINE_RECURSION`) and applies no side effect
13838-
// there, so do not read this comment as "the tracer does it too".
13834+
// `max_unroll_recursion`. The production FBW walker mirrors both the
13835+
// counter and this side effect in
13836+
// `pyre-jit-trace/jitcode_dispatch/inline_call.rs`; keeping the state
13837+
// transition on both tracing paths prevents sibling branches from
13838+
// restarting recursive unrolling after the first bound hit.
1383913839
if should_disable {
1384013840
self.warm_state.disable_noninlinable_function(callee_key);
1384113841
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
bridges_compiled=3
1+
bridges_compiled=8
22
descr_set_absent=0
33
descr_set_ambiguous=0
44
descr_set_stale_absent=0
@@ -8,7 +8,7 @@ fbw_rolled_back_with_effects=0
88
fbw_store_journal_rollback_failed=0
99
field_pos_attached_misplaced=0
1010
field_pos_spec_misplaced=0
11-
guard_failures=406
11+
guard_failures=1645
1212
internal_compile_panics=0
1313
loops_aborted=0
1414
loops_compiled=1
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
bridges_compiled=3
1+
bridges_compiled=8
22
descr_set_absent=0
33
descr_set_ambiguous=0
44
descr_set_stale_absent=0
@@ -8,7 +8,7 @@ fbw_rolled_back_with_effects=0
88
fbw_store_journal_rollback_failed=0
99
field_pos_attached_misplaced=0
1010
field_pos_spec_misplaced=0
11-
guard_failures=406
11+
guard_failures=1645
1212
internal_compile_panics=0
1313
loops_aborted=0
1414
loops_compiled=1
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
bridges_compiled=3
1+
bridges_compiled=8
22
descr_set_absent=0
33
descr_set_ambiguous=0
44
descr_set_stale_absent=0
@@ -8,7 +8,8 @@ fbw_rolled_back_with_effects=0
88
fbw_store_journal_rollback_failed=0
99
field_pos_attached_misplaced=0
1010
field_pos_spec_misplaced=0
11-
guard_failures=406
11+
guard_failures=1645
1212
internal_compile_panics=0
1313
loops_aborted=0
1414
loops_compiled=1
15+
retraces_compiled=0

‎pyre/bench/synth/bound_method_builtin_fold.wasm.jitstats‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ fbw_rolled_back_with_effects=0
88
fbw_store_journal_rollback_failed=0
99
field_pos_attached_misplaced=0
1010
field_pos_spec_misplaced=0
11-
guard_failures=459
11+
guard_failures=458
1212
internal_compile_panics=0
1313
loops_aborted=0
1414
loops_compiled=7
15+
retraces_compiled=0
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
bridges_compiled=3
1+
bridges_compiled=4
22
descr_set_absent=0
33
descr_set_ambiguous=0
44
descr_set_stale_absent=0
@@ -8,7 +8,7 @@ fbw_rolled_back_with_effects=0
88
fbw_store_journal_rollback_failed=0
99
field_pos_attached_misplaced=0
1010
field_pos_spec_misplaced=0
11-
guard_failures=798
11+
guard_failures=962
1212
internal_compile_panics=0
1313
loops_aborted=0
1414
loops_compiled=1
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
bridges_compiled=3
1+
bridges_compiled=4
22
descr_set_absent=0
33
descr_set_ambiguous=0
44
descr_set_stale_absent=0
@@ -8,7 +8,7 @@ fbw_rolled_back_with_effects=0
88
fbw_store_journal_rollback_failed=0
99
field_pos_attached_misplaced=0
1010
field_pos_spec_misplaced=0
11-
guard_failures=798
11+
guard_failures=962
1212
internal_compile_panics=0
1313
loops_aborted=0
1414
loops_compiled=1
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
bridges_compiled=3
1+
bridges_compiled=4
22
descr_set_absent=0
33
descr_set_ambiguous=0
44
descr_set_stale_absent=0
@@ -8,7 +8,7 @@ fbw_rolled_back_with_effects=0
88
fbw_store_journal_rollback_failed=0
99
field_pos_attached_misplaced=0
1010
field_pos_spec_misplaced=0
11-
guard_failures=798
11+
guard_failures=962
1212
internal_compile_panics=0
1313
loops_aborted=0
1414
loops_compiled=1
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
bridges_compiled=16
1+
bridges_compiled=24
22
descr_set_absent=0
33
descr_set_ambiguous=0
44
descr_set_stale_absent=0
@@ -8,7 +8,7 @@ fbw_rolled_back_with_effects=0
88
fbw_store_journal_rollback_failed=0
99
field_pos_attached_misplaced=0
1010
field_pos_spec_misplaced=0
11-
guard_failures=2592
11+
guard_failures=3437
1212
internal_compile_panics=0
1313
loops_aborted=0
1414
loops_compiled=3

0 commit comments

Comments
 (0)