mirror of
https://github.com/python/cpython.git
synced 2026-01-29 10:42:17 +00:00
GH-138245: Perform boolean guards by testing a single bit, rather than a full pointer comparison. (GH-143810)
This commit is contained in:
parent
f52af86cba
commit
9eab67d507
8 changed files with 2478 additions and 1027 deletions
|
|
@ -1136,15 +1136,6 @@ dummy_func(void) {
|
|||
}
|
||||
}
|
||||
|
||||
op(_GUARD_IS_TRUE_POP, (flag -- )) {
|
||||
if (sym_is_const(ctx, flag)) {
|
||||
PyObject *value = sym_get_const(ctx, flag);
|
||||
assert(value != NULL);
|
||||
eliminate_pop_guard(this_instr, ctx, value != Py_True);
|
||||
}
|
||||
sym_set_const(flag, Py_True);
|
||||
}
|
||||
|
||||
op(_CALL_LIST_APPEND, (callable, self, arg -- none, c, s)) {
|
||||
(void)(arg);
|
||||
c = callable;
|
||||
|
|
@ -1181,12 +1172,39 @@ dummy_func(void) {
|
|||
}
|
||||
}
|
||||
|
||||
op(_GUARD_IS_TRUE_POP, (flag -- )) {
|
||||
if (sym_is_const(ctx, flag)) {
|
||||
PyObject *value = sym_get_const(ctx, flag);
|
||||
assert(value != NULL);
|
||||
eliminate_pop_guard(this_instr, ctx, value != Py_True);
|
||||
}
|
||||
else {
|
||||
int bit = get_test_bit_for_bools();
|
||||
if (bit) {
|
||||
REPLACE_OP(this_instr,
|
||||
test_bit_set_in_true(bit) ?
|
||||
_GUARD_BIT_IS_SET_POP :
|
||||
_GUARD_BIT_IS_UNSET_POP, bit, 0);
|
||||
}
|
||||
}
|
||||
sym_set_const(flag, Py_True);
|
||||
}
|
||||
|
||||
op(_GUARD_IS_FALSE_POP, (flag -- )) {
|
||||
if (sym_is_const(ctx, flag)) {
|
||||
PyObject *value = sym_get_const(ctx, flag);
|
||||
assert(value != NULL);
|
||||
eliminate_pop_guard(this_instr, ctx, value != Py_False);
|
||||
}
|
||||
else {
|
||||
int bit = get_test_bit_for_bools();
|
||||
if (bit) {
|
||||
REPLACE_OP(this_instr,
|
||||
test_bit_set_in_true(bit) ?
|
||||
_GUARD_BIT_IS_UNSET_POP :
|
||||
_GUARD_BIT_IS_SET_POP, bit, 0);
|
||||
}
|
||||
}
|
||||
sym_set_const(flag, Py_False);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue