gh-134584: Eliminate redundant refcounting in TO_BOOL_INT, TO_BOOL_LIST (GH-143759)

This commit is contained in:
reiden 2026-01-12 22:56:26 +01:00 committed by GitHub
parent 66e1399311
commit c556786b8b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 1047 additions and 920 deletions

View file

@ -400,19 +400,21 @@ dummy_func(void) {
}
}
op(_TO_BOOL_INT, (value -- res)) {
int already_bool = optimize_to_bool(this_instr, ctx, value, &res, false);
op(_TO_BOOL_INT, (value -- res, v)) {
int already_bool = optimize_to_bool(this_instr, ctx, value, &res, true);
if (!already_bool) {
sym_set_type(value, &PyLong_Type);
res = sym_new_truthiness(ctx, value, true);
}
v = value;
}
op(_TO_BOOL_LIST, (value -- res)) {
int already_bool = optimize_to_bool(this_instr, ctx, value, &res, false);
op(_TO_BOOL_LIST, (value -- res, v)) {
int already_bool = optimize_to_bool(this_instr, ctx, value, &res, true);
if (!already_bool) {
res = sym_new_type(ctx, &PyBool_Type);
}
v = value;
}
op(_TO_BOOL_NONE, (value -- res)) {