Skip to content

[mypyc] Try adjusting error kinds for all blocks #15262

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

Merged
merged 1 commit into from
May 25, 2023

Conversation

ichard26
Copy link
Collaborator

@ichard26 ichard26 commented May 18, 2023

adjust_error_kinds() should be run over every block, but the old impl. of insert_exception_handling() would stop iterating over blocks once it generated a default error handler. This made sense for its original purpose, but unfortunately limits the effectiveness of adjust_error_kinds().

Changing insert_exception_handling() to loop over every block no matter what also means we can get rid of the weird GetAttr special casing in the branch emit logic (stumbling across that is what made me investigate in the first place!).

This reduces self-compile LOC by 1.1% in my experiments (avoiding error branches sometimes eliminates register assignments or on-error decrefs... according to my brief look through the C diff between master and this patch).

Revision Self-compile C LOC
PR 2 265 486 (-1.1%)
Master (905c2cb) 2 290 748

Notable removals in the diff (other than the all of the label renumbering) ...1

image
image

Footnotes

  1. apologies for the screenshots, this diff was generated during a SSH session so copying and pasting is a real pain.

adjust_error_kinds() should be run over every block, but the old impl.
of insert_exception_handling() would stop iterating over blocks once it
generated a default error handler. This made sense for its original
purpose, but now this limits the effectiveness of adjust_error_kinds().

Changing insert_exception_handling() to loop over every block no matter
what also means we can get rid of the weird GetAttr special casing in
the branch emit logic (stumbling across that is what made me investigate
in the first place!).

This reduces self-compile LOC by 1.1% in my experiments (avoiding error
branchs sometimes avoids register assignments or on-error decrefs...
according to my brief look through the C diff between master and this
patch).
Copy link
Collaborator

@JukkaL JukkaL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice win -- it both simplifies the implementation and produces smaller code.

@JukkaL JukkaL merged commit ac6dc18 into python:master May 25, 2023
@ichard26 ichard26 deleted the fix-always-defined-error-adjust branch May 25, 2023 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants