gh-148210: fix incorrect _BINARY_OP_SUBSCR_DICT JIT optimization (GH-148213)

This commit is contained in:
Kumar Aditya 2026-04-08 20:53:20 +05:30 committed by GitHub
parent bb03c8bd02
commit 6e081614eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 25 additions and 10 deletions

View file

@ -515,18 +515,18 @@ dummy_func(void) {
}
op(_BINARY_OP_SUBSCR_DICT, (dict_st, sub_st -- res, ds, ss)) {
PyObject *sub = sym_get_const(ctx, sub_st);
if (sub != NULL) {
optimize_dict_known_hash(ctx, dependencies, this_instr,
sub, _BINARY_OP_SUBSCR_DICT_KNOWN_HASH);
}
res = sym_new_not_null(ctx);
ds = dict_st;
ss = sub_st;
PyObject *sub = sym_get_const(ctx, sub_st);
if (sym_is_not_container(sub_st) &&
sym_matches_type(dict_st, &PyFrozenDict_Type)) {
REPLACE_OPCODE_IF_EVALUATES_PURE(dict_st, sub_st, res);
}
else if (sub != NULL) {
optimize_dict_known_hash(ctx, dependencies, this_instr,
sub, _BINARY_OP_SUBSCR_DICT_KNOWN_HASH);
}
}
op(_BINARY_OP_SUBSCR_LIST_SLICE, (list_st, sub_st -- res, ls, ss)) {