Commit 8c87851
authored
jit, interp: inline bound methods and defaults, specialize builtin calls, and fold the per-opcode polls into the eval breaker word (#878)
* build: enable thin LTO and codegen-units=1 for the release profile
`cargo run --release` gets the same cross-crate optimization the `dist`
profile already inherits.
Assisted-by: Claude
* interp: enter apply_all_thread_hooks only when a hook generation changed
`all_thread_hooks_current` compares the execution context's
`trace_all_generation` / `profile_all_generation` against the process
counters, and `bytecode_trace` calls the updater only when they differ.
`bytecode_trace` and `bytecode_only_trace` become `#[inline(always)]`.
Assisted-by: Claude
* interp: unwrap Method in the CALL Function valuestack fast path
baseobjspace.py:1254-1259 unwraps `_Method` before the Function
valuestack path. The CALL handler now writes the receiver into the
`null_or_self` stack slot, continues with `w_function`, and passes
`methodcall` to `funccall_valuestack` with the receiver counted as one
extra argument (callmethod.py:85-94) while the popped width stays the
physical `[callable, null_or_self, args...]`.
Assisted-by: Claude
* jit: require PYRE_JD1=1 for the jd1 unpackiterable driver
jd1 shares the `MetaInterp.tracing` slot with the bytecode portal, so
while a residual `next()` runs a generator body the jd1 trace holds only
the opaque call and every jd0 merge point that body reaches is
suppressed. Restore the opt-in gate; the master JIT off-switches still
apply.
Assisted-by: Claude
* jit: read gc_interp::enabled once per eval_loop_jit activation
The flag is process-stable after its first env read, so hoist it out of
the per-bytecode safepoint poll instead of crossing the
`dont_look_inside` gate and reloading its atomic on every iteration.
Assisted-by: Claude
* jit: cache the unsupported_jit_shape classification per code object
`CallControl.graph_jit_shapes` holds the `UnsupportedJitShape`
discriminant keyed by code-object address, alongside the graph-keyed
`jitcodes`. `eval_with_jit_inner` classifies through the cache, and
`maybe_compile_and_run` and `try_function_entry_jit` drop their repeated
whole-frame scans, which ran on every back-edge and every Python call.
Assisted-by: Claude
* jit: specialize type(), dict.get(), int(), math.frexp and math.ldexp
`register_jit_builtin_wrappers` records the `py_checked_arity_fn!`
wrapper pointer each BuiltinCode actually stores for `math.sqrt`,
`math.frexp` and `math.ldexp`; `is_math_sqrt_function` moves onto that
comparison and `is_math_frexp_function` / `is_math_ldexp_function` join
it. `jit_math_frexp_mantissa`, `jit_math_frexp_exponent` and
`jit_math_ldexp_raw` are the raw entry points behind the emitted pure
calls.
`try_walker_specialize_builtin_type` lowers `space.type(w_obj)`.
`try_walker_specialize_builtin_dict_get` guards the new
`W_DictObject.keys_version` descriptor and reads the resolved entry
value through `jit_dict_nth_value`. `try_walker_specialize_int_call`,
`try_walker_specialize_math_frexp` and `try_walker_specialize_math_ldexp`
join them in `dispatch_residual_call_iRd_kind`.
Assisted-by: Claude
* jit: inline bound-method calls and positional defaults in the walker
`try_walker_inline_user_call` unwraps a `_Method` callable
(baseobjspace.py:1254-1259), guards the Method class and its
`w_function`, and passes the live `w_self` field as the receiver
argument instead of baking one anchor's receiver.
`try_walker_inline_resolved_user_call` fills a missing positional tail
from `Function.defs_w` (function.py:188-193,217-231) behind a
`GuardValue` on the new live `defs_w` descriptor, then reads each
default out of the pinned tuple's `wrappeditems`. Method-form keyword
calls prepend the receiver before the `kwnames` permutation.
The blanket `POP_JUMP_IF_{NOT_}NONE` callee rejection is removed;
`requires_seeded_callee_frame` declines instead when the callee frame is
not actually seeded.
`fbw_callee_body_replay_safety` takes per-parameter `ExactNumericArg`
provenance and tracks the exact-numeric and exact-int facts separately
per register and per frame slot, so
`residual_call_is_specialized_plain_numeric_binop` judges the actual
operands of each binop; `residual_call_is_specialized_plain_int_binop`
supplies the bitwise-result fact.
Assisted-by: Claude
* Optimize translated JIT builtin call paths
* majit: restrict the niche Option pointer fold to mutable references
`tyref_is_niche_option_ptr` folded `Discriminant` to a pointer null test for
`Option<&T>` as well as `Option<&mut T>` and `Option<NonNull<T>>`.
`Option<&T>` is the `Iterator::next` result shape, and `front::iter_next`
recognizes that call by its `__discriminant` match diamond; with the
discriminant folded there is no diamond left to rewrite, so the residual
`Iterator::next()` survives as the unregistered callee the rewrite removes.
`type_node_is_ref` becomes `type_node_is_mut_ref` and reads the kind field of
the Charon `{"Ref": [region, ty, kind]}` node instead of accepting any `Ref`.
Fixes tests/test_iter_next.rs branch_loop_sum_lifts_next_to_iter_next_op and
tests/test_desugar_mir.rs lowers_desugar_mix_with_aggregate_and_question_mark.
Assisted-by: Claude
* jit: restore two walker inline-call declines
`try_walker_inline_resolved_user_call` declines again on:
- a method-form callee whose body `method_form_callee_body_supported`
rejects. The `requires_seeded_callee_frame` exemption is removed
(synth/float_subclass_binop_dispatch, synth/polymorphic_binary_receiver).
- a `Dirty` replay-safety body. Its residual can raise, and the local
`except` that catches it is a callee-owned catch edge the inline path does
not compile, so the exception escapes the caller instead of being handled
where the source handles it (synth/bool_dunder_error_no_leak,
synth/pickle_ctor_args).
With `Dirty` rejected, `requires_seeded_callee_frame` is always false; it and
the three branches it guarded are removed.
Assisted-by: Claude
* jit: roll the builtin-wrapper descent back instead of aborting the trace
`try_walker_inline_builtin_call` propagated
`OrthodoxSubWalkTraceUnsupported` out of its sub-walk with `?`.
`try_execute_residual_call_via_executor` raises that error before running the
call, and this walk is the authoritative executor, so the aborted trace
resumed past a Python CALL whose effect never happened:
`collections.deque.popleft()` returned its value and left the element in the
deque (synth/gc_deque_backing_list grow_each_round 2966 -> 987234, one
`popleft` dropped per trace transition).
The descent now cuts the trace back to the position recorded before its first
emitted op, resets the heap cache and returns `Ok(None)` so the ordinary
residual call runs — the rollback `orthodox_list_append_commit`'s callers
already use. It is gated on the descent having executed no journaled or
unjournaled effect, since a descent that applied one cannot be rewound this
way and keeps the abort.
Assisted-by: Claude
* fix(translator): decode current Charon const generics
* fix(jit): preserve generated call frame semantics
* fix(jit): rebuild materialized inline frames in bridges
* perf(jit): cache bytecode dump configuration
* fix(jit): preserve frontend guard source indices
* fix(jit): bound nested-break hazard to inner loop1 parent 6efa1e2 commit 8c87851
41 files changed
Lines changed: 3547 additions & 327 deletions
File tree
- majit
- majit-gc/src
- majit-ir/src
- majit-metainterp/src
- majit-translate/src
- codewriter
- front
- translator/rtyper
- pyre
- pyre-interpreter/src
- module
- _random
- math
- thread
- pyre-jit-trace
- src
- jitcode_dispatch
- pyre-jit/src
- jit
- pyre-macros/src
- pyre-object/src
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
180 | 180 | | |
181 | 181 | | |
182 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
183 | 191 | | |
184 | 192 | | |
185 | 193 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
117 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
118 | 122 | | |
119 | 123 | | |
120 | | - | |
121 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
122 | 129 | | |
123 | 130 | | |
124 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
8 | 14 | | |
9 | 15 | | |
10 | 16 | | |
| |||
24 | 30 | | |
25 | 31 | | |
26 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
27 | 39 | | |
28 | 40 | | |
29 | 41 | | |
| |||
75 | 87 | | |
76 | 88 | | |
77 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
78 | 98 | | |
79 | 99 | | |
80 | 100 | | |
81 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
434 | 434 | | |
435 | 435 | | |
436 | 436 | | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
437 | 446 | | |
438 | 447 | | |
439 | 448 | | |
| |||
2712 | 2721 | | |
2713 | 2722 | | |
2714 | 2723 | | |
| 2724 | + | |
| 2725 | + | |
| 2726 | + | |
| 2727 | + | |
| 2728 | + | |
| 2729 | + | |
| 2730 | + | |
| 2731 | + | |
| 2732 | + | |
| 2733 | + | |
| 2734 | + | |
| 2735 | + | |
| 2736 | + | |
| 2737 | + | |
| 2738 | + | |
| 2739 | + | |
| 2740 | + | |
| 2741 | + | |
| 2742 | + | |
| 2743 | + | |
| 2744 | + | |
| 2745 | + | |
| 2746 | + | |
| 2747 | + | |
| 2748 | + | |
| 2749 | + | |
| 2750 | + | |
2715 | 2751 | | |
2716 | 2752 | | |
2717 | 2753 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| 175 | + | |
175 | 176 | | |
176 | 177 | | |
177 | 178 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
570 | 570 | | |
571 | 571 | | |
572 | 572 | | |
573 | | - | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
574 | 580 | | |
575 | 581 | | |
576 | 582 | | |
| |||
3191 | 3197 | | |
3192 | 3198 | | |
3193 | 3199 | | |
| 3200 | + | |
| 3201 | + | |
| 3202 | + | |
| 3203 | + | |
| 3204 | + | |
| 3205 | + | |
| 3206 | + | |
| 3207 | + | |
| 3208 | + | |
| 3209 | + | |
| 3210 | + | |
3194 | 3211 | | |
3195 | 3212 | | |
3196 | 3213 | | |
| |||
3332 | 3349 | | |
3333 | 3350 | | |
3334 | 3351 | | |
| 3352 | + | |
| 3353 | + | |
| 3354 | + | |
3335 | 3355 | | |
3336 | 3356 | | |
3337 | 3357 | | |
| |||
3754 | 3774 | | |
3755 | 3775 | | |
3756 | 3776 | | |
| 3777 | + | |
| 3778 | + | |
| 3779 | + | |
| 3780 | + | |
| 3781 | + | |
| 3782 | + | |
| 3783 | + | |
| 3784 | + | |
| 3785 | + | |
| 3786 | + | |
3757 | 3787 | | |
3758 | 3788 | | |
3759 | 3789 | | |
| |||
4585 | 4615 | | |
4586 | 4616 | | |
4587 | 4617 | | |
| 4618 | + | |
| 4619 | + | |
| 4620 | + | |
| 4621 | + | |
| 4622 | + | |
| 4623 | + | |
| 4624 | + | |
| 4625 | + | |
| 4626 | + | |
| 4627 | + | |
| 4628 | + | |
| 4629 | + | |
| 4630 | + | |
| 4631 | + | |
| 4632 | + | |
| 4633 | + | |
| 4634 | + | |
| 4635 | + | |
| 4636 | + | |
| 4637 | + | |
| 4638 | + | |
| 4639 | + | |
| 4640 | + | |
| 4641 | + | |
| 4642 | + | |
| 4643 | + | |
| 4644 | + | |
| 4645 | + | |
| 4646 | + | |
4588 | 4647 | | |
4589 | 4648 | | |
4590 | 4649 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2826 | 2826 | | |
2827 | 2827 | | |
2828 | 2828 | | |
| 2829 | + | |
| 2830 | + | |
| 2831 | + | |
| 2832 | + | |
| 2833 | + | |
| 2834 | + | |
| 2835 | + | |
| 2836 | + | |
| 2837 | + | |
| 2838 | + | |
| 2839 | + | |
| 2840 | + | |
| 2841 | + | |
| 2842 | + | |
| 2843 | + | |
| 2844 | + | |
| 2845 | + | |
| 2846 | + | |
| 2847 | + | |
| 2848 | + | |
| 2849 | + | |
| 2850 | + | |
| 2851 | + | |
| 2852 | + | |
| 2853 | + | |
2829 | 2854 | | |
2830 | 2855 | | |
2831 | 2856 | | |
| |||
8671 | 8696 | | |
8672 | 8697 | | |
8673 | 8698 | | |
| 8699 | + | |
| 8700 | + | |
| 8701 | + | |
| 8702 | + | |
| 8703 | + | |
| 8704 | + | |
| 8705 | + | |
| 8706 | + | |
| 8707 | + | |
| 8708 | + | |
| 8709 | + | |
| 8710 | + | |
| 8711 | + | |
| 8712 | + | |
| 8713 | + | |
| 8714 | + | |
| 8715 | + | |
| 8716 | + | |
| 8717 | + | |
| 8718 | + | |
| 8719 | + | |
| 8720 | + | |
| 8721 | + | |
| 8722 | + | |
| 8723 | + | |
| 8724 | + | |
| 8725 | + | |
| 8726 | + | |
| 8727 | + | |
| 8728 | + | |
8674 | 8729 | | |
8675 | 8730 | | |
8676 | 8731 | | |
| |||
0 commit comments