FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-131798: JIT: Split CALL_STR_1 into several uops by tomasr8 · Pull Request #132849 · python/cpython · GitHub

Repository navigation

gh-131798: JIT: Split CALL_STR_1 into several uops - #132849

Merged
brandtbucher merged 6 commits into
python:mainfrom
tomasr8:jit-call-str-1
Apr 24, 2025
Merged

brandtbucher merged 6 commits into
python:mainfrom
tomasr8:jit-call-str-1

Conversation

tomasr8 commented Apr 23, 2025 •
edited by bedevere-app Bot
Loading

Copy link
Copy Markdown
Member

CALL_STR_1 is equivalent to str(...).

Very similar to previous work on splitting up CALL_TYPE_1: #132419
This splits the instruction into a smaller instruction + 2 guards which can be optimized away. This also sets the return type to str.

Comment on lines +859 to +863
if (sym_matches_type(arg, &PyUnicode_Type)) {
// e.g. str('foo') or str(foo) where foo is known to be a string
PyObject *value = sym_get_const(ctx, arg);
res = sym_new_const(ctx, value);
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This is an optimization that Brandt suggested. When in str(foo), foo is known to be a string, we can propagate it to the output. I also added a test for this case.

brandtbucher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks great! Just two suggestions:

Comment thread Python/optimizer_bytecodes.c Outdated
tomasr8 requested a review from brandtbucher April 24, 2025 19:52
brandtbucher merged commit 0a387b3 into python:main Apr 24, 2025
tomasr8 deleted the jit-call-str-1 branch April 24, 2025 19:58

tomasr8 commented Apr 24, 2025

Copy link
Copy Markdown
Member Author

Thanks for the review!

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL