8000 GH-131798: Remove guard for known type in TO_BOOL_STR by fluhus · Pull Request #131816 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-131798: Remove guard for known type in TO_BOOL_STR #131816

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 9 commits into from
Mar 30, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Break down TO_BOOL_STR into guard and to-bool
  • Loading branch information
fluhus committed Mar 26, 2025
commit ddcb309455e38be365e2d421f8df50b173035d50
2 changes: 1 addition & 1 deletion Include/internal/pycore_opcode_metadata.h

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

193 changes: 97 additions & 96 deletions Include/internal/pycore_uop_ids.h

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

6 changes: 5 additions & 1 deletion Include/internal/pycore_uop_metadata.h

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

9 changes: 8 additions & 1 deletion Python/bytecodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,10 +512,14 @@ dummy_func(
res = PyStackRef_False;
}

inst(TO_BOOL_STR, (unused/1, unused/2, value -- res)) {
op(_GUARD_TOS_UNICODE, (value-- value)) {
PyObject *value_o = PyStackRef_AsPyObjectBorrow(value);
EXIT_IF(!PyUnicode_CheckExact(value_o));
}

op(_TO_BOOL_STR, (value-- res)) {
STAT_INC(TO_BOOL, hit);
PyObject* value_o = PyStackRef_AsPyObjectBorrow(value);
if (value_o == &_Py_STR(empty)) {
assert(_Py_IsImmortal(value_o));
DEAD(value);
Expand All @@ -528,6 +532,9 @@ dummy_func(
}
}

macro(TO_BOOL_STR) =
_GUARD_TOS_UNICODE + unused / 1 + unused / 2 + _TO_BOOL_STR;

op(_REPLACE_WITH_TRUE, (value -- res)) {
PyStackRef_CLOSE(value);
res = PyStackRef_True;
Expand Down
11 changes: 9 additions & 2 deletions Python/executor_cases.c.h

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

Loading
0