GH-115685: Split _TO_BOOL_ALWAYS_TRUE into micro-ops (GH-116352)

This commit is contained in:
Mark Shannon 2024-03-05 15:23:08 +00:00 committed by GitHub
parent 0c81ce1360
commit 23db9c6227
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 50 additions and 44 deletions

View file

@ -382,15 +382,16 @@ dummy_func(
}
}
inst(TO_BOOL_ALWAYS_TRUE, (unused/1, version/2, value -- res)) {
// This one is a bit weird, because we expect *some* failures:
assert(version);
EXIT_IF(Py_TYPE(value)->tp_version_tag != version);
STAT_INC(TO_BOOL, hit);
DECREF_INPUTS();
op(_REPLACE_WITH_TRUE, (value -- res)) {
Py_DECREF(value);
res = Py_True;
}
macro(TO_BOOL_ALWAYS_TRUE) =
unused/1 +
_GUARD_TYPE_VERSION +
_REPLACE_WITH_TRUE;
inst(UNARY_INVERT, (value -- res)) {
res = PyNumber_Invert(value);
DECREF_INPUTS();