-
Notifications
You must be signed in to change notification settings - Fork 19
jit: inline a user __next__ under FOR_ITER, plus three exception wrong-code fixes #1270
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
8b4931d
4b8bb12
da18f0b
ac12f59
6b995c5
50481e2
bad0678
1bdc9e8
243ed50
77d6c7a
a909075
260697e
0cca7dd
270f822
ef4f28d
2ef71b4
bae52e3
4e25ed4
dfa0282
3188e23
780971b
4b7b4a1
254bc28
7a73390
22b06d8
6f0d55a
8231221
2072b26
4f6fbb9
077977f
75eab4a
fea3ab7
268e3f8
9b40bf5
2ca8618
b2e4b3d
963b9a3
93454cb
f6c1d6d
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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6300,20 +6300,28 @@ impl OptContext { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| op.getdescr().is_some_and(|d| d.is_resume_guard_copied()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // A walker-native range FOR_ITER class guard carries a pre-minted | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // marker descr (`range_foriter_green_key`) so its failure can demote | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // the specialization by descr identity. `Op::clone` shares the descr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Arc, so unroll's phase-1/phase-2 emissions of the guard reach this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // function on the same, already-finalized descr. Mint a fresh marked | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // descr for this emission — mirroring the `op.descr.is_none()` arm's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // fresh-per-emission descr — so the once-per-descr `finish()` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // invariant below still holds for it (and for every other guard). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Walker-native FOR_ITER guards can carry a pre-minted range or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // user-instance-next marker descr so failure routing is keyed by descr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // identity. `Op::clone` shares the descr Arc, so unroll's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // phase-1/phase-2 emissions of the guard reach this function on the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // same, already-finalized descr. Mint a fresh marked descr for this | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // emission — mirroring the `op.descr.is_none()` arm's fresh-per-emission | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // descr — so the once-per-descr `finish()` invariant below still holds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // for it (and for every other guard). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let refinalize_marked_key = op | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .getdescr() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .and_then(|d| d.range_foriter_green_key()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .filter(|_| op.resolved_rd_numb().is_some()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let refinalize_instance_next_key = op | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .getdescr() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .and_then(|d| d.instance_next_foriter_green_key()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .filter(|_| op.resolved_rd_numb().is_some()); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if let Some(key) = refinalize_marked_key { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| op.setdescr(crate::compile::make_resume_guard_descr_range_foriter(key)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else if let Some(key) = refinalize_instance_next_key { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| op.setdescr( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| crate::compile::make_resume_guard_descr_instance_next_foriter(Some(op.opcode), key), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
6311
to
6325
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. 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win Guard refinalize logic is correct; consider an explicit mutual-exclusion assertion. The refinalize block re-mints a descr for either the range-FOR_ITER marker or the instance-next-FOR_ITER marker. When both Add a ♻️ Proposed defensive assertion let refinalize_instance_next_key = op
.getdescr()
.and_then(|d| d.instance_next_foriter_green_key())
.filter(|_| op.resolved_rd_numb().is_some());
+ debug_assert!(
+ refinalize_marked_key.is_none() || refinalize_instance_next_key.is_none(),
+ "a ResumeGuardDescr must not carry both a range and an instance-next FOR_ITER key",
+ );
if let Some(key) = refinalize_marked_key {📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // resume.py:397 `assert not storage.rd_numb` — finish() runs at | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
This is bad idea