gh-131798: Optimize _ITER_CHECK_RANGE and _ITER_CHECK_LIST in the JIT (GH-144583)

This commit is contained in:
Sacul 2026-03-17 22:07:17 +08:00 committed by GitHub
parent 9d7621b75b
commit 1efd9939c8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 51 additions and 0 deletions

View file

@ -1091,6 +1091,24 @@ dummy_func(void) {
sym_set_type(iter, &PyTuple_Type);
}
op(_ITER_CHECK_LIST, (iter, null_or_index -- iter, null_or_index)) {
if (sym_matches_type(iter, &PyList_Type)) {
ADD_OP(_NOP, 0, 0);
}
else {
sym_set_type(iter, &PyList_Type);
}
}
op(_ITER_CHECK_RANGE, (iter, null_or_index -- iter, null_or_index)) {
if (sym_matches_type(iter, &PyRange_Type)) {
ADD_OP(_NOP, 0, 0);
}
else {
sym_set_type(iter, &PyRange_Type);
}
}
op(_ITER_NEXT_RANGE, (iter, null_or_index -- iter, null_or_index, next)) {
next = sym_new_type(ctx, &PyLong_Type);
}