GH-138245: Perform boolean guards by testing a single bit, rather than a full pointer comparison. (GH-143810)

This commit is contained in:
Mark Shannon 2026-01-21 15:58:27 +00:00 committed by GitHub
parent f52af86cba
commit 9eab67d507
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 2478 additions and 1027 deletions

View file

@ -5273,6 +5273,28 @@ dummy_func(
AT_END_EXIT_IF(!is_false);
}
replicate(4:8) op (_GUARD_BIT_IS_SET_POP, (flag -- )) {
#ifdef Py_STACKREF_DEBUG
uintptr_t bits = flag.index;
#else
uintptr_t bits = flag.bits;
#endif
uintptr_t set = (1 << oparg) & bits;
DEAD(flag);
AT_END_EXIT_IF(set == 0);
}
replicate(4:8) op (_GUARD_BIT_IS_UNSET_POP, (flag -- )) {
#ifdef Py_STACKREF_DEBUG
uintptr_t bits = flag.index;
#else
uintptr_t bits = flag.bits;
#endif
uintptr_t set = (1 << oparg) & bits;
DEAD(flag);
AT_END_EXIT_IF(set != 0);
}
op (_GUARD_IS_NONE_POP, (val -- )) {
int is_none = PyStackRef_IsNone(val);
if (!is_none) {