Skip to content
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

GH-126222: Fix _PyUop_num_popped #126507

Merged
merged 3 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 56 additions & 56 deletions Include/internal/pycore_uop_metadata.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Lib/test/test_capi/test_opt.py
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,14 @@ def fn(a):

fn(A())

def test_jit_error_pops(self):
"""
Tests that the correct number of pops are inserted into the
exit stub
"""
items = 17 * [None] + [[]]
with self.assertRaises(TypeError):
{item for item in items}

if __name__ == "__main__":
unittest.main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Do not include count of "peek" items in ``_PyUop_num_popped``. This ensures
that the correct number of items are popped from the stack when a micro-op
exits with an error.
2 changes: 2 additions & 0 deletions Tools/cases_generator/uop_metadata_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def generate_names_and_flags(analysis: Analysis, out: CWriter) -> None:
if uop.is_viable() and uop.properties.tier != 1:
stack = Stack()
for var in reversed(uop.stack.inputs):
if var.peek:
break
stack.pop(var)
popped = (-stack.base_offset).to_c()
out.emit(f"case {uop.name}:\n")
Expand Down
Loading