Skip to content

Commit 49baba9

Browse files
committed
address feedback
1 parent cbd17a2 commit 49baba9

3 files changed

Lines changed: 23 additions & 25 deletions

File tree

Python/bytecodes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3830,7 +3830,7 @@ dummy_func(
38303830

38313831
macro(FOR_ITER_VIRTUAL) =
38323832
unused/1 + // Skip over the counter
3833-
_RECORD_NOS +
3833+
_RECORD_NOS + // Required for family-uniform recording (gh-148571).
38343834
_GUARD_NOS_ITER_VIRTUAL +
38353835
_FOR_ITER_VIRTUAL;
38363836

Python/optimizer_bytecodes.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1453,24 +1453,23 @@ dummy_func(void) {
14531453
}
14541454

14551455
op(_FOR_ITER_TIER_TWO, (iter, null_or_index -- iter, null_or_index, next)) {
1456+
bool definite = true;
14561457
PyTypeObject *type = sym_get_type(iter);
1457-
if (type != NULL && type != &PyGen_Type && type->tp_iternext != NULL) {
1458-
ADD_OP(_ITER_NEXT_INLINE, 0, (uintptr_t)type->tp_iternext);
1458+
if (type == NULL) {
1459+
type = sym_get_probable_type(iter);
1460+
definite = false;
14591461
}
1460-
else if (!sym_has_type(iter)) {
1461-
PyTypeObject *probable = sym_get_probable_type(iter);
1462-
if (probable != NULL &&
1463-
probable != &PyGen_Type &&
1464-
probable->tp_iternext != NULL) {
1465-
PyType_Watch(TYPE_WATCHER_ID, (PyObject *)probable);
1466-
_Py_BloomFilter_Add(dependencies, probable);
1467-
sym_set_type(iter, probable);
1462+
if (type != NULL && type != &PyGen_Type && type->tp_iternext != NULL) {
1463+
PyType_Watch(TYPE_WATCHER_ID, (PyObject *)type);
1464+
_Py_BloomFilter_Add(dependencies, type);
1465+
if (!definite) {
1466+
sym_set_type(iter, type);
14681467
assert((this_instr - 1)->opcode == _RECORD_NOS_TYPE);
14691468
int32_t orig_target = (this_instr - 1)->target;
1470-
ADD_OP(_GUARD_TYPE_ITER, 0, (uintptr_t)probable);
1469+
ADD_OP(_GUARD_TYPE_ITER, 0, (uintptr_t)type);
14711470
uop_buffer_last(&ctx->out_buffer)->target = orig_target;
1472-
ADD_OP(_ITER_NEXT_INLINE, 0, (uintptr_t)probable->tp_iternext);
14731471
}
1472+
ADD_OP(_ITER_NEXT_INLINE, 0, (uintptr_t)type->tp_iternext);
14741473
}
14751474
next = sym_new_not_null(ctx);
14761475
}

Python/optimizer_cases.c.h

Lines changed: 11 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)