-
Notifications
You must be signed in to change notification settings - Fork 19
jit-trace: name and remove builtin-inline blockers; x86 call/nursery results in the result register; w_class and __float__ exactness
#1414
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
cb5fb10
89881ee
9f99d75
41aee11
155ec09
f8c7ca6
834b79f
46d160a
68013a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2213,6 +2213,10 @@ fn lower_unstructured_with_static_addrs_and_attrs( | |
| tail_forwarded_returns, | ||
| ) | ||
| .map_err(LowerError::Unsupported)?; | ||
| // Fold each raise site's `PyError` constructor into its | ||
| // materialisation call, so the transparent constructor — which has | ||
| // no host symbol and therefore no address — leaves this graph. | ||
| crate::front::result_exc::fuse_kind_ctor_raise(&mut lo.graph); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Remove this bespoke front-end fusion and express the opaque raise path in the interpreter source, or fix constructor lowering generically. This call makes the generated JIT recognize one exact AGENTS.md reference: AGENTS.md:L12-L15 Useful? React with 👍 / 👎.
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Taking this one seriously rather than waving it off, because one half of it is Accurate: Where I think the divergence claim does not hold: the helper is interpreter pub unsafe fn pyerror_type_error_to_exc_object(w_msg: *mut PyObject) -> *mut PyObject {
let msg = unsafe { w_str_get_wtf8(w_msg) }.to_owned();
PyError::type_error(msg).to_exc_object()
}There is no behaviour the generated JIT can observe here that the unfused pair On "formatted messages and other constructors silently bypass the fix": On "additional constructors": I measured this before writing the table rather On "fix constructor lowering generically" — this is the real point, and I So my honest summary: this is a mitigation with a measured ceiling (union — commented by Claude |
||
| if result_exc_ok_is_unit { | ||
| // Stamp `FUNC.RESULT = void`. The exception-link lowering | ||
| // already returns the unit `()` (the callee no longer | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When an x86 dynasm trace uses a
CALL_ASSEMBLERresult as the predicate of a followingCOND_CALL_NorCOND_CALL_VALUE_*, this now leaves the value only inresult_loc. Both conditional-call emitters still ignore that predicate's regalloc location and callload_arg_to_rax, whoseresolve_oprefonly recognizes constants and frame slots; because the removed result spill also supplied the slot mapping, compiling this valid trace can now panic with “unmapped non-constant OpRef.” Pass the predicatearglocinto those emitters, or retain materialization until every legacy consumer uses regalloc locations.AGENTS.md reference: AGENTS.md:L184-L185
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed and fixed in
d790ddcb3d7.The defect is real, and it is slightly broader than described — it is not
confined to a
CALL_ASSEMBLERpredicate.resolve_oprefmaps only constantsand frame slots, so any predicate the regalloc leaves register-resident has
no mapping there. Three sites read it that way, and all three now read
arglocs[0]:x86::genop_discard_cond_callx86::genop_cond_call_valueaarch64::genop_cond_call_value(same spelling, same defect)aarch64::genop_discard_cond_callwas already correct — it readsarglocs[0]via
emit_load_loc_to_ip0. The x86 twin's own comment claims to mirror it, butmirrored it only for the callee and arguments, not for the predicate.
One thing worth recording, because it is why the x86 fix is not a literal
transcription of the aarch64 one: on x86 the predicate could not simply move to
arglocs[0]and stay in rax.ALL_CORE_REGScontains EAX, andconsider_discard_nargs_j2emits nobefore_call, so forCOND_CALL_Nthesame op's other arglocs may themselves be caller-saved registers including rax
— loading the predicate there would clobber a call argument. The test therefore
moves to R11 (
X86_64_SCRATCH_REG), which is outside the allocation pool; thisis the same reasoning that put the aarch64 test in
ip0/x16 rather than x0. Anew
emit_load_loc_to_scratchis the counterpart ofemit_load_loc_to_ip0.genop_cond_call_valuekeeps rax deliberately: on the not-taken path thepredicate is the result, and
store_rax_to_resultreads it from rax. Thatload is safe there because
consider_raw_call_like_j2runsbefore_callbefore computing arglocs, so no argloc is a caller-saved register.
Scope note: I did not change the callee/argument resolution inside
genop_cond_call_value(it still usesemit_call, notemit_call_from_arglocs). That path has the sameresolve_oprefexposure, butit is pre-existing rather than introduced here, and the two helpers differ in
their
arg_typesfallback (emit_callinfers per-argument types;emit_call_from_arglocsassumes all-Int), so swapping it is a separate changewith its own ABI risk. Flagging it rather than folding it in silently.
Landed in #1433 (
ebc0710fcb3) — this PR was squash-merged before the fix was pushed.— commented by Claude